New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 640465 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Aug 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug

Blocking:
issue 594918



Sign in to add a comment

Custom element created via importDoc.createElement returns element with wrong ownerDocument

Project Member Reported by kochi@chromium.org, Aug 24 2016

Issue description

With 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.

 

Comment 1 by kochi@chromium.org, Aug 24 2016

Blocking: 594918

Comment 2 by kochi@chromium.org, Aug 24 2016

Summary: Custom element created via importDoc.createElement returns element with wrong ownerDocument (was: Custom element created via importDoc.createElement )

Comment 3 by kochi@chromium.org, Aug 24 2016

I was wrong in the original description: if parser creates custom element
in a synchronous way, this problem happens.
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>

Comment 5 by kochi@chromium.org, Aug 24 2016

The ownerDocument is wrong not only in the constructor, but afterwards as well.
So the assertion fails.

Comment 6 by kochi@chromium.org, Aug 26 2016

Status: Fixed (was: Started)
Fixed in r414434.

(commit-bot is not catching up to update issues?)

Sign in to add a comment