Sunday 15 April 2012

javascript - When are MutationObserver callbacks fired? -


I know that mutationObservers can get a callback after some time after the DOM change but the question is, what is the time of these callbacks is? Do the callback browser enter the event queue? If so, when do they enter the queue?

There are callbacks:

  • DOM is said immediately after mutation,
  • As soon as the call stack is empty,
  • Enqueue immediately after the DOM mutation,
  • Use the function in the form of an encoding such as DOM, or
  • at some other time?

    For example, if the following part of the code is executed (with):

      var target = document.body; New Change Observer (function) {console.log ('MutationObserver');}) Inspection (target, {attributes: true, child list: true, characteristic: true}); // Set Post MessageJet Timetime (function () {console.log ('Message Event');}); // DOM mutation target.setAttribute ("data-test", "value");   

    Should "Event Object" print after "Message Event" or after? Or is this implementation-defined?

    I'm getting "EntertainmentAburser" before "Event Event" on Chromium 26, although DOM Mutation occurs after posting message. Perhaps this is indicating that mutation is not using the Observer callback event queue.

    I have googled for the HTML specification, DOM specification or browser implementation documents, but related to me

    P> Mutation Observer is removed from asynchronous but 'soon', which means that they fire in the queue before other things, such as layout, paint or trigger Events done

    It enhances the loss of synchronization,

    In developer notes, they talk about the 'end-of-microtask' timing model. I agree that this is a bad document.

No comments:

Post a Comment