Specifying an 'is' attribute on an autonomous custom element should have no effect |
|||
Issue description
When an autonomous custom element definition exists named 'a-a',
createElement('a-a', {is: 'b-b'})
should create the autonomous custom element definition regardless of if a custom element definition with name 'b-b' exists.
The current implementation throws a NotFoundError.
,
Nov 17 2016
"Any namespace-less attribute that is relevant to the element's functioning, as determined by the element's author, may be specified on an autonomous custom element, so long as the attribute name is XML-compatible and contains no uppercase ASCII letters. The exception is the is attribute, which must not be specified on an autonomous custom element (and which will have no effect if it is)." My implementation wasn't doing this properly.
,
Nov 17 2016
That's a conformance requirement for authors, telling them what they must write to have valid HTML. It doesn't affect implementations, which must process is attributes according to the normative parts of the spec's processing model.
,
Nov 17 2016
If someone creates an element with createElement('a-a', {is: 'b-b'}) it should create an autonomous custom element with definition of 'a-a' with 'is' attribute set to 'b-b', right?
In this case my implementation was looking for a custom element definition with name 'b-b' and localName 'a-a', which doesn't exist.
,
Nov 17 2016
> If someone creates an element with createElement('a-a', {is: 'b-b'}) it should create an autonomous custom element with definition of 'a-a' with 'is' attribute set to 'b-b', right?
Well, I'm not sure? What does the spec say? Let me walk you through the process of finding out. Note how the section you quoted is never involved as it does not give any normative algorithm steps for createElement.
1. We start at https://dom.spec.whatwg.org/#dom-document-createelement and go to step 5
2. That takes us to https://dom.spec.whatwg.org/#concept-create-element passing document, 'a-a', the HTML namespace, null, 'b-b', and with the synchronous custom elements flag set.
3. Step 4 takes us to https://html.spec.whatwg.org/multipage/scripting.html#look-up-a-custom-element-definition passing document, the HTML namespace, 'a-a', and 'b-b'
4. In this algorithm, does step 4's condition hold? Maybe, if previously 'a-a' has been defined as an autonomous custom element. Let's call that case (A).
5. If 'a-a' has not been defined, we get to step 5. Is there a custom element definition with name equal to 'b-b' and local name equal to 'a-a'? Maybe. Let's call that case (B).
6. Otherwise, if neither step 4 or step 5's condition hold, we return null. Let's call that case (C).
In case (A), following the logic in https://dom.spec.whatwg.org/#concept-create-element will take us to step 6.1, calling the constructor for a-a which executes the relevant constructor and sets the `is` value to null. Popping back to https://dom.spec.whatwg.org/#dom-document-createelement step 6, we'll set the `is` attribute.
In case (B), we'll end up at step 5, which sets the `is` value to 'b-b' and enqueues an upgrade. Before the upgrade happens, we'll also set the `is` attribute.
And in case (C), we'll end up in step 7, which creates a new undefined element, but sets its `is` value to 'b-b'. We'll also set its `is` attribute.
----
I'm not sure which of case (A), (B), or (C) you were referring to. But in genreal the `is` option will have an effect, definitely. You have to follow the algorithm steps to work through it.
,
Nov 18 2016
I was referring to case (A), but my implementation wrongly responded with case (B)'s result. This is because I don't conform to the specs in https://dom.spec.whatwg.org/#dom-document-createelement. What I posted in the description above is the part of the spec that reminded me to test case (A) in the first place. I'll update the description to be more specific.
,
Nov 19 2016
,
Nov 20 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/f7888049506013dd915e6d9cbd03bbe837ccf271 commit f7888049506013dd915e6d9cbd03bbe837ccf271 Author: yurak <yurak@google.com> Date: Sun Nov 20 08:50:15 2016 Added some tests according to https://html.spec.whatwg.org/multipage/scripting.html#custom-elements-core-concepts Fixed a bug where: The 'is' attribute must not be specified on an autonomous custom element, if it is it has no effect BUG= 666166 Review-Url: https://codereview.chromium.org/2502223002 Cr-Commit-Position: refs/heads/master@{#433451} [modify] https://crrev.com/f7888049506013dd915e6d9cbd03bbe837ccf271/third_party/WebKit/LayoutTests/custom-elements/spec/create-element.html [modify] https://crrev.com/f7888049506013dd915e6d9cbd03bbe837ccf271/third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.cpp
,
Nov 24 2016
|
|||
►
Sign in to add a comment |
|||
Comment 1 by domenic@chromium.org
, Nov 17 2016