RESOLVED FIXED 163147
importNode from template doesn't instantiate custom element
https://bugs.webkit.org/show_bug.cgi?id=163147
Summary importNode from template doesn't instantiate custom element
Jan Miksovsky
Reported 2016-10-07 15:10:27 PDT
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
Ryosuke Niwa
Comment 1 2016-10-07 23:46:48 PDT
This is kind of expected right now because we don't fully implement custom elements reactions yet.
Jan Miksovsky
Comment 2 2016-10-10 09:13:04 PDT
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
Comment 3 2016-10-10 19:08:44 PDT
(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
Comment 4 2016-10-10 21:50:20 PDT
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
Comment 5 2016-10-11 00:51:29 PDT
On my second thought, we should probably just fix the spec so that this case works.
Ryosuke Niwa
Comment 6 2016-10-19 00:22:08 PDT
Note You need to log in before you can comment on or make changes to this bug.