Question

Under native HTML Imports, a <link rel="import" href="..."> will, once loaded, have an .import property pointing to the imported document. Under the polyfill, this property does not seem to be available. (See http://jsbin.com/sifem/4/edit, which displays "Got content" in the console under native HTML Imports in Canary, and "No content" under the polyfill.)

How then can one reliably access imported content in code?

Was it helpful?

Solution

When you wrote onload="loaded(this)" you bypassed the ShadowDOMPolyfill, so the reference received in loaded is unwrapped and unsuitable for use.

addEventListener doesn't have this problem:

http://jsbin.com/xokar/1/edit

You could also use wrap, like onload = "loaded(wrap(this))", but it's best to avoid referring to wrap|unwrap if you can.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top