From e75f1079ae348d09f030dda63e0d5ace2cf50071 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 6 Dec 2019 14:37:27 +0100 Subject: [PATCH] Editorial: embrace that attributes are objects Closes #801. --- dom.bs | 167 ++++++++++++++++++++++----------------------------------- 1 file changed, 65 insertions(+), 102 deletions(-) diff --git a/dom.bs b/dom.bs index 00212ae6b..a3b2559b2 100644 --- a/dom.bs +++ b/dom.bs @@ -3592,11 +3592,6 @@ run these steps: target with null, null, null, addedNodes, removedNodes, previousSibling, and nextSibling. -

To queue an attribute mutation record for target with -name, namespace, and oldValue, queue a mutation record of -"attributes" for target with name, namespace, -oldValue, « », « », null, and null. -

Interface {{MutationRecord}}

@@ -6100,106 +6095,83 @@ its attribute list is empty. has an attribute A if its attribute list contains A. -This and other specifications may define +

This and other specifications may define attribute change steps for elements. The algorithm is passed element, localName, oldValue, value, and namespace. -To change an -attribute attribute -from an element element -to value, run these steps: +

To handle attribute changes for an attribute attribute with +element, oldValue, and newValue, run these steps:

    -
  1. Queue an attribute mutation record for element with attribute's - local name, attribute's namespace, and - attribute's value. +

  2. Queue a mutation record of "attributes" for element with + attribute's local name, attribute's + namespace, oldValue, « », « », null, and null. -

  3. If element is custom, then +
  4. If element is custom, then enqueue a custom element callback reaction with element, callback name "attributeChangedCallback", and an argument list containing attribute's - local name, attribute's value, value, and - attribute's namespace. + local name, oldValue, newValue, and attribute's + namespace.

  5. Run the attribute change steps with element, attribute's - local name, attribute's value, value, and - attribute's namespace. - -

  6. Set attribute's - value to value. + local name, oldValue, newValue, and attribute's + namespace.
-To append an -attribute attribute to -an element element, -run these steps: +

To change an +attribute attribute to value, run these steps:

    -
  1. Queue an attribute mutation record for element with attribute's - local name, attribute's namespace, and null. +

  2. Assert: attribute's element is non-null. -

  3. If element is custom, then - enqueue a custom element callback reaction with element, callback name - "attributeChangedCallback", and an argument list containing attribute's - local name, null, attribute's value, and - attribute's namespace. +
  4. Handle attribute changes for attribute with attribute's + element, attribute's value, and value. -

  5. Run the attribute change steps with element, attribute's - local name, null, attribute's value, and - attribute's namespace. +

  6. Set attribute's value to value. +

+ +

To append an +attribute attribute to an element element, run these +steps: -

  • Append attribute to element's +
      +
    1. Handle attribute changes for attribute with element, + attribute's value, and value. + +

    2. Append attribute to element's attribute list. -

    3. Set attribute's - element to element. +
    4. Set attribute's element to element.

    -To remove an -attribute attribute -from an element element, -run these steps: +

    To remove an +attribute attribute, run these steps:

      -
    1. Queue an attribute mutation record for element with attribute's - local name, attribute's namespace, and - attribute's value. +

    2. Let element be attribute's element. -

    3. If element is custom, then - enqueue a custom element callback reaction with element, callback name - "attributeChangedCallback", and an argument list containing attribute's - local name, attribute's value, null, and - attribute's namespace. +
    4. Assert: element is non-null. -

    5. Run the attribute change steps with element, attribute's - local name, attribute's value, null, and - attribute's namespace. +

    6. Handle attribute changes for attribute with element, + attribute's value, and null.

    7. Remove attribute from element's attribute list. -
    8. Set attribute's - element to null. +
    9. Set attribute's element to null.

    -To replace an -attribute oldAttr by an attribute newAttr -in an element element, run these steps: +

    To replace an +attribute oldAttr with an attribute newAttr, run these steps:

      -
    1. Queue an attribute mutation record for element with oldAttr's - local name, oldAttr's namespace, and - oldAttr's value. +

    2. Let element be oldAttr's element. -

    3. If element is custom, then - enqueue a custom element callback reaction with element, callback name - "attributeChangedCallback", and an argument list containing oldAttr's - local name, oldAttr's value, newAttr's - value, and oldAttr's namespace. +
    4. Assert: element is non-null. -

    5. Run the attribute change steps with element, oldAttr's - local name, oldAttr's value, newAttr's - value, and oldAttr's namespace. +

    6. Handle attribute changes for oldAttr with element, + oldAttr's value, and newAttr's value.

    7. Replace oldAttr by newAttr in element's attribute list. @@ -6211,7 +6183,7 @@ in an element element, run these steps:


      -To get an attribute by name given a +

      To get an attribute by name given a qualifiedName and element element, run these steps:

        @@ -6223,7 +6195,7 @@ To get an attribute by nam whose qualified name is qualifiedName, and null otherwise.
      -To +

      To get an attribute by namespace and local name given a namespace, localName, and element element, run these steps: @@ -6253,7 +6225,7 @@ run these steps:

    8. Return attr's value.

    -To set an attribute given an +

    To set an attribute given an attr and element, run these steps:

      @@ -6267,18 +6239,17 @@ To set an attribute given an
    1. If oldAttr is attr, return attr. -

    2. If oldAttr is non-null, replace it - by attr in element. +

    3. If oldAttr is non-null, then replace + oldAttr with attr.

    4. Otherwise, append attr to element.

    5. Return oldAttr.

    -To set an attribute value for -an element element -using a localName and value, and an optional prefix, and -namespace, run these steps: +

    To set an attribute value for an +element element, using a localName and value, and an +optional prefix, and namespace, run these steps:

    1. If prefix is not given, set it to null. @@ -6296,46 +6267,40 @@ using a localName and value, and an optional prefixappend this attribute to element, and then return. -
    2. Change - attribute from element to - value. +
    3. Change attribute to value.

    -To -remove an attribute by name +

    To remove an attribute by name given a qualifiedName and element element, run these steps:

    1. Let attr be the result of - getting an attribute given - qualifiedName and element. - -

    2. If attr is non-null, remove it from + getting an attribute given qualifiedName and element. +

    3. If attr is non-null, then remove attr. +

    4. Return attr.

    -To +

    To remove an attribute by namespace and local name -given a namespace, localName, and -element element, run these steps: +given a namespace, localName, and element element, +run these steps:

      -
    1. Let attr be the result of +
    2. Let attr be the result of getting an attribute given namespace, localName, and element. -

    3. If attr is non-null, - remove it from - element. +
    4. If attr is non-null, then remove attr. -

    5. Return attr. +
    6. Return attr.


    -An element can have an associated +

    An element can have an associated unique identifier (ID)

    Historically elements could have multiple identifiers e.g., by using @@ -6568,8 +6533,7 @@ method, when invoked, must run these steps: node document, then append this attribute to context object, and then return. -

  • Change attribute from context object to - value. +

  • Change attribute to value.

    The @@ -6685,7 +6649,7 @@ when invoked, must run these steps: contain attr, then throw a "{{NotFoundError!!exception}}" {{DOMException}}. -

  • Remove attr from context object. +

  • Remove attr.

  • Return attr. @@ -7097,11 +7061,10 @@ null. string value, run these steps:

      -
    1. If attribute's element is null, then set attribute's +
    2. If attribute's element is null, then set attribute's value to value. -

    3. Otherwise, change attribute from - attribute's element to value. +
    4. Otherwise, change attribute to value.

    The {{Attr/value}} attribute's setter must set an existing attribute value with