- From: <bugzilla@jessica.w3.org>
- Date: Thu, 13 Nov 2014 21:03:45 +0000
- To: www-dom@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=27320 Bug ID: 27320 Summary: Need some clarification around MutationObserver stuff. Product: WebAppsWG Version: unspecified Hardware: PC OS: Windows NT Status: NEW Severity: normal Priority: P2 Component: DOM Assignee: annevk@annevk.nl Reporter: crimsteam@gmail.com QA Contact: public-webapps-bugzilla@w3.org CC: mike@w3.org, www-dom@w3.org I tried analyze dependencies across all algorithms and other prose for MutationObserver oposite to how browsers works, but every time something is wrong. Here are some inaccuracies: === callback MutationCallback = void (sequence<MutationRecord> mutations, MutationObserver observer); In practice mutations and observer are optional (Firefox/Chrome/IE), so maybe add "optional" to IDL? And maybe cover this somehow in prose (step 3.4 in "notify mutation observers"). <script> var new_MO = new MutationObserver(function(){}); alert(new_MO); // create without any problem </script> === Next is more complicated, but I'm not sure whether it is browsers problem or DOM. This affects mainly to "notify mutation observers" alghoritm and proper support takeRecords() method. Important thing is that if we operete on orginal or copy of something (like list or other object). Look this: 2. Let notify list be a copy of unit of related similar-origin browsing contexts's list of MutationObserver objects. Per spec. callback get only copy of MO (as second argument) but all browsers operate on original. <script> var new_MO = new MutationObserver(function(records, observer){ alert(new_MO === observer); alert(new_MO === this); alert(this === observer); }); var new_P = document.createElement("P"); new_MO.observe(new_P, {attributes: true}); new_P.id = "setID"; </script> Above is important for takeRecords() method because we can use this method for original (new_MO in our example) and for copy (observer in our example as second argument for callback or "this" value) directly in callback. takeRecords() method should clear "record queue", but if we have different object we have different "record queue" too. <script> var new_MO = new MutationObserver(function(records, observer){ // All browsers trate new_MO and observer as the same object (instance) and clear its record queue before invoke callback // its correct per step 3.2, but in generaly not per step 2. (algo "notify mutation observers") because its operate on copy var takeFrom_MO = new_MO.takeRecords().length; // record queue is empty var takeFrom_observer = observer.takeRecords().length; // record queue is empty document.documentElement.innerHTML += "new_MO.takeRecords().length: " + takeFrom_MO + "<br>" + "observer.takeRecords().length: " + takeFrom_observer // This was only copy so we still get 1 + "<br>" + "records.length: " + records.length }); var new_P = document.createElement("P"); new_MO.observe(new_P, {attributes: true}); new_P.id = "setID"; </script> What do you think? -- You are receiving this mail because: You are on the CC list for the bug.
Received on Thursday, 13 November 2014 21:03:46 UTC