Bug 163147
Summary: | importNode from template doesn't instantiate custom element | ||
---|---|---|---|
Product: | WebKit | Reporter: | Jan Miksovsky <jan> |
Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | cdumez, rniwa |
Priority: | P2 | ||
Version: | Safari Technology Preview | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Bug Depends on: | |||
Bug Blocks: | 154907 |
Jan Miksovsky
See http://jsbin.com/tukocup/1/edit?html,console.
class TestElement extends HTMLElement {}
customElements.define('test-element', TestElement);
let template = document.createElement('template');
template.innerHTML = `<test-element></test-element>`;
let clone = document.importNode(template.content, true);
let element = clone.querySelector('test-element');
console.log(element instanceof TestElement); // true in Chrome Canary, false in WebKit
This defines a custom element, then tries to use it in a template. Following the importNode call, the test-element node should be an instance of TestElement, but it's not. (It works as expected in Chrome Canary.)
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Ryosuke Niwa
This is kind of expected right now because we don't fully implement custom elements reactions yet.
Jan Miksovsky
Ah, okay, we hadn't seen a description of what was/wasn't implemented. If such a description is posted somewhere, that would help us determine what bugs should be reported. Or should we just back off on reporting bugs for the time being?
Ryosuke Niwa
(In reply to comment #2)
> Ah, okay, we hadn't seen a description of what was/wasn't implemented. If
> such a description is posted somewhere, that would help us determine what
> bugs should be reported. Or should we just back off on reporting bugs for
> the time being?
I'm actively fixing this but expect that no custom element reaction would fire beyond handful of DOM functions like appendChild, setAttribute, cloneNode, etc...
Ryosuke Niwa
Oh actually, this behavior is expected. You need to insert the imported node into a document since upgrading now happens when an element is connected, not when it's instantiated.
Ryosuke Niwa
On my second thought, we should probably just fix the spec so that this case works.
Ryosuke Niwa
This has been fixed in https://trac.webkit.org/changeset/207170.