Ff149 allow more chars in attributes/element names#43350
Ff149 allow more chars in attributes/element names#43350hamishwillee wants to merge 1 commit intomdn:mainfrom
Conversation
|
|
||
| ```js-nolint | ||
| createAttribute(name) | ||
| createAttribute(localName) |
There was a problem hiding this comment.
FYI Note, I have matched spec here for the name (and in other places too). It is useful to do so because these parts of the names all have meanings that map to properties.
| - `InvalidCharacterError` {{domxref("DOMException")}} | ||
| - : Thrown if the [`qualifiedName`](#qualifiedname) value is not a valid [XML name](https://www.w3.org/TR/xml/#dt-name); for example, it starts with a number, hyphen, or period, or contains characters other than alphanumeric characters, underscores, hyphens, or periods. | ||
| - : Thrown if the [`qualifiedname`](#qualifiedname) value is not a valid attribute name. | ||
| A string is a valid attribute name if its length is at least 1 and it does not contain ASCII whitespace, `NULL`, `/` , `=` or `>` (U+0000, U+002F, U+003D or U+003E, respectively). |
There was a problem hiding this comment.
Name validation covered in https://dom.spec.whatwg.org/#namespaces
|
|
||
| If you are working with HTML documents and you don't need to specify the requested attribute as being part of a specific namespace, use the {{domxref("Element.setAttribute()", "setAttribute()")}} method instead. | ||
|
|
||
| Note that `setAttributeNS()` is the only method for namespaced attributes which expects the fully qualified name, i.e., `"namespace:local-name"`. |
There was a problem hiding this comment.
FWIW I don't believe this to be true any more, if it ever was. The algorithm is the same for all of these NS methods: https://dom.spec.whatwg.org/#validate-and-extract
Perhaps needs testing to see that it really was required previously.
| - `is` {{Optional_Inline}} | ||
| - : A string defining the tag name for a custom element (that was previously defined using {{domxref("CustomElementRegistry/define", "customElements.define()")}}). | ||
| The new element will be given an `is` attribute whose value is the custom element's tag name. | ||
| See [Web component example](#web_component_example) for more details. | ||
| - `customElementRegistry` {{Optional_Inline}} | ||
| - : A {{domxref("CustomElementRegistry")}} that sets the [Scoped custom element registry](/en-US/docs/Web/API/Web_components/Using_custom_elements#scoped_custom_element_registries) of a custom element. |
There was a problem hiding this comment.
FYI @chrisdavidmills When you get to this one, it looks like this is how a scoped custom element registry can be specifically assigned to an element. It isn't clear to me if this is another option that should be covered in the linked doc, or if this is something used "under the hood". But I plan on leaving that with you, since it is out of scope for me and I seem to recall you doing that work recently.
What I have done though is create a BCD entry for these two options mdn/browser-compat-data#29216
There was a problem hiding this comment.
@hamishwillee I didn't work on this recently, sorry.
The last time I touched any custom element stuff was a long time ago.
febf052 to
f600acb
Compare
f600acb to
2643011
Compare
Includes: - Document.createAttribute()/createAttributeNS() - Document.setAttribute()/setAttributeNS() - Document.createElement()/createElementNS() - Element.toggleAttribute() - DOMImplementation.createDocument() - CustomElementRegistry.whenDefined()/define()
2643011 to
2745030
Compare
| - `InvalidCharacterError` {{domxref("DOMException")}} | ||
| - : Thrown if the [`name`](#name) value is not a valid [XML name](https://www.w3.org/TR/xml/#dt-name); for example, it starts with a number, hyphen, or period, or contains characters other than alphanumeric characters, underscores, hyphens, or periods. | ||
| - : Thrown if the [`localName`](#localName) value is not a valid attribute name. | ||
| It must have at least 1 character, and may not contain ASCII whitespace, `NULL`, `/` , `=` or `>` (U+0000, U+002F, U+003D or U+003E, respectively). |
There was a problem hiding this comment.
Note, all the docs follow this pattern of including the precise set of allowed chars in the exception. I think that better than specifying in the localname, in particular now that the set of chars that is allowed matches the same element/attribute in HTML.
FF149 adds support for additional characters to be used in attribute and element names in https://bugzilla.mozilla.org/show_bug.cgi?id=1773312. Previoulsy the DOM allowed you to only create them with XML characters, now the rules are less restrictive.
This adds docs updates.
Related docs work can be tracked in #43218