• tkent's avatar
    Change the timing of event dispatching and <script> execution in... · e15391d9
    tkent authored
    Change the timing of event dispatching and <script> execution in Node::appendChild, insertBefore, and replaceChild.
    
    When we insert a DocumentFragment including multiple children into another node,
    
    * WebKit and Blink: DOMNodeInserted is dispatched just after each of
      DocumentFragment children was inserted.
    
    * Firefox and Edge: DOMNodeInserted is dispatched after all of DocumentFragment
      children were inserted.
    
    <script> execution and <iframe> load event have the same incompatibility.
    
    This CL makes Blink same as Firefox and Edge in order to improve interoperability
    and avoid additional hierarchy check for crbug.com/523157.
    
    Implementation:
    Fold updateTreeAfterInsertion() and notifyNodeInserted() into insertNodeVector(),
    and move childrenChange(), didNotifySubtreeInsertionsToDocument(), and
    dispatchChildInsertionEvents() out from the loop.
    
    Test changes:
    * fast/dom/MutationObserver/removed-out-of-order.html
      DOMNodeInserted timing change.  New result matches to Firefox and Edge.
    
    BUG=523157
    
    Review-Url: https://codereview.chromium.org/2306323002
    Cr-Commit-Position: refs/heads/master@{#417209}
    e15391d9
mutation-event-for-fragment-insertion.html 1.48 KB