-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom elements to HTML #1012
Conversation
@@ -108,6 +108,7 @@ | |||
<li><code>var</code></li> | |||
<li><code>video</code></li> | |||
<li><code>wbr</code></li> | |||
<li><span>custom tags</span></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plan is to rename this in a follow up commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess, if we ever figure something out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I think we need to. "tags" is just super wrong.
I should have asked this earlier, where exactly does NewTarget come from? Is that worthy of a note or a cross-reference? |
I think it would be ideal to cross-reference, but ES does not have a definition for it; instead as far as I can tell it's just an ambient floating thing all ES algorithms get. I'll file an ES bug. |
<li><p>If <var>name</var> is <code>blink</code>, <code>bgsound</code>, <code>isindex</code>, | ||
<code>multicol</code>, <code>nextid</code>, or <code>spacer</code>, return | ||
<code>HTMLUnknownElement</code>.</p></li> | ||
<!-- These have to be explicitly listed because technically we define these elements in HTML, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This helps with https://www.w3.org/Bugs/Public/show_bug.cgi?id=27877, but probably doesn't completely take care of it, as basefont might still be confusing.
I pushed fixes addressing the issues I noted on @annevk's commit. One interesting issue it raised is defining element interface for obsolete elements better. I will open a new issue on that. |
Should "Core concepts" be named "Processing model"? Maybe not, since so much of the processing model is defined elsewhere... |
@@ -9574,26 +9574,28 @@ interface <dfn>HTMLUnknownElement</dfn> : <span>HTMLElement</span> { };</pre> | |||
<span>HTML namespace</span> is determined as follows:</p> | |||
|
|||
<ol> | |||
<li><p>If <var>name</var> is <code>blink</code>, <code>bgsound</code>, <code>isindex</code>, | |||
<li><p>If <var>name</var> is <code>bgsound</code>, <code>blink</code>, <code>isindex</code>, | |||
<code>multicol</code>, <code>nextid</code>, or <code>spacer</code>, return | |||
<code>HTMLUnknownElement</code>.</p></li> | |||
<!-- These have to be explicitly listed because technically we define these elements in HTML, | |||
albeit as obsolete. --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is obsolete with this commit, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good catch
Would you mind if I added ", then" to conditionals? |
Although with all the don't squash that might get a little labor intensive... |
You can add it, it's fine. Maybe don't add it to the sections touched in "don't squash" and I can do those myself when I rebase and rearrange commits. |
I think it's all good now. I have fixed up the commits to add "then" and removed "don't squash" from the titles. Admittedly I have relied in part on my earlier review of the algorithms. Since I assume you just moved them around. |
data-x="concept-custom-element-definition-name">name</span> <var>name</var>, then return that | ||
entry's <span data-x="concept-custom-element-definition-constructor">constructor</span>.</p></li> | ||
|
||
<li><p>Otherwise, return undefined.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more common to return null from a method. Why undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that. I suspect @domenic wants to mimic Map semantics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly, map-like get() methods need to return undefined.
There needs to be a normative statement saying that |
Do we want to allow any attribute on customized built-in elements? In particular those in the obsolete section? Note that |
+ <dt><var>window</var> . <code data-x="dom-window-customElements">customElements</code> . <code
+ data-x="dom-CustomElementsRegistry-define">define</code>(<var>name</var>,
+ <var>constructor</var>)</dt> These typically have a |
(Reached the end of the diff; no more comments.) |
Why?
Good catch, thanks.
Either would work, I imagine. -1 is more explicit IMO?
Hmm. We probably should? I have no real idea how to phrase this though, or which sections to edit. Suggestions?
Thanks, will add. |
-1 means it's still focusable if you click it. Also the code above uses |
The content model is normative, but nothing says the attributes list is. The rest of the spec addresses each attribute individually in prose I believe. So right now it's a statement of fact that's not backed up by anything normative. :-) |
Why can't |
Yeah, that was my question. I agree with you now about removeAttribute; thanks for that. |
Oh, I don't mind allowing |
How about... diff --git a/source b/source
index 0967e3a..a627fa4 100644
--- a/source
+++ b/source
@@ -28002,8 +28002,8 @@ attribute, set the <span>browsing context name</span> of the element's <span>nes
<p class="note">All attributes in <span>HTML documents</span> get lowercased automatically, so the
restriction on uppercase letters doesn't affect such documents.</p>
- <p class="note">The four exceptions are to exclude legacy attributes that have side-effects beyond
- just sending parameters to the <span>plugin</span>.</p>
+ <p class="note">The four exceptions are to exclude <span>obsolete attributes</span> that have
+ side-effects beyond just sending parameters to the <span>plugin</span>.</p>
<div w-nodev>
@@ -67011,9 +67011,13 @@ console.log(plasticButton2.getAttribute("is")); // will output "plastic-button"<
<p>An <span>autonomous custom element</span> does not have any special meaning: it
<span>represents</span> its children. A <span>customized built-in element</span> inherits the
- semantics of the element that it extends. Both types of <span>custom element</span> may have any
- non-namespaced attributes that are relevant to the element's functioning, as determined by the
- element's author.</p>
+ semantics of the element that it extends.</p>
+
+ <p>Any namespace-less attribute, that are relevant to the element's functioning, as determined by
+ the element's author, may be specified on both types of <span data-x="custom element">custom
+ elements</span>, except those that are defined as being <span data-x="obsolete
+ attributes">obsolete</span> for that element, so long as its name is <span>XML-compatible</span>
+ and contains no <span>uppercase ASCII letters</span>.</p>
<p>A <dfn data-export="">valid custom element name</dfn> is a sequence of characters
<var>name</var> that meets all of the following requirements:</p>
@@ -111655,7 +111659,8 @@ if (s = prompt('What is your name?')) {
<h3>Non-conforming features</h3>
- <p>Elements in the following list are entirely obsolete, and must not be used by authors:</p>
+ <p>Elements in the following list are entirely <dfn data-x="obsolete elements">obsolete</dfn>, and
+ must not be used by authors:</p>
<dl><!-- alphabetical by first element in the group, except CSS goes last -->
@@ -111736,8 +111741,8 @@ if (s = prompt('What is your name?')) {
<hr>
- <p>The following attributes are obsolete (though the elements are still part of the language), and
- must not be used by authors:</p>
+ <p>The following attributes are <dfn data-x="obsolete attributes">obsolete</dfn> (though the
+ elements are still part of the language), and must not be used by authors:</p>
<dl><!-- alphabetical by element then attribute of first item in group, except CSS goes last -->
Note: I copied the requirements from Additional thoughts:
|
Huh, I didn't notice that. I think it must have been intended to go on autonomous built-in elements; I have no idea how it made it to
That's a good point. Let's leave them invalid for now, and address this in a follow-up issue. |
@zcorpan please take a look, made a fixup commit for easier reviewing. |
LGTM |
This upstreams custom elements into the HTML Standard, instead of having them be in a separate spec that monkeypatches HTML extensively. This builds on previous work in whatwg/dom#204. See https://rawgit.com/w3c/webcomponents/15a203c8393aef0df7223ab1d43406aa11a7e71e/spec/custom/index.html for the source material, in particular the sections labeled "HTML+". Most changes while upstreaming were editorial in nature, with the following exceptions: - Changes were made to the "element interface" section to nail down underspecified edge cases, and fix https://www.w3.org/Bugs/Public/show_bug.cgi?id=27877. - Changes were made to the authoring conformance criteria for attributes on custom elements. A notable change included in this upstreaming is that the order of attributes created by the parser is now well-defined. See WICG/webcomponents#474 for discussion, as well as https://www.w3.org/Bugs/Public/show_bug.cgi?id=17871.
"custom tag" becomes "autonomous custom element", and "type extension" becomes "customized built-in element". Fixes WICG/webcomponents#434.
\o/ (Do we want to keep this branch alive as we did in DOM?) |
Yeah, we probably should, and I can also help maintain a similar wiki page. |
Protected. |
This upstreams custom elements into the HTML Standard, instead of having
them be in a separate spec that monkeypatches HTML extensively. This
builds on previous work in whatwg/dom#204.
See https://rawgit.com/w3c/webcomponents/15a203c8393aef0df7223ab1d43406aa11a7e71e/spec/custom/index.html
for the source material, in particular the sections labeled "HTML+". All
changes while upstreaming were editorial in nature.
Review appreciated, especially in the form of pushing fixups to the branch.