creating customized bult-in elements with constructor and document.createElement have different results
Reported by
edo.c...@gmail.com,
Oct 19 2016
|
|||||||
Issue description
Chrome Version : 54.0.2840.59
What steps will reproduce the problem?
(1) class MyElem extends HTMLElement {}
(2) customElements.define('my-elem', MyElem, { extends: 'div' })
(3) document.createElement('div', 'my-elem') // <div is="my-elem"></div>
(4) new MyElem() // <my-elem></my-elem>
What is the expected result?
The element constructor should retrieve the same result of document.createElement method.
What happens instead?
An element with custom tag name is created.
Please provide any additional information below. Attach a screenshot if
possible.
Custom Elements spec: https://w3c.github.io/webcomponents/spec/custom/ , "2.1.2 Creating a customized built-in element"
,
Oct 20 2016
,
Oct 21 2016
The examples provided by "edo" are not conform to current V1 specification. First of all, it looks like the implementation is not complete: https://bugs.chromium.org/p/chromium/issues/detail?id=652579 Secondly, the example should rather bethe following: 1. class MyDiv extends HTMLDivElement {} 2. customElements.define('my-div', MyDiv, { extends: 'div' }) 3. document.createElement('div', {is: 'my-div'}) 4. new MyDiv() TL;DR the example uses V0 API instead of V1, but even using proper V1 API nothing works as expected. Best Regards
,
Oct 25 2016
yurak is working on this. Assigning to me because she doesn't have editbugs yet IIRC.
What you're seeing here results from customized built-in elements not being implemented in customElements.define, but createElement('foo', 'x-bar') creates an element for the old document.register custom elements.
By the way, document.createElement('div', 'my-div') is a very old draft of the custom elements spec that only Chrome implements. The new syntax is document.createElement('div', {is: 'my-div'}). That doesn't work yet, but when it does, we plan to deprecate and remove the createElement(string, string) version so be ready for that!
,
Oct 27 2016
,
Nov 18 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/fe200cd217b99368dbded68a0350d33c552c6a5b commit fe200cd217b99368dbded68a0350d33c552c6a5b Author: yurak <yurak@google.com> Date: Fri Nov 18 08:08:40 2016 https://dom.spec.whatwg.org/#dom-document-createelement Definition is checked for HTML namespace elements in document.createElement Customized built-in elements can now be created with the document.createElement NOTE: This is behind runtime enabled flag "CustomElementsBuiltin". Syntax: https://html.spec.whatwg.org/multipage/scripting.html#custom-elements-customized-builtin-example Implemented create element algorithm https://dom.spec.whatwg.org/#concept-create-element Steps 5-7: /core/dom/custom/CustomElement.cpp Added some tests. (Sorry this patch is big) BUG= 648828 , 657583 Review-Url: https://codereview.chromium.org/2477713003 Cr-Commit-Position: refs/heads/master@{#433146} [modify] https://crrev.com/fe200cd217b99368dbded68a0350d33c552c6a5b/third_party/WebKit/LayoutTests/custom-elements/spec/create-element-defined-synchronous.html [add] https://crrev.com/fe200cd217b99368dbded68a0350d33c552c6a5b/third_party/WebKit/LayoutTests/custom-elements/spec/create-element.html [modify] https://crrev.com/fe200cd217b99368dbded68a0350d33c552c6a5b/third_party/WebKit/LayoutTests/custom-elements/v0-v1-interop.html [delete] https://crrev.com/bd0d9c52947c4db46e946743783660bd06354359/third_party/WebKit/LayoutTests/fast/dom/custom/create-element-second-arg.html [modify] https://crrev.com/fe200cd217b99368dbded68a0350d33c552c6a5b/third_party/WebKit/Source/core/dom/Document.cpp [modify] https://crrev.com/fe200cd217b99368dbded68a0350d33c552c6a5b/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp [modify] https://crrev.com/fe200cd217b99368dbded68a0350d33c552c6a5b/third_party/WebKit/Source/core/dom/custom/CustomElement.h
,
Jan 20 2017
The assigned owner "yurak@google.com" is not able to receive e-mails, please re-triage. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jan 20 2017
,
Jan 30 2017
,
Jan 30 2017
I believe yurak's patch fixed this, provided you use the new APIs and enable the feature flag. |
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by sureshkumari@chromium.org
, Oct 20 2016Labels: Needs-Feedback