From d1c9cb632e56c2764e491e0284bd74181fc348c7 Mon Sep 17 00:00:00 2001 From: arottier Date: Thu, 26 Mar 2020 15:37:38 -0700 Subject: [PATCH 1/5] Add mutation observer init options elementHasAttributeNameFilter and elementLocalNameFilter --- dom.bs | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/dom.bs b/dom.bs index afe7880a0..80ad9b844 100644 --- a/dom.bs +++ b/dom.bs @@ -3320,6 +3320,8 @@ dictionary MutationObserverInit { boolean attributeOldValue; boolean characterDataOldValue; sequence<DOMString> attributeFilter; + sequence<DOMString> elementFilterByAttribute; + sequence<DOMString> elementLocalNameFilter; }; @@ -3398,6 +3400,19 @@ dictionary MutationObserverInit { attribute mutations need to be observed and {{MutationObserverInit/attributes}} is true or omitted. + +
{{MutationObserverInit/elementFilterByAttribute}} +
Set to a list of attribute + local names (without namespace) to observe changes + to the presence of an elements attributes. + +
{{MutationObserverInit/elementLocalNameFilter}} +
Set to a list of element + local names (without namespace) to observe + changes to the presence of specific element local names + if not all element local names need to be + observed and {{MutationObserverInit/attributes}} is true + or omitted.
observer . {{disconnect()}} @@ -3437,6 +3452,14 @@ method, when invoked, must run these steps: options's {{MutationObserverInit/characterData}} is omitted, then set options's {{MutationObserverInit/characterData}} to true. +
  • If options's {{MutationObserverInit/elementFilterByAttribute}} is present and + options's {{MutationObserverInit/childList}} is omitted, then set + options's {{MutationObserverInit/childList}} to true. + +

  • If options's {{MutationObserverInit/elementLocalNameFilter}} is present and + options's {{MutationObserverInit/childList}} is omitted, then set + options's {{MutationObserverInit/childList}} to true. +

  • If none of options's {{MutationObserverInit/childList}}, {{MutationObserverInit/attributes}}, and {{MutationObserverInit/characterData}} is true, then throw a TypeError. @@ -3453,6 +3476,14 @@ method, when invoked, must run these steps: options's {{MutationObserverInit/characterData}} is false, then throw a TypeError. +

  • If options's {{MutationObserverInit/elementFilterByAttribute}} is present and + options's {{MutationObserverInit/childList}} is false, then throw a + TypeError. + +

  • If options's {{MutationObserverInit/elementLocalNameFilter}} is present and + options's {{MutationObserverInit/childList}} is false, then throw a + TypeError. +

  • For each registered of target's registered observer list, if registered's @@ -3594,6 +3625,60 @@ run these steps:

    1. Assert: either addedNodes or removedNodes is not empty. +

    2. If either options's' {{MutationObserverInit/elementLocalNameFilter}} or + {{MutationObserverInit/elementFilterByAttribute}} is present, then: + +

        +
      1. Let nodeAttributesList be the set of local names of node's attributes. + +

      2. Let filteredAddedNodes be an empty list. + +

      3. Let filterRemovedNodes be an empty list. + +

      4. +

        For each node in addedNodes. + +

      5. +

        If none of the following are true + +

          +
        • if options's + {{MutationObserverInit/elementLocalNameFilter}} is present, and + "node.localName" is in {{MutationObserverInit/elementLocalNameFilter}} + +
        • options's {{MutationObserverInit/elementFilterByAttribute}} is + present, and options's {{MutationObserverInit/elementFilterByAttribute}} + contains any of the attribute name in nodeAttributesList +
        +

        then: +

          +
        1. Enqueue record node in filteredAddedNodes +

        + +
      6. For each node in removedNodes. +

      7. +

        If none of the following are true +

          +
        • if options's + {{MutationObserverInit/elementLocalNameFilter}} is present, and + "node.localName" is in {{MutationObserverInit/elementLocalNameFilter}} +
        • if options's + {{MutationObserverInit/elementFilterByAttribute}} is present,and options's + {{MutationObserverInit/elementFilterByAttribute}} contains any of the attribute names + in nodeAttributesList +
        +

        then: +

          +
        1. Enqueue record node in filterRemovedNodes +

        + +
      8. Assert: either filteredAddedNodes or filteredRemovedNodes is not empty. + +

      9. Set addedNodes to filteredAddedNodes + +

      10. Set removedNodes to filteredRemovedNodes +

      +
    3. Queue a mutation record of "childList" for target with null, null, null, addedNodes, removedNodes, previousSibling, and nextSibling. From 8dff3a0d3ef8ace107bc108f9af994c19203817c Mon Sep 17 00:00:00 2001 From: arottier Date: Mon, 21 Sep 2020 14:58:24 -0400 Subject: [PATCH 2/5] minor fixes --- dom.bs | 95 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 44 deletions(-) diff --git a/dom.bs b/dom.bs index 80ad9b844..014945380 100644 --- a/dom.bs +++ b/dom.bs @@ -3320,8 +3320,8 @@ dictionary MutationObserverInit { boolean attributeOldValue; boolean characterDataOldValue; sequence<DOMString> attributeFilter; - sequence<DOMString> elementFilterByAttribute; - sequence<DOMString> elementLocalNameFilter; + sequence<DOMString> elementByAttributeFilter; + sequence<DOMString> elementFilter; }; @@ -3401,12 +3401,12 @@ dictionary MutationObserverInit { observed and {{MutationObserverInit/attributes}} is true or omitted. -

      {{MutationObserverInit/elementFilterByAttribute}} +
      {{MutationObserverInit/elementByAttributeFilter}}
      Set to a list of attribute local names (without namespace) to observe changes to the presence of an elements attributes. -
      {{MutationObserverInit/elementLocalNameFilter}} +
      {{MutationObserverInit/elementFilter}}
      Set to a list of element local names (without namespace) to observe changes to the presence of specific element local names @@ -3417,7 +3417,7 @@ dictionary MutationObserverInit {
      observer . {{disconnect()}}
      Stops observer from observing any mutations. Until the {{observe()}} method is used - again, observer's callback will not be invoked. + again, observer's callback will not be invoked.
      observer . {{takeRecords()}}
      Empties the record queue and @@ -3452,11 +3452,11 @@ method, when invoked, must run these steps: options's {{MutationObserverInit/characterData}} is omitted, then set options's {{MutationObserverInit/characterData}} to true. -
    4. If options's {{MutationObserverInit/elementFilterByAttribute}} is present and +

    5. If options's {{MutationObserverInit/elementByAttributeFilter}} is present and options's {{MutationObserverInit/childList}} is omitted, then set options's {{MutationObserverInit/childList}} to true. -

    6. If options's {{MutationObserverInit/elementLocalNameFilter}} is present and +

    7. If options's {{MutationObserverInit/elementFilter}} is present and options's {{MutationObserverInit/childList}} is omitted, then set options's {{MutationObserverInit/childList}} to true. @@ -3476,11 +3476,11 @@ method, when invoked, must run these steps: options's {{MutationObserverInit/characterData}} is false, then throw a TypeError. -

    8. If options's {{MutationObserverInit/elementFilterByAttribute}} is present and +

    9. If options's {{MutationObserverInit/elementByAttributeFilter}} is present and options's {{MutationObserverInit/childList}} is false, then throw a TypeError. -

    10. If options's {{MutationObserverInit/elementLocalNameFilter}} is present and +

    11. If options's {{MutationObserverInit/elementFilter}} is present and options's {{MutationObserverInit/childList}} is false, then throw a TypeError. @@ -3625,48 +3625,53 @@ run these steps:

      1. Assert: either addedNodes or removedNodes is not empty. -

      2. If either options's' {{MutationObserverInit/elementLocalNameFilter}} or - {{MutationObserverInit/elementFilterByAttribute}} is present, then: +

      3. If either options's' {{MutationObserverInit/elementFilter}} or + {{MutationObserverInit/elementByAttributeFilter}} is present, then:

          -
        1. Let nodeAttributesList be the set of local names of node's attributes. -

        2. Let filteredAddedNodes be an empty list.

        3. Let filterRemovedNodes be an empty list.

        4. -

          For each node in addedNodes. - -

        5. -

          If none of the following are true - -

            -
          • if options's - {{MutationObserverInit/elementLocalNameFilter}} is present, and - "node.localName" is in {{MutationObserverInit/elementLocalNameFilter}} - -
          • options's {{MutationObserverInit/elementFilterByAttribute}} is - present, and options's {{MutationObserverInit/elementFilterByAttribute}} - contains any of the attribute name in nodeAttributesList -
          -

          then: +

          For each node in addedNodes:

            -
          1. Enqueue record node in filteredAddedNodes -

          +
        6. +

          Let nodeAttributesList be the set of local names of node's attributes. +

        7. +

          If none of the following are true +

            +
          • if options's + {{MutationObserverInit/elementFilter}} is present, and the node's + localName is in {{MutationObserverInit/elementFilter}} + +
          • options's {{MutationObserverInit/elementByAttributeFilter}} is + present, and options's {{MutationObserverInit/elementByAttributeFilter}} + contains any of the attribute name in nodeAttributesList +
          +
        +

        then: +

          +
        1. Enqueue record node in filteredAddedNodes +

        -
      4. For each node in removedNodes. -

      5. -

        If none of the following are true -

          -
        • if options's - {{MutationObserverInit/elementLocalNameFilter}} is present, and - "node.localName" is in {{MutationObserverInit/elementLocalNameFilter}} -
        • if options's - {{MutationObserverInit/elementFilterByAttribute}} is present,and options's - {{MutationObserverInit/elementFilterByAttribute}} contains any of the attribute names - in nodeAttributesList -
        +
      6. +

        For each node in removedNodes: +

          +
        1. +

          Let nodeAttributesList be the set of local names of node's attributes. +

        2. +

          If none of the following are true +

            +
          • if options's + {{MutationObserverInit/elementFilter}} is present, and the node's + localName is in {{MutationObserverInit/elementFilter}} +
          • if options's + {{MutationObserverInit/elementByAttributeFilter}} is present,and options's + {{MutationObserverInit/elementByAttributeFilter}} contains any of the attribute names + in nodeAttributesList +
          +

        then:

        1. Enqueue record node in filterRemovedNodes @@ -3674,9 +3679,11 @@ run these steps:

        2. Assert: either filteredAddedNodes or filteredRemovedNodes is not empty. -

        3. Set addedNodes to filteredAddedNodes +

        4. +

          Set addedNodes to filteredAddedNodes -

        5. Set removedNodes to filteredRemovedNodes +

        6. +

          Set removedNodes to filteredRemovedNodes

      7. Queue a mutation record of "childList" for target with From e0b4bcb4101cf2c314f88a64faac9ebb062eafc6 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Thu, 24 Sep 2020 13:28:34 +0200 Subject: [PATCH 3/5] fix formatting --- dom.bs | 100 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/dom.bs b/dom.bs index 014945380..76b9b0cfa 100644 --- a/dom.bs +++ b/dom.bs @@ -3417,7 +3417,7 @@ dictionary MutationObserverInit {

        observer . {{disconnect()}}
        Stops observer from observing any mutations. Until the {{observe()}} method is used - again, observer's callback will not be invoked. + again, observer's callback will not be invoked.
        observer . {{takeRecords()}}
        Empties the record queue and @@ -3625,66 +3625,66 @@ run these steps:
        1. Assert: either addedNodes or removedNodes is not empty. -

        2. If either options's' {{MutationObserverInit/elementFilter}} or - {{MutationObserverInit/elementByAttributeFilter}} is present, then: +

        3. +

          If either options's' {{MutationObserverInit/elementFilter}} or + {{MutationObserverInit/elementByAttributeFilter}} is present, then: -

            -
          1. Let filteredAddedNodes be an empty list. +

              +
            1. Let filteredAddedNodes be an empty list. -

            2. Let filterRemovedNodes be an empty list. +

            3. Let filterRemovedNodes be an empty list. -

            4. +
            5. For each node in addedNodes: +

                -
              1. -

                Let nodeAttributesList be the set of local names of node's attributes. -

              2. -

                If none of the following are true -

                  -
                • if options's - {{MutationObserverInit/elementFilter}} is present, and the node's - localName is in {{MutationObserverInit/elementFilter}} - -
                • options's {{MutationObserverInit/elementByAttributeFilter}} is - present, and options's {{MutationObserverInit/elementByAttributeFilter}} - contains any of the attribute name in nodeAttributesList -
                -
              -

              then: -

                -
              1. Enqueue record node in filteredAddedNodes -

              +
            6. Let nodeAttributesList be the set of local names of node's + attributes. -

            7. +
            8. +

              If none of the following are true + +

                +
              • if options's {{MutationObserverInit/elementFilter}} is present, and the + node's localName is in {{MutationObserverInit/elementFilter}} + +
              • options's {{MutationObserverInit/elementByAttributeFilter}} is present, and + options's {{MutationObserverInit/elementByAttributeFilter}} contains any of the + attribute name in nodeAttributesList +
              + +

              then enqueue record node in filteredAddedNodes. +

            + +
          2. For each node in removedNodes: +

              -
            1. -

              Let nodeAttributesList be the set of local names of node's attributes. -

            2. -

              If none of the following are true -

                -
              • if options's - {{MutationObserverInit/elementFilter}} is present, and the node's - localName is in {{MutationObserverInit/elementFilter}} -
              • if options's - {{MutationObserverInit/elementByAttributeFilter}} is present,and options's - {{MutationObserverInit/elementByAttributeFilter}} contains any of the attribute names - in nodeAttributesList -
              -
            -

            then: -

              -
            1. Enqueue record node in filterRemovedNodes -

            +
          3. Let nodeAttributesList be the set of local names of node's + attributes. -

          4. Assert: either filteredAddedNodes or filteredRemovedNodes is not empty. +

          5. +

            If none of the following are true -

          6. -

            Set addedNodes to filteredAddedNodes +

              +
            • if options's {{MutationObserverInit/elementFilter}} is present, and the + node's localName is in {{MutationObserverInit/elementFilter}} -
            • -

              Set removedNodes to filteredRemovedNodes -

          +
        4. if options's {{MutationObserverInit/elementByAttributeFilter}} is present, and + options's {{MutationObserverInit/elementByAttributeFilter}} contains any of the + attribute names in nodeAttributesList + + +

          then enqueue record node in filterRemovedNodes. +

        + +
      8. Assert: either filteredAddedNodes or filteredRemovedNodes + is not empty. + +

      9. Set addedNodes to filteredAddedNodes + +

      10. Set removedNodes to filteredRemovedNodes +

    12. Queue a mutation record of "childList" for target with null, null, null, addedNodes, removedNodes, previousSibling, From cb4b0d9c799f6832599cd77e869c5052180fdf9d Mon Sep 17 00:00:00 2001 From: arottier Date: Fri, 25 Sep 2020 13:49:02 -0400 Subject: [PATCH 4/5] minor fixes --- dom.bs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dom.bs b/dom.bs index 76b9b0cfa..e919eb9b8 100644 --- a/dom.bs +++ b/dom.bs @@ -3645,7 +3645,7 @@ run these steps:

      If none of the following are true

        -
      • if options's {{MutationObserverInit/elementFilter}} is present, and the +
      • options's {{MutationObserverInit/elementFilter}} is present, and the node's localName is in {{MutationObserverInit/elementFilter}}
      • options's {{MutationObserverInit/elementByAttributeFilter}} is present, and @@ -3653,7 +3653,7 @@ run these steps: attribute name in nodeAttributesList
      -

      then enqueue record node in filteredAddedNodes. +

      then append node to filteredAddedNodes.

  • @@ -3667,15 +3667,15 @@ run these steps:

    If none of the following are true

      -
    • if options's {{MutationObserverInit/elementFilter}} is present, and the +
    • options's {{MutationObserverInit/elementFilter}} is present, and the node's localName is in {{MutationObserverInit/elementFilter}} -
    • if options's {{MutationObserverInit/elementByAttributeFilter}} is present, and +
    • options's {{MutationObserverInit/elementByAttributeFilter}} is present, and options's {{MutationObserverInit/elementByAttributeFilter}} contains any of the attribute names in nodeAttributesList
    -

    then enqueue record node in filterRemovedNodes. +

    then append node to filterRemovedNodes.

  • Assert: either filteredAddedNodes or filteredRemovedNodes From f9d51aaad2f90c7b6c25d07f3ddb7fc856e65c23 Mon Sep 17 00:00:00 2001 From: arottier Date: Sat, 6 Feb 2021 14:41:15 -0500 Subject: [PATCH 5/5] add links --- dom.bs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dom.bs b/dom.bs index e919eb9b8..b7344e160 100644 --- a/dom.bs +++ b/dom.bs @@ -3638,8 +3638,8 @@ run these steps:

    For each node in addedNodes:

      -
    1. Let nodeAttributesList be the set of local names of node's - attributes. +

    2. Let nodeAttributesList be the set of local names of node's + attributes.

    3. If none of the following are true @@ -3660,8 +3660,8 @@ run these steps:

      For each node in removedNodes:

        -
      1. Let nodeAttributesList be the set of local names of node's - attributes. +

      2. Let nodeAttributesList be the set of local names of node's + attributes.

      3. If none of the following are true