<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>16142</bug_id>
          
          <creation_ts>2012-02-27 23:51:59 +0000</creation_ts>
          <short_desc>Spec delivery semantics for MutationObservers</short_desc>
          <delta_ts>2012-03-06 23:45:02 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Adam Klein">adamk</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>bugs</cc>
    
    <cc>ian</cc>
    
    <cc>jonas</cc>
    
    <cc>mike</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>64663</commentid>
    <comment_count>0</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2012-02-27 23:51:59 +0000</bug_when>
    <thetext>From http://lists.w3.org/Archives/Public/public-webapps/2011JulSep/1622.html

&quot;Delivery of MutationRecords happens asynchronously, at the end of
the current “microtask”. This is between Options 2 and 3 from this
discussion http://lists.w3.org/Archives/Public/public-webapps/2011JulSep/0780.html.
Instead of calling listeners at the end of outermost DOM operation or
at the end of a Task, listeners are called at the end of outermost
script invocation. If there are no script invocations, listeners are
called at the end of Task.&quot;

See http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#mutation-observers for the current language. Specifically, &quot;delivery&quot; above means &quot;invoking the MutationCallback associated with a registered observer&quot; passing it the current &quot;record queue&quot; of that observer, and clearing the queue (just before invocation).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64693</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-02-28 19:30:54 +0000</bug_when>
    <thetext>I don&apos;t understand which observers I&apos;m supposed to know to call. Can you elaborate?

It would be ideal if there was just an algorithm I could call with a browsing context, Document, event loop, or other generic grouping identifier that would just fire all the relevant observers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64694</commentid>
    <comment_count>2</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2012-02-28 19:36:38 +0000</bug_when>
    <thetext>I don&apos;t think HTML spec should define when MutationObservers callbacks run,
but it should define what a microtask (feel free to change the name) is, 
and what it means to run something at end of microtask. 
Then DOM 4 could use that to define when callbacks are called.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64737</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-02-29 17:31:47 +0000</bug_when>
    <thetext>In reply to comment #2, As I mentioned on IRC earlier, we do not want DOM to depend on HTML.

I defined http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-mo-invoke as a hook for HTML. You also need to define the scope of &quot;scripting environment&quot;, which is basically all browsing contexts that can reach each other via script, but I cannot mention that normatively in the DOM. (At least until we give up on this dependency exercise.)

There is still an XXX comment remaining the source regarding transient observers and all this, advice welcome.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64738</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-02-29 17:35:17 +0000</bug_when>
    <thetext>Oh yes, and the million dollar question, what about garbage collection?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64746</commentid>
    <comment_count>5</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2012-02-29 18:18:40 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; Oh yes, and the million dollar question, what about garbage collection?

Not sure exactly what you&apos;re asking about, but the records would normally be GCed after the last observer with that record in its queue has been called (unless of course the observers take their own references).  Which implies that the nodes referred to by those records would also be collectable (if they&apos;re no longer in the document or referred to elsewhere).

As for the MutationObserver instances themselves, the WebKit approach is to give them weak references to the nodes they observe: if the node is collected, and there are no more references to the observer, it can also be collected.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64763</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-02-29 21:25:22 +0000</bug_when>
    <thetext>For GC, I recommend just saying that the EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see http://html5.org/tools/web-apps-tracker?from=7008&amp;to=7009
Rationale: Concurred with reporter&apos;s comments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64893</commentid>
    <comment_count>7</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-03-02 10:36:55 +0000</bug_when>
    <thetext>1. You use both &lt;var title=&quot;&quot;&gt;running mutation observers&lt;/var&gt; and &lt;dfn&gt;running mutation observers&lt;/dfn&gt;

2. Still curious about what you wanted to say about GC :-)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65079</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-03-06 23:43:12 +0000</bug_when>
    <thetext>1. Fixed.

2. I didn&apos;t have anything to say. I thought I should, so I wrote what you saw, then I thought about it, and realised I had nothing useful to say. So then I deleted what I wrote. Except apparently I didn&apos;t. :-)


EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: Concurred with reporter&apos;s comments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65080</commentid>
    <comment_count>9</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-03-06 23:43:36 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7019.
Check-in comment: fix up some xrefs
http://html5.org/tools/web-apps-tracker?from=7018&amp;to=7019</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65081</commentid>
    <comment_count>10</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-03-06 23:45:02 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7020.
Check-in comment: more markup errors
http://html5.org/tools/web-apps-tracker?from=7019&amp;to=7020</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>