From 776ab2b60aab3571e474eee1eb7cd980b7401155 Mon Sep 17 00:00:00 2001 From: sideshowbarker Date: Sat, 9 Nov 2024 11:35:26 +0900 Subject: [PATCH] Disambiguate attribute declarations from content attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The change updates the spec to use the term “attribute declaration” in all cases where what the spec is referring to is actually the syntax for declaring attributes in markup. Otherwise, without this change, the spec uses the same term “attribute” to refer both to attribute declarations in markup and to actual content attributes as they exist in the DOM. And we have evidence of authors being confused due to that ambiguous use of the same term to refer to different things — and evidence suggesting the ambiguous usage promotes the wrong mental model of HTML for authors. --- source | 96 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 50 insertions(+), 46 deletions(-) diff --git a/source b/source index 0d9624488bd..0cd9a04487a 100644 --- a/source +++ b/source @@ -677,11 +677,11 @@ interface Example {
<a href="demo.html">simple</a>
-

Attributes are placed inside the start tag, and consist - of a name and a value, separated by an "=" character. - The attribute value can remain unquoted if it doesn't contain ASCII - whitespace or any of " ' Attribute declarations are placed inside + the start tag, and consist of a name and a value, separated by an "=" + character. The attribute value can remain unquoted if it doesn't contain + ASCII whitespace or any of " ' ` = < or >. Otherwise, it has to be quoted using either single or double quotes. The value, along with the "=" character, can be omitted altogether if the value @@ -1174,8 +1174,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

For example, this is why the U+0060 GRAVE ACCENT character (`) is not allowed in unquoted - attributes. In certain legacy user agents, it is sometimes treated as a - quote character.

+ attribute declarations. In certain legacy user agents, it is sometimes + treated as a quote character.

@@ -1246,18 +1246,18 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
-

For example, "attributes" in end tags are ignored currently, but they are invalid, in case a - future change to the language makes use of that syntax feature without conflicting with - already-deployed (and valid!) content.

+

For example, attribute declarations in end tags are ignored currently, but they are invalid, + in case a future change to the language makes use of that syntax feature without conflicting + with already-deployed (and valid!) content.

-

Some authors find it helpful to be in the practice of always quoting all attributes and always - including all optional tags, preferring the consistency derived from such custom over the minor - benefits of terseness afforded by making use of the flexibility of the HTML syntax. To aid such - authors, conformance checkers can provide modes of operation wherein such conventions are +

Some authors find it helpful to be in the practice of always quoting all attribute values and + always including all optional tags, preferring the consistency derived from such custom over the + minor benefits of terseness afforded by making use of the flexibility of the HTML syntax. To aid + such authors, conformance checkers can provide modes of operation wherein such conventions are enforced.

@@ -45441,7 +45441,8 @@ interface HTMLTableCellElement : HTMLElement {

There is no particular significance to the way some of the attributes have their values quoted and others don't. The HTML syntax allows a variety of equally valid ways to specify - attributes, as discussed in the syntax section.

+ attributes, as discussed in the syntax + section.

For example, if the customer entered "Denise Lawrence" as their name, "555-321-8642" as their telephone number, did not specify an email address, asked for a medium-sized pizza, selected the @@ -122895,17 +122896,17 @@ dictionary StorageEventInit : EventInit {

  • The next few characters of a start tag must be the element's tag name.
  • -
  • If there are to be any attributes in the next step, there must first be one or more - ASCII whitespace.
  • +
  • If there are to be any attribute declarations in the next step, there must first be one or + more ASCII whitespace.
  • -
  • Then, the start tag may have a number of attributes, the syntax for which is described below. Attributes must be - separated from each other by one or more ASCII whitespace.
  • +
  • Then, the start tag may have a number of attribute declarations, the syntax for which is described below. Attribute + declarations must be separated from each other by one or more ASCII whitespace.
  • -
  • After the attributes, or after the tag name if there - are no attributes, there may be one or more ASCII whitespace. (Some attributes are - required to be followed by a space. See the attributes - section below.)
  • +
  • After the attribute declarations, or after the tag name + if there are no attributes, there may be one or more ASCII whitespace. (Some + attribute declarations are required to be followed by a space. See the attribute declarations section below.)
  • Then, if the element is one of the void elements, or if the element is a foreign element, then there may be a single U+002F SOLIDUS @@ -122938,10 +122939,10 @@ dictionary StorageEventInit : EventInit { -
    Attributes
    +
    Attribute declarations
    -

    Attributes for an element are expressed inside the - element's start tag.

    +

    Attribute declarations for an element are + expressed inside the element's start tag.

    Attributes have a name and a value. Attribute names must consist of one or more characters other than controls, @@ -122955,7 +122956,7 @@ dictionary StorageEventInit : EventInit { except with the additional restriction that the text cannot contain an ambiguous ampersand.

    -

    Attributes can be specified in four different ways:

    +

    Attributes can be declared in four different ways:

    Empty attribute syntax
    @@ -122973,8 +122974,8 @@ dictionary StorageEventInit : EventInit { -

    If an attribute using the empty attribute syntax is to be followed by another attribute, then - there must be ASCII whitespace separating the two.

    +

    If an attribute declaration using the empty attribute syntax is to be followed by another + attribute declaration, then there must be ASCII whitespace separating the two.

    Unquoted attribute value syntax
    @@ -123026,9 +123027,9 @@ dictionary StorageEventInit : EventInit { -

    If an attribute using the unquoted attribute syntax is to be followed by another attribute or - by the optional U+002F SOLIDUS character (/) allowed in step 6 of the start tag syntax above, then there must be ASCII +

    If an attribute declaration using the unquoted attribute syntax is to be followed by another + attribute declaration or by the optional U+002F SOLIDUS character (/) allowed in step 6 of the + start tag syntax above, then there must be ASCII whitespace separating the two.

    @@ -123052,8 +123053,9 @@ dictionary StorageEventInit : EventInit { -

    If an attribute using the single-quoted attribute syntax is to be followed by another - attribute, then there must be ASCII whitespace separating the two.

    +

    If an attribute declaration using the single-quoted attribute syntax is to be followed by + another attribute declaration, then there must be ASCII whitespace separating the + two.

    Double-quoted attribute value syntax
    @@ -123076,13 +123078,14 @@ dictionary StorageEventInit : EventInit { -

    If an attribute using the double-quoted attribute syntax is to be followed by another - attribute, then there must be ASCII whitespace separating the two.

    +

    If an attribute declaration using the double-quoted attribute syntax is to be followed by + another attribute declaration, then there must be ASCII whitespace separating the + two.

    -

    There must never be two or more attributes on the same start tag whose names are an ASCII - case-insensitive match for each other.

    +

    There must never be two or more attribute declarations in the same start tag whose names are an + ASCII case-insensitive match for each other.


    @@ -123858,14 +123861,15 @@ dictionary StorageEventInit : EventInit { duplicate-attribute

    This error occurs if the parser encounters an attribute in a tag that already has an attribute with the - same name. The parser ignores all such duplicate occurrences of the attribute. + data-x="syntax-attribute-declarations">attribute declaration in a tag that already has + an attribute with the same name. The parser ignores all such duplicate occurrences of the + attribute. end-tag-with-attributes

    This error occurs if the parser encounters an end - tag with attributes. Attributes in end tags are - ignored and do not make their way into the DOM.

    + tag with attribute declarations. + Attribute declarations in end tags are ignored and do not result in attributes in the DOM.

    end-tag-with-trailing-solidus @@ -123977,7 +123981,7 @@ dictionary StorageEventInit : EventInit { missing-attribute-value

    This error occurs if the parser encounters a U+003E (>) code point where an - attribute value is expected (e.g., attribute value is expected (e.g., <div id=>). The parser treats the attribute as having an empty value.

    @@ -124064,7 +124068,7 @@ dictionary StorageEventInit : EventInit { missing-whitespace-between-attributes

    This error occurs if the parser encounters attributes that are not separated by ASCII + data-x="syntax-attribute-declarations">attributes that are not separated by ASCII whitespace (e.g., <div id="foo"class="bar">). In this case the parser behaves as if ASCII whitespace is present.

    @@ -124251,7 +124255,7 @@ dictionary StorageEventInit : EventInit { unexpected-solidus-in-tag

    This error occurs if the parser encounters a U+002F (/) code point that is - not a part of a quoted attribute value and not + not a part of a quoted attribute value and not immediately followed by a U+003E (>) code point in a tag (e.g., <div / id="foo">). In this case the parser behaves as if it encountered ASCII whitespace.