Custom element created via importDoc.createElement returns element with wrong ownerDocument |
||
Issue descriptionWith CL https://codereview.chromium.org/2132343002 (under review as of now) custom elements can be instantiated in imports, but if it is instantiated in an import with createElement(), like <script> let importDoc = document.currentScript.ownerDocument; let e = importDoc.createElement('my-element'); assert(e.ownerDocument === importDoc); </script> the assertion will fail, because e's ownerDocument is currently set to (the master) document. If HTML parser creates elements (either via upgrade or synchronous creation) both results in e.ownerDocument === importDoc.
,
Aug 24 2016
,
Aug 24 2016
I was wrong in the original description: if parser creates custom element in a synchronous way, this problem happens.
,
Aug 24 2016
Can you confirm: with this bug, will `ownerDocument` be wrong for parser-created elements only during its constructor, or will it be wrong afterwards also?
e.g. does the assert below fail when the code is in an import?
<script>
customElements.define('my-element', class extends HTMLElement {});
</script>
<my-element></my-element>
<script>
let importDoc = document.currentScript.ownerDocument;
let myEl = importDoc.querySelector('my-element');
console.assert(myEl.ownerDocument == importDoc.ownerDocument);
<script>
,
Aug 24 2016
The ownerDocument is wrong not only in the constructor, but afterwards as well. So the assertion fails.
,
Aug 26 2016
|
||
►
Sign in to add a comment |
||
Comment 1 by kochi@chromium.org
, Aug 24 2016