From 19960d900ee213556c20c29a23fc89e7140562e5 Mon Sep 17 00:00:00 2001 From: arottier Date: Thu, 26 Mar 2020 15:37:38 -0700 Subject: [PATCH] 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..5a6b2a662 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.