Skip to content
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

Definition of valid shadow elements is ambiguous #745

Closed
MatsPalmgren opened this issue Mar 31, 2019 · 5 comments
Closed

Definition of valid shadow elements is ambiguous #745

MatsPalmgren opened this issue Mar 31, 2019 · 5 comments
Labels
clarification Standard could be clearer good first issue Ideal for someone new to a WHATWG standard or software project topic: shadow Relates to shadow trees (as defined in DOM)

Comments

@MatsPalmgren
Copy link

https://dom.spec.whatwg.org/#dom-element-attachshadow
Item 2 in the list says:

If context object’s local name is not a valid custom element name, "article", "aside", "blockquote", "body", "div", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "main" "nav", "p", "section", or "span", then throw a "NotSupportedError" DOMException.

The above sentence is ambiguous. The enumeration can be read both as a list of valid names, or as a list of invalid names. The sentence is also unnecessarily complex. I would suggest:

If context object’s local name is not a valid custom element name, then throw a "NotSupportedError" DOMException. The only valid names are: "article", "aside", "blockquote", "body", "div", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "main" "nav", "p", "section", and "span".

@rniwa
Copy link
Collaborator

rniwa commented Mar 31, 2019

That doesn't read well. It sounds like we should always throw NotSupportedError whenever the context object's local name is not a valid custom name. We need something like this:

If context object’s local name is not one of a valid custom element name, "article", "aside", "blockquote", "body", "div", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "main" "nav", "p", "section", or "span", then throw a "NotSupportedError" DOMException.

or

If context object’s local name is not a valid custom element name and not one of "article", "aside", "blockquote", "body", "div", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "main" "nav", "p", "section", or "span", then throw a "NotSupportedError" DOMException.

@annevk annevk transferred this issue from whatwg/html Apr 1, 2019
@annevk annevk added the topic: shadow Relates to shadow trees (as defined in DOM) label Apr 1, 2019
@annevk
Copy link
Member

annevk commented Apr 1, 2019

I'd also support a list:

If context object’s local name is not one of

  • a valid custom element name
  • "article"
  • "aside"
  • ...

then throw ...

(Note that the rewording in OP is incorrect.)

@annevk annevk added good first issue Ideal for someone new to a WHATWG standard or software project clarification Standard could be clearer labels Apr 1, 2019
@MatsPalmgren
Copy link
Author

Oh, so "a valid custom element name" was intended to be one of the alternatives in that enumeration? Then it's even worse than I thought, because that meaning didn't even occur to me. I might have understood it like that if there had been a colon after the "not", maybe. @rniwa's first suggestion have that same problem IMO. The second suggestion is better but still rather convoluted. Perhaps making an explicit listing of alternatives is better:

Context object’s local name must be one of the following:

  • a valid custom element name
  • "article", "aside", "blockquote", "body", "div", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "main" "nav", "p", "section", or "span"

If it's not, then throw a "NotSupportedError" DOMException.

@Yash-Handa
Copy link
Member

Hey @annevk, I would love to help in editing the dom.bs.

BTW, for clarification the following should be done:

this’s local name must be one of the following:

  • a valid custom element name.
  • "article", "aside", "blockquote", "body", "div", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "main", "nav", "p", "section", or "span".

If it's not, then throw a "NotSupportedError" DOMException.

A suggestion though (a less verbose option):

If this’s local name is not an "article", "aside", "blockquote", "body", "div", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "main", "nav", "p", "section", "span", or any valid custom element name, then throw a "NotSupportedError" DOMException.

Do let me know which one should be used : )

@annevk
Copy link
Member

annevk commented Jun 5, 2020

Thanks @Yash-Handa!

I'd suggest:

If this's local name is not one of the following:

  • ...
  • ...

then throw a ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer good first issue Ideal for someone new to a WHATWG standard or software project topic: shadow Relates to shadow trees (as defined in DOM)
Development

No branches or pull requests

4 participants