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

Issue 657583 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

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"

 
Cc: sureshkumari@chromium.org
Labels: Needs-Feedback
could you please provide the sample Html file to traige the issue further.


Thanks.
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
Cc: yurak@google.com
Owner: dominicc@chromium.org
Status: Started (was: Unconfirmed)
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!
Owner: yurak@google.com
Project Member

Comment 6 by bugdroid1@chromium.org, 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

Project Member

Comment 7 by sheriffbot@chromium.org, Jan 20 2017

Labels: Hotlist-Recharge-BouncingOwner
Status: Untriaged (was: Started)
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

Comment 8 by cda...@chromium.org, Jan 20 2017

Owner: ----
Components: Blink>DOM Blink>WebComponents
Cc: -yurak@google.com dominicc@chromium.org
Owner: yurak@google.com
Status: Fixed (was: Untriaged)
I believe yurak's patch fixed this, provided you use the new APIs and enable the feature flag.

Sign in to add a comment