initial draft of mutation observers https://www.w3.org/Bugs/Public/show_bug.cgi?id=13040
authorAnne van Kesteren <annevk@opera.com>
Thu, 16 Feb 2012 22:42:45 +0100
changeset 937f483bcdf3dba
parent 936 4743619d759c
child 938 a7a596e99a70
initial draft of mutation observers https://www.w3.org/Bugs/Public/show_bug.cgi?id=13040
Overview.html
Overview.src.html
dom-core.html
     1.1 --- a/Overview.html	Mon Feb 06 15:13:20 2012 +0100
     1.2 +++ b/Overview.html	Thu Feb 16 22:42:45 2012 +0100
     1.3 @@ -52,8 +52,8 @@
     1.4  <!--end-logo-->
     1.5  </div>
     1.6   <h1>DOM4</h1>
     1.7 - <h2 class="no-num no-toc" id="editor's-draft-6-february-2012">
     1.8 -  <span class="w3conly">Editor's Draft 6 February 2012</span>
     1.9 + <h2 class="no-num no-toc" id="editor's-draft-16-february-2012">
    1.10 +  <span class="w3conly">Editor's Draft 16 February 2012</span>
    1.11    </h2>
    1.12  
    1.13   <dl>
    1.14 @@ -84,7 +84,7 @@
    1.15  <p class="dontpublish copyright"><a href="http://creativecommons.org/publicdomain/zero/1.0/" rel="license"><img alt="CC0" src="http://i.creativecommons.org/p/zero/1.0/80x15.png"></a>
    1.16  To the extent possible under law, the editors have waived all copyright and
    1.17  related or neighboring rights to this work. In addition, as of
    1.18 -6 February 2012, the editors have made this specification available
    1.19 +16 February 2012, the editors have made this specification available
    1.20  under the
    1.21  <a href="http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0" rel="license">Open Web Foundation Agreement Version 1.0</a>,
    1.22  which is available at
    1.23 @@ -134,7 +134,9 @@
    1.24       <li><a href="#mutation-algorithms"><span class="secno">5.1.1 </span>Mutation algorithms</a></li>
    1.25       <li><a href="#mutation-methods"><span class="secno">5.1.2 </span>Mutation methods</a></li>
    1.26       <li><a href="#legacy-mutation-methods"><span class="secno">5.1.3 </span>Legacy mutation methods</a></li>
    1.27 -     <li><a href="#mutation-observers"><span class="secno">5.1.4 </span>Mutation observers</a></ol></li>
    1.28 +     <li><a href="#mutation-observers"><span class="secno">5.1.4 </span>Mutation observers</a></li>
    1.29 +     <li><a href="#mutation-observation-algorithms"><span class="secno">5.1.5 </span>Mutation observation algorithms</a></li>
    1.30 +     <li><a href="#mutationrecord-attributes"><span class="secno">5.1.6 </span>MutationRecord attributes</a></ol></li>
    1.31     <li><a href="#interface-node"><span class="secno">5.2 </span>Interface <code>Node</code></a></li>
    1.32     <li><a href="#interface-document"><span class="secno">5.3 </span>Interface <code>Document</code></a>
    1.33      <ol class="toc">
    1.34 @@ -1377,14 +1379,23 @@
    1.35   increase its <a href="#concept-range-end-offset" title="concept-range-end-offset">end offset</a> by
    1.36   <var title="">count</var>.
    1.37  
    1.38 + <li><p>Let <var title="">addedNodes</var> be an ordered list of <a href="#concept-node" title="concept-node">nodes</a>.
    1.39 +
    1.40   <li><p>If <var title="">node</var> is a <code><a href="#documentfragment">DocumentFragment</a></code>
    1.41 - <a href="#concept-node" title="concept-node">node</a>, insert its
    1.42 - <a href="#concept-tree-child" title="concept-tree-child">children</a> (preserving
    1.43 - <a href="#concept-tree-order" title="concept-tree-order">tree order</a>), before
    1.44 - <var title="">child</var> or at the end of <var title="">parent</var> if
    1.45 - <var title="">child</var> is null.
    1.46 -
    1.47 - <li><p>Otherwise insert <var title="">node</var> before
    1.48 + <a href="#concept-node" title="concept-node">node</a>, append its
    1.49 + <a href="#concept-tree-child" title="concept-tree-child">children</a> to <var title="">addedNodes</var>
    1.50 + (preserving <a href="#concept-tree-order" title="concept-tree-order">tree order</a>);
    1.51 + otherwise, append <var title="">node</var> to <var title="">addedNodes</var>.
    1.52 +
    1.53 + <li><p><a href="#concept-mutation-dispatch-childlist" title="concept-mutation-dispatch-childlist">Dispatch</a> a
    1.54 + "<code>childList</code>" mutation with <b>target</b> set to <var title="">parent</var>,
    1.55 + <b>addedNodes</b> set to <var title="">addedNodes</var>,
    1.56 + <b>nextSibling</b> set to <var title="">child</var>, and <b>previousSibling</b> set to
    1.57 + <var title="">child</var>'s <a href="#concept-tree-previous-sibling" title="concept-tree-previous-sibling">previous sibling</a>
    1.58 + or to <var title="">parent</var>'s <a href="#concept-tree-last-child" title="concept-tree-last-child">last child</a>
    1.59 + if <var title="">child</var> is null.
    1.60 +
    1.61 + <li><p>Insert all nodes in <var title="">addedNodes</var> before
    1.62   <var title="">child</var> or at the end of <var title="">parent</var> if
    1.63   <var title="">child</var> is null.
    1.64  </ol>
    1.65 @@ -1572,6 +1583,21 @@
    1.66   <var title="">index</var>, decrease its
    1.67   <a href="#concept-range-end-offset" title="concept-range-end-offset">end offset</a> by one.
    1.68  
    1.69 + <li><p><a href="#concept-mutation-dispatch-childlist" title="concept-mutation-dispatch-childlist">Dispatch</a> a
    1.70 + "<code>childList</code>" mutation with <b>target</b> set to <var title="">parent</var>,
    1.71 + <b>removedNodes</b> set to a <code><a href="#nodelist">NodeList</a></code> containing only <var title="">node</var>,
    1.72 + <b>nextSibling</b> set to <var title="">node</var>'s
    1.73 + <a href="#concept-tree-next-sibling" title="concept-tree-next-sibling">next sibling</a>,
    1.74 + and <b>previousSibling</b> set to <var title="">node</var>'s
    1.75 + <a href="#concept-tree-previous-sibling" title="concept-tree-previous-sibling">previous sibling</a>.
    1.76 +
    1.77 + <li><p>For each <a href="#concept-tree-ancestor" title="concept-tree-ancestor">ancestor</a> <var title="">ancestor</var>
    1.78 + of <var title="">node</var>, if <var title="">ancestor</var> has any
    1.79 + <a href="#registered-observer" title="registered-observer">registered observers</a> with the <code>subtree</code>
    1.80 + option set, <a href="#concept-add-transient-observer" title="concept-add-transient-observer">add</a>
    1.81 + an identical <a href="#transient-observer">transient observer</a> to <var title="">node</var> for
    1.82 + each such subtree <a href="#registered-observer" title="registered-observer">registration</a> on <var title="">ancestor</var>.
    1.83 +
    1.84   <li><p>Remove <var title="">node</var> from its <var title="">parent</var>.
    1.85  </ol>
    1.86  
    1.87 @@ -1720,74 +1746,258 @@
    1.88  
    1.89  <h4 id="mutation-observers"><span class="secno">5.1.4 </span>Mutation observers</h4>
    1.90  
    1.91 -<p class="XXX">This section will define the replacement for the
    1.92 -"Mutation Events" feature of the platform. For now it contains the interface
    1.93 -being implemented by vendors.
    1.94 -
    1.95  <pre class="idl">[Constructor(<a href="#mutationcallback">MutationCallback</a> callback)]
    1.96  interface <dfn id="mutationobserver">MutationObserver</dfn> {
    1.97 -  void observe(<a href="#node">Node</a> target, <a href="#mutationobserverinit">MutationObserverInit</a> options);
    1.98 -  void disconnect();
    1.99 +  void <a href="#dom-mutationobserver-observe" title="dom-MutationObserver-observe">observe</a>(<a href="#node">Node</a> target, <a href="#mutationobserverinit">MutationObserverInit</a> options);
   1.100 +  void <a href="#dom-mutationobserver-disconnect" title="dom-MutationObserver-disconnect">disconnect</a>();
   1.101  };
   1.102  
   1.103  callback <dfn id="mutationcallback">MutationCallback</dfn> = void (<a href="#mutationrecord">MutationRecord</a>[] mutations, <a href="#mutationobserver">MutationObserver</a> observer);
   1.104  
   1.105  dictionary <dfn id="mutationobserverinit">MutationObserverInit</dfn> {
   1.106 -  // Mutation types
   1.107 -  boolean childList;     // If true, mutations affecting node&rsquo;s childNodes are included.
   1.108 -  boolean attributes;    // If true, mutations affecting element&rsquo;s attributes are included.
   1.109 -  boolean characterData; // If true, mutations affecting the value of CharacterData nodes are included.
   1.110 -  // [Note: If none of the known mutation types is specified, an Error is thrown]
   1.111 -
   1.112 -  // Subtree observation
   1.113 -  boolean subtree;  // If true, the observed set of nodes for this registration should include
   1.114 -                    // descendants of MutationTarget (behavior described below).
   1.115 -
   1.116 -  // Old values
   1.117 -  boolean attributeOldValue;
   1.118 -  // If true, MutationRecords describing changes to attributes should
   1.119 -  // contain the value of the attribute before the change. If true
   1.120 -  // without attribute: true specified, an Error is thrown.
   1.121 -
   1.122 -  boolean characterDataOldValue;
   1.123 -  // If true, MutationRecords describing changes to
   1.124 -  // CharacterData nodes should contain the value
   1.125 -  // of the node before the change. If true without
   1.126 -  // characterData: true, an Error is thrown.
   1.127 -
   1.128 -  // Filtering
   1.129 -  DOMString[] attributeFilter;
   1.130 -  // If provided, only changes to attributes with localName equaling
   1.131 -  // one of the provided strings will be delivered. If provided without
   1.132 -  // attribute: true, an Error is thrown.
   1.133 +  boolean <span title="dom-MutationObserverInit-childlist">childList</span>;
   1.134 +  boolean <span title="dom-MutationObserverInit-attributes">attributes</span>;
   1.135 +  boolean <span title="dom-MutationObserverInit-characterdata">characterData</span>;
   1.136 +  boolean <span title="dom-MutationObserverInit-subtree">subtree</span>;
   1.137 +  boolean <span title="dom-MutationObserverInit-attributeoldvalue">attributeOldValue</span>;
   1.138 +  boolean <span title="dom-MutationObserverInit-characterdataoldvalue">characterDataOldValue</span>;
   1.139 +  DOMString[] <span title="dom-MutationObserverInit-attributefilter">attributeFilter</span>;
   1.140  };
   1.141  
   1.142  interface <dfn id="mutationrecord">MutationRecord</dfn> {
   1.143 -  // Mutation type: one of 'childList', 'attributes', or 'characterData'
   1.144 -  readonly attribute DOMString type;
   1.145 -
   1.146 -  // For childList and attributes, target is the owner node affected.
   1.147 -  // For CharacterData, target is the node affected.
   1.148 -  readonly attribute <a href="#node">Node</a> target;
   1.149 -
   1.150 -  // For type == 'childList', Sequence of added and removed nodes in this operation.
   1.151 -  readonly attribute <a href="#nodelist">NodeList</a> addedNodes;
   1.152 -  readonly attribute <a href="#nodelist">NodeList</a> removedNodes;
   1.153 -
   1.154 -  // For type == 'childList', The siblings in childNodes immediately preceding following the first
   1.155 -  // and last nodes added and/or removed.
   1.156 -  readonly attribute <a href="#node">Node</a> previousSibling;
   1.157 -  readonly attribute <a href="#node">Node</a> nextSibling;
   1.158 -
   1.159 -  // For type == 'attribute', the name and namespaceURI of the attribute affected
   1.160 -  readonly attribute DOMString attributeName;
   1.161 -  readonly attribute DOMString attributeNamespace;
   1.162 -
   1.163 -  // For type == 'attribute' or 'characterData', if requested, the value immediately
   1.164 -  // preceding the mutation.
   1.165 -  readonly attribute DOMString oldValue;
   1.166 +  readonly attribute DOMString <a href="#dom-mutationrecord-type" title="dom-MutationRecord-type">type</a>;
   1.167 +  readonly attribute <a href="#node">Node</a> <a href="#dom-mutationrecord-target" title="dom-MutationRecord-target">target</a>;
   1.168 +  readonly attribute <a href="#nodelist">NodeList</a>? <a href="#dom-mutationrecord-addednodes" title="dom-MutationRecord-addedNodes">addedNodes</a>;
   1.169 +  readonly attribute <a href="#nodelist">NodeList</a>? <a href="#dom-mutationrecord-removednodes" title="dom-MutationRecord-removedNodes">removedNodes</a>;
   1.170 +  readonly attribute <a href="#node">Node</a>? <a href="#dom-mutationrecord-previoussibling" title="dom-MutationRecord-previousSibling">previousSibling</a>;
   1.171 +  readonly attribute <a href="#node">Node</a>? <a href="#dom-mutationrecord-nextsibling" title="dom-MutationRecord-nextSibling">nextSibling</a>;
   1.172 +  readonly attribute DOMString? <a href="#dom-mutationrecord-attributename" title="dom-MutationRecord-attributeName">attributeName</a>;
   1.173 +  readonly attribute DOMString? <a href="#dom-mutationrecord-attributenamespace" title="dom-MutationRecord-attributeNamespace">attributeNamespace</a>;
   1.174 +  readonly attribute DOMString? <a href="#dom-mutationrecord-oldvalue" title="dom-MutationRecord-oldValue">oldValue</a>;
   1.175  };</pre>
   1.176 -<!-- XXX remove inline comments when this is defined -->
   1.177 +
   1.178 +<p>When the constructor of the <code><a href="#mutationobserver">MutationObserver</a></code> interface is invoked
   1.179 +with callback <var title="">callback</var> and options <var title="">options</var>, run these steps:
   1.180 +
   1.181 +<ol>
   1.182 +  <li><p>If <var title="">callback</var> is null, <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#notfounderror">NotFoundError</a></code>" and terminate these steps.
   1.183 +  <li><p>Return a <code><a href="#mutationobserver">MutationObserver</a></code> <a href="#mutation-observer-associated-callback" title="mutation-observer-associated-callback">associated</a> with the callback.
   1.184 +</ol>
   1.185 +
   1.186 +Besides the properties listed in the IDL for <code><a href="#mutationobserver">MutationObserver</a></code>, it has three internal properties:
   1.187 +<ul>
   1.188 +  <li><p>An <dfn id="mutation-observer-associated-callback" title="mutation-observer-associated-callback">associated callback</dfn>.
   1.189 +  <li><p>A list of <a href="#concept-node" title="concept-node">nodes</a> on which it is <a href="#registered-observer" title="registered-observer">registered</a>.
   1.190 +  <li><p>A queue of <code><a href="#mutationrecord">MutationRecord</a></code>s which are <dfn id="mutation-observer-pending" title="mutation-observer-pending">pending</dfn> delivery.
   1.191 +</ul>
   1.192 +
   1.193 +<hr>
   1.194 +
   1.195 +<p>A <dfn id="registered-observer" title="registered-observer">registered observer</dfn> consists of an <b>observer</b> (an instance of <code><a href="#mutationobserver">MutationObserver</a></code>),
   1.196 +a set of <b>options</b> (an instance of <code><a href="#mutationobserverinit">MutationObserverInit</a></code>), and a <b>transient</b> variable (whose default value is false).
   1.197 +Each <code><a href="#node">Node</a></code> has a list of registered observers. A <dfn id="transient-observer">transient observer</dfn> is a <a href="#registered-observer" title="registered-observer">registered observer</a>
   1.198 +whose <b>transient</b> variable is set to true.
   1.199 +<!-- XXX Need a cross-reference from the microtask processing model explaining when to remove transient observers -->
   1.200 +
   1.201 +<hr>
   1.202 +
   1.203 +<p>When the <dfn id="dom-mutationobserver-observe" title="dom-MutationObserver-observe"><code>observe(<var title="">target</var>, <var title="">options</var>)</code></dfn>
   1.204 +method is called, these steps must be run:
   1.205 +
   1.206 +<ol>
   1.207 +  <li><p>If <var title="">target</var> is not a <a href="#concept-node" title="concept-node">node</a>,
   1.208 +  <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#notfounderror">NotFoundError</a></code>" and terminate these steps.
   1.209 +
   1.210 +  <li><p>If <var title="">options</var> is null, or is not an instance of <code><a href="#mutationobserverinit">MutationObserverInit</a></code>,
   1.211 +  <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#typemismatcherror">TypeMismatchError</a></code>" and terminate these steps.
   1.212 +
   1.213 +  <li><p>Run these substeps, treating <var title="">options</var> as the <a href="#context-object">context object</a>:
   1.214 +  <ol>
   1.215 +    <li><p>If neither <code>childList</code>, <code>attributes</code>, nor <code><a href="#characterdata">characterData</a></code> is true,
   1.216 +    <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#syntaxerror">SyntaxError</a></code>" and terminate these steps.
   1.217 +
   1.218 +    <li><p>If <code>attributeOldValue</code> is true and <code>attributes</code> is not true,
   1.219 +    <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#syntaxerror">SyntaxError</a></code>" and terminate these steps.
   1.220 +
   1.221 +    <li><p>If <code>attributeFilter</code> is a non-empty array and <code>attributes</code> is not true,
   1.222 +    <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#syntaxerror">SyntaxError</a></code>" and terminate these steps.
   1.223 +
   1.224 +    <li><p>If <code>characterDataOldValue</code> is true and <code><a href="#characterdata">characterData</a></code> is not true,
   1.225 +    <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#syntaxerror">SyntaxError</a></code>" and terminate these steps.
   1.226 +  </ol>
   1.227 +
   1.228 +  <li><p>If <var title="">target</var>'s registration list already includes a registration associated with
   1.229 +  the <a href="#context-object">context object</a>, replace that registrations's options with <var title="">options</var>.
   1.230 +
   1.231 +  <li><p>Otherwise, add a new <a href="#registered-observer" title="registered-observer">registration</a> to <var title="">target</var>'s registered observer list with the
   1.232 +  <a href="#context-object">context object</a> as the <var title="">observer</var> and <var title="">options</var> as the options,
   1.233 +  and add <var title="">target</var> to <var title="">observer</var>'s list of nodes on which it is registered.
   1.234 +</ol>
   1.235 +
   1.236 +<p>When the <dfn id="dom-mutationobserver-disconnect" title="dom-MutationObserver-disconnect"><code>disconnect</code></dfn> method is called, for each
   1.237 +<a href="#concept-node" title="concept-node">node</a> <var title="">node</var> in the <a href="#context-object">context object</a>'s list of
   1.238 +<a href="#concept-node" title="concept-node">nodes</a>, remove any <a href="#registered-observer" title="registered-observer">registration</a> on <var title="">node</var> for which
   1.239 +the <a href="#context-object">context object</a> is the <b>observer</b>.
   1.240 +
   1.241 +<h4 id="mutation-observation-algorithms"><span class="secno">5.1.5 </span>Mutation observation algorithms</h4>
   1.242 +
   1.243 +To <dfn id="concept-mutation-dispatch-attributes" title="concept-mutation-dispatch-attributes">dispatch</dfn> an "<code>attributes</code>" MutationRecord
   1.244 +with target <var title="">target</var>, attributeName <var title="">name</var>, and oldValue <var title="">oldValue</var>,
   1.245 +run these steps:
   1.246 +
   1.247 +<ol>
   1.248 +<li><p>Create a new MutationRecord <var title="">record</var> with type initialized to "<code>attributes</code>", target initialized to <var title="">target</var>,
   1.249 +and attributeName initialized to <var title="">name</var>.
   1.250 +
   1.251 +<li><p>Create a copy of this record named <var title="">recordWithOldValue</var> and initialize its oldValue to <var title="">oldValue</var>.
   1.252 +
   1.253 +<li><p>For each <a href="#registered-observer" title="registered-observer">registered observer</a> <var title="">observer</var> (with options <var title="">options</var>) in
   1.254 +
   1.255 +<var title="">target</var>'s registered observer list, run these substeps:
   1.256 +  <ol>
   1.257 +    <li><p>If <var title="">options</var> does not have the <code>attributes</code> option set, terminate these substeps (and run them for the next observer).
   1.258 +
   1.259 +    <li><p>If <var title="">options</var> has a non-empty <code>attributeFilter</code> array, and <var title="">name</var> is not in that array, terminate these substeps
   1.260 +    (and run them for the next observer).
   1.261 +
   1.262 +    <li><p>If <var title="">options</var> has the <code>attributeOldValue</code> option set, append <var title="">recordWithOldValue</var> to the observer's
   1.263 +    queue of pending mutations.
   1.264 +
   1.265 +    <li><p>Otherwise, append <var title="">record</var> to the observer's queue of pending mutations.
   1.266 +    </ol>
   1.267 +     <li><p>For each <a href="#concept-tree-ancestor" title="concept-tree-ancestor">ancestor</a> <var title="">ancestor</var> of target, and for each
   1.268 +     <a href="#registered-observer" title="registered-observer">registered observer</a> <var title="">observer</var> (with options <var title="">options</var>) in <var title="">ancestor</var>'s
   1.269 +     registered observer list, run these substeps:
   1.270 +    <ol>
   1.271 +
   1.272 +    <li><p>If <var title="">options</var> does not have the <code>subtree</code> option set, terminate these substeps (and run them for the next observer).
   1.273 +
   1.274 +    <li><p>If <var title="">options</var> does not have the <code>attributes</code> option set, terminate these substeps (and run them for the next observer).
   1.275 +
   1.276 +    <li><p>If <var title="">options</var> has a non-empty <code>attributeFilter</code> array, and <var title="">name</var> is not in that array, terminate these substeps
   1.277 +    (and run them for the next observer).
   1.278 +
   1.279 +    <li><p>If <var title="">options</var> has the <code>attributeOldValue</code> option set, append <var title="">recordWithOldValue</var> to the observer's
   1.280 +    queue of pending mutations.
   1.281 +
   1.282 +    <li><p>Otherwise, append <var title="">record</var> to the observer's queue of <a href="#mutation-observer-pending" title="mutation-observer-pending">pending</a> mutations.
   1.283 +  </ol>
   1.284 +</ol>
   1.285 +
   1.286 +To <dfn id="concept-mutation-dispatch-characterdata" title="concept-mutation-dispatch-characterData">dispatch</dfn> a "<code><a href="#characterdata">characterData</a></code>" MutationRecord
   1.287 +with target <var title="">target</var> and oldValue <var title="">oldValue</var>, run these steps:
   1.288 +
   1.289 +<ol>
   1.290 + <li><p>Create a new MutationRecord <var title="">record</var> with type initialized to "<code><a href="#characterdata">characterData</a></code>" and target initialized to <var title="">target</var>.
   1.291 +
   1.292 + <li><p>Create a copy of this record named <var title="">recordWithOldValue</var> and initialize its oldValue to <var title="">oldValue</var>.
   1.293 +
   1.294 + <li><p>For each <a href="#registered-observer" title="registered-observer">registered observer</a> <var title="">observer</var> (with options <var title="">options</var>) in
   1.295 + <var title="">target</var>'s registered observer list, run these substeps:
   1.296 +   <ol>
   1.297 +    <li><p>If <var title="">options</var> does not have the <code><a href="#characterdata">characterData</a></code> option set, terminate these substeps (and run them for the next observer).
   1.298 +
   1.299 +    <li><p>If <var title="">options</var> has the <code>characterDataOldValue</code> option set, append <var title="">recordWithOldValue</var> to the observer's
   1.300 +    queue of pending mutations.
   1.301 +
   1.302 +    <li><p>Otherwise, append <var title="">record</var> to the observer's queue of pending mutations.
   1.303 +   </ol>
   1.304 +
   1.305 + <li><p>For each <a href="#concept-tree-ancestor" title="concept-tree-ancestor">ancestor</a> <var title="">ancestor</var> of target, and for each
   1.306 + <a href="#registered-observer" title="registered-observer">registered observer</a> <var title="">observer</var> (with options <var title="">options</var>) in <var title="">ancestor</var>'s
   1.307 + registered observer list, run these substeps:
   1.308 + <ol>
   1.309 +  <li><p>If <var title="">options</var> does not have the <code>subtree</code> option set, terminate these substeps (and run them for the next observer).
   1.310 +
   1.311 +  <li><p>If <var title="">options</var> does not have the <code><a href="#characterdata">characterData</a></code> option set, terminate these substeps (and run them for the next observer).
   1.312 +
   1.313 +  <li><p>If <var title="">options</var> has the <code>characterDataOldValue</code> option set, append <var title="">recordWithOldValue</var> to the observer's
   1.314 +    queue of pending mutations.
   1.315 +
   1.316 +  <li><p>Otherwise, append <var title="">record</var> to the observer's queue of <a href="#mutation-observer-pending" title="mutation-observer-pending">pending</a> mutations.
   1.317 + </ol>
   1.318 +</ol>
   1.319 +
   1.320 +To <dfn id="concept-mutation-dispatch-childlist" title="concept-mutation-dispatch-childList">dispatch</dfn> a "<code>childList</code>" MutationRecord
   1.321 +with target <var title="">target</var>, addedNodes <var title="">addedNodes</var>, removedNodes <var title="">removedNodes</var>, previousSibling <var title="">previousSibling</var>,
   1.322 +and nextSibling <var title="">nextSibling</var>, run these steps:
   1.323 +
   1.324 +<ol>
   1.325 + <li><p>Create a new MutationRecord <var title="">record</var> with type initialized to "<code>childList</code>", target initialized to <var title="">target</var>,
   1.326 + addedNodes initialized to <var title="">addedNodes</var>, removedNodes initialized to <var title="">removedNodes</var>,
   1.327 + previousSibling initialized to <var title="">previousSibling</var>, and nextSibling initialized to.
   1.328 +
   1.329 + <li><p>For each <a href="#registered-observer" title="registered-observer">registered observer</a> <var title="">observer</var> (with options <var title="">options</var>) in
   1.330 + <var title="">target</var>'s registered observer list, run these substeps:
   1.331 + <ol>
   1.332 +  <li><p>If <var title="">options</var> does not have the <code>childList</code> option set, terminate these substeps (and run them for the next observer).
   1.333 +
   1.334 +  <li><p>Append <var title="">record</var> to the observer's queue of pending mutations.
   1.335 + </ol>
   1.336 +
   1.337 + <li><p>For each <a href="#concept-tree-ancestor" title="concept-tree-ancestor">ancestor</a> <var title="">ancestor</var> of target, and for each
   1.338 + <a href="#registered-observer" title="registered-observer">registered observer</a> <var title="">observer</var> (with options <var title="">options</var>) in <var title="">ancestor</var>'s
   1.339 + registered observer list, run these substeps:
   1.340 + <ol>
   1.341 +  <li><p>If <var title="">options</var> does not have the <code>subtree</code> option set, terminate these substeps (and run them for the next observer).
   1.342 +
   1.343 +  <li><p>If <var title="">options</var> does not have the <code>childList</code> option set, terminate these substeps (and run them for the next observer).
   1.344 +
   1.345 +  <li><p>Append <var title="">record</var> to the observer's queue of <a href="#mutation-observer-pending" title="mutation-observer-pending">pending</a> mutations.
   1.346 + </ol>
   1.347 +</ol>
   1.348 +
   1.349 +To <dfn id="concept-add-transient-observer" title="concept-add-transient-observer">add a transient observer</dfn> <var title="">observer</var> with options <var title="">options</var>
   1.350 +to a <a href="#concept-node" title="concept-node">node</a> <var title="">node</var>, create a new <a href="#registered-observer" title="registered-observer">registration</a> with <b>observer</b> set to
   1.351 +<var title="">observer</var>, <b>options</b> set to <var title="">options</var>, and <b>transient</b> set to true and append it to <var title="">node</var>'s
   1.352 +list of <a href="#registered-observer" title="registered-observer">registered observers</a>.
   1.353 +
   1.354 +<h4 id="mutationrecord-attributes"><span class="secno">5.1.6 </span>MutationRecord attributes</h4>
   1.355 +
   1.356 +<p>The <dfn id="dom-mutationrecord-type" title="dom-MutationRecord-type"><code>type</code></dfn> attribute must return
   1.357 +a string representing the type of the mutation, which must be one of the following:
   1.358 +<ul>
   1.359 +  <li>"<dfn id="dom-mutationrecord-type-attributes" title="dom-MutationRecord-type-attributes"><code>attributes</code></dfn>"
   1.360 +  <li>"<dfn id="dom-mutationrecord-type-childlist" title="dom-MutationRecord-type-childList"><code>childList</code></dfn>"
   1.361 +  <li>"<dfn id="dom-mutationrecord-type-characterdata" title="dom-MutationRecord-type-characterData"><code>characterData</code></dfn>"
   1.362 +</ul>
   1.363 +
   1.364 +<p>The <dfn id="dom-mutationrecord-target" title="dom-MutationRecord-target"><code>target</code></dfn> attribute must
   1.365 +return the node this mutation affected, which differs depending on the <span title="mutation-record-type">type</span>.
   1.366 +For childList mutations, it must be the node whose children changed.
   1.367 +For attributes mutations, it must be the element whose attributes changed.
   1.368 +For characterData mutations, it must be the <code><a href="#characterdata">CharacterData</a></code> node whose value changed.
   1.369 +
   1.370 +<p>The <dfn id="dom-mutationrecord-addednodes" title="dom-MutationRecord-addedNodes"><code>addedNodes</code></dfn> attribute must return
   1.371 +the list of nodes added in this mutation, if it was a childList mutation. Otherwise it must return null.
   1.372 +
   1.373 +<p>The <dfn id="dom-mutationrecord-removednodes" title="dom-MutationRecord-removedNodes"><code>removedNodes</code></dfn> attribute must return
   1.374 +the list of nodes removed in this mutation, if it was a childList mutation. Otherwise it must return null.
   1.375 +
   1.376 +<p>The <dfn id="dom-mutationrecord-previoussibling" title="dom-MutationRecord-previousSibling"><code>previousSibling</code></dfn> attribute must return
   1.377 +the node which was the <a href="#concept-tree-previous-sibling" title="concept-tree-previous-sibling">previous sibling</a> of the first element of addedNodes when the mutation occurred, if addedNodes is non-empty,
   1.378 +or the node which was the <a href="#concept-tree-previous-sibling" title="concept-tree-previous-sibling">previous sibling</a> of the first element of removedNodes, if removedNodes is non-empty. Otherwise it must return null.
   1.379 +
   1.380 +<p>The <dfn id="dom-mutationrecord-nextsibling" title="dom-MutationRecord-nextSibling"><code>nextSibling</code></dfn> attribute must return
   1.381 +the node which was the <a href="#concept-tree-next-sibling" title="concept-tree-next-sibling">next sibling</a> of the last item in addedNodes when the mutation occurred, if addedNodes is non-empty,
   1.382 +or the node which was the <a href="#concept-tree-next-sibling" title="concept-tree-next-sibling">next sibling</a> of the last element of removedNodes, if removedNodes is non-empty. Otherwise it must return null.
   1.383 +
   1.384 +<p>The <dfn id="dom-mutationrecord-attributename" title="dom-MutationRecord-attributeName"><code>attributeName</code></dfn> attribute must return
   1.385 +the <code title="dom-attr-name"><a href="#dom-attr-name">name</a></code> of the modified attribute if this is an "<code>attributes</code>" mutation. Otherwise it must return null.
   1.386 +
   1.387 +<p>The <dfn id="dom-mutationrecord-attributenamespace" title="dom-MutationRecord-attributeNamespace"><code>attributeNamespace</code></dfn> attribute must return
   1.388 +the <code title="dom-attr-namespaceuri"><a href="#dom-attr-namespaceuri">namespaceURI</a></code> of the modified attribute if this is an "<code>attributes</code>" mutation. Otherwise it must return null.
   1.389 +
   1.390 +<p>The <dfn id="dom-mutationrecord-oldvalue" title="dom-MutationRecord-oldValue"><code>oldValue</code></dfn> attribute varies in behavior
   1.391 +based on the <a href="#dom-mutationrecord-type" title="dom-MutationRecord-type">type</a> of mutation:
   1.392 +
   1.393 +<ul>
   1.394 +  <li><p>If type is "<code>childList</code>", it must return null.
   1.395 +  <li><p>If type is "<code>attributes</code>" and the registered observation had the attributeOldValue option set, must return
   1.396 +  the <a href="#dom-attr-value" title="dom-attr-value">value</a> of the <a href="#attr" title="attr">attribute</a> just before the mutation was made.
   1.397 +  <li><p>If type is "<code><a href="#characterdata">characterData</a></code>" and the registered observation had the characterDataOldValue option set, must return the value of
   1.398 +  the <a href="#dom-mutationrecord-target" title="dom-MutationRecord-target">target</a>'s <a href="#dom-characterdata-data" title="dom-characterdata-data">data</a> attribute just before the mutation was made.
   1.399 +</ul>
   1.400  
   1.401  
   1.402  <h3 id="interface-node"><span class="secno">5.2 </span>Interface <code><a href="#node">Node</a></code></h3>
   1.403 @@ -3386,7 +3596,7 @@
   1.404   <a href="#affected-by-a-base-url-change">affected by a base URL change</a>.
   1.405  
   1.406   <li><p>If <var title="">node</var>'s
   1.407 - <a href="#concept-tree-parent" title="concept-tree-parent">parent</a> is not null, remove
   1.408 + <a href="#concept-tree-parent" title="concept-tree-parent">parent</a> is not null, <a href="#concept-node-remove" title="concept-node-remove">remove</a>
   1.409   <var title="">node</var> from its
   1.410   <a href="#concept-tree-parent" title="concept-tree-parent">parent</a>.
   1.411  
   1.412 @@ -4120,24 +4330,29 @@
   1.413   <var title="">name</var>, <a href="#concept-throw" title="concept-throw">throw</a> a
   1.414   "<code><a href="#namespaceerror">NamespaceError</a></code>" and terminate these steps.
   1.415  
   1.416 - <li><p>If the <a href="#context-object">context object</a> does not have an
   1.417 + <li><p>Let <var title="">attribute</var> be the
   1.418 + first <a href="#concept-attribute" title="concept-attribute">attribute</a> in the
   1.419 + <a href="#context-object">context object</a>'s <a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a>
   1.420 + whose <a href="#concept-attribute-name" title="concept-attribute-name">name</a> is
   1.421 + <var title="">name</var>, or null if there is no such
   1.422 + <a href="#concept-attribute" title="concept-attribute">attribute</a>.
   1.423 +
   1.424 + <li><p>If <var title="">attribute</var> is null, create an
   1.425   <a href="#concept-attribute" title="concept-attribute">attribute</a> whose
   1.426   <a href="#concept-attribute-name" title="concept-attribute-name">name</a> is
   1.427 - <var title="">name</var>, create an
   1.428 - <a href="#concept-attribute" title="concept-attribute">attribute</a>, whose
   1.429 - <a href="#concept-attribute-name" title="concept-attribute-name">name</a> is
   1.430   <var title="">name</var> and
   1.431   <a href="#concept-attribute-value" title="concept-attribute-value">value</a> is <var title="">value</var>,
   1.432   and then <a href="#concept-element-attributes-append" title="concept-element-attributes-append">append</a> this
   1.433   <a href="#concept-attribute" title="concept-attribute">attribute</a> to the
   1.434 - <a href="#context-object">context object</a>.
   1.435 -
   1.436 - <li><p>Otherwise, <a href="#concept-attribute-change" title="concept-attribute-change">change</a> the
   1.437 - first <a href="#concept-attribute" title="concept-attribute">attribute</a> in the
   1.438 - <a href="#context-object">context object</a>'s
   1.439 - <a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a> whose
   1.440 - <a href="#concept-attribute-name" title="concept-attribute-name">name</a> is
   1.441 - <var title="">name</var>, to <var title="">value</var>.
   1.442 + <a href="#context-object">context object</a> and terminate these steps.
   1.443 +
   1.444 + <li><p><a href="#concept-mutation-dispatch-attributes" title="concept-mutation-dispatch-attributes">Dispatch</a> an "<code>attributes</code>"
   1.445 + <code><a href="#mutationrecord">MutationRecord</a></code> with <b>target</b> set to the <a href="#context-object">context object</a>,
   1.446 + <b>attributeName</b> set to <var title="">attribute</var>'s <a href="#dom-attr-localname" title="dom-attr-localname">localName</a>,
   1.447 + <b>attributeNamespace</b> set to <var title="">attribute</var>'s <a href="#dom-attr-namespaceuri" title="dom-attr-namespaceuri">namespaceURI</a>,
   1.448 + and <b>oldValue</b> set to <var title="">attribute</var>'s <a href="#dom-attr-value" title="dom-attr-value">value</a>.
   1.449 +
   1.450 + <li><p>Set <var title="">attribute</var>'s <a href="#concept-attribute-value" title="concept-attribute-value">value</a> to <var title="">value</var>.
   1.451  </ol>
   1.452  
   1.453  <p>The
   1.454 @@ -4183,14 +4398,18 @@
   1.455   "<code title="">xmlns</code>", <a href="#concept-throw" title="concept-throw">throw</a> a
   1.456   "<code><a href="#namespaceerror">NamespaceError</a></code>" exception and terminate these steps.
   1.457  
   1.458 - <li><p>If the <a href="#context-object">context object</a> does not
   1.459 - <a href="#concept-element-attribute-has" title="concept-element-attribute-has">have</a> an
   1.460 + <li><p>Let <var title="">attribute</var> be the
   1.461 + first <a href="#concept-attribute" title="concept-attribute">attribute</a> in the
   1.462 + <a href="#context-object">context object</a>'s
   1.463 + <a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a>
   1.464 + whose <a href="#concept-attribute-namespace" title="concept-attribute-namespace">namespace</a> is
   1.465 + <var title="">namespace</var> and whose
   1.466 + <a href="#concept-attribute-local-name" title="concept-attribute-local-name">local name</a>
   1.467 + is <var title="">localName</var>, or null if there is no such
   1.468 + <a href="#concept-attribute" title="concept-attribute">attribute</a>.
   1.469 +
   1.470 + <li><p>If <var title="">attribute</var> is null, create an
   1.471   <a href="#concept-attribute" title="concept-attribute">attribute</a> whose
   1.472 - <a href="#concept-attribute-namespace" title="concept-attribute-namespace">namespace</a> is
   1.473 - <var title="">namespace</var> and
   1.474 - <a href="#concept-attribute-local-name" title="concept-attribute-local-name">local name</a> is
   1.475 - <var title="">localName</var>, create an
   1.476 - <a href="#concept-attribute" title="concept-attribute">attribute</a>, whose
   1.477   <a href="#concept-attribute-name" title="concept-attribute-name">name</a> is
   1.478   <var title="">name</var>,
   1.479   <a href="#concept-attribute-namespace" title="concept-attribute-namespace">namespace</a> is
   1.480 @@ -4202,10 +4421,17 @@
   1.481   is <var title="">value</var>, and then
   1.482   <a href="#concept-element-attributes-append" title="concept-element-attributes-append">append</a> this
   1.483   <a href="#concept-attribute" title="concept-attribute">attribute</a> to the
   1.484 - <a href="#context-object">context object</a>.
   1.485 -
   1.486 - <li><p>Otherwise, <a href="#concept-attribute-change" title="concept-attribute-change">change</a> that
   1.487 - <a href="#concept-attribute" title="concept-attribute">attribute</a> to <var title="">value</var>.
   1.488 + <a href="#context-object">context object</a> and terminate these steps.
   1.489 +
   1.490 + <li><p><a href="#concept-mutation-dispatch-attributes" title="concept-mutation-dispatch-attributes">Dispatch</a> an
   1.491 + "<code>attributes</code>" <code><a href="#mutationrecord">MutationRecord</a></code> with <b>target</b>
   1.492 + set to the <a href="#context-object">context object</a>, <b>attributeName</b> set to
   1.493 + <var title="">name</var>, <b>attributeNamespace</b> set to
   1.494 + <var title="">namespace</var>, and <b>oldValue</b> set to
   1.495 + <var title="">attribute</var>'s <a href="#dom-attr-value" title="dom-attr-value">value</a>.
   1.496 +
   1.497 + <li><p>Set <var title="">attribute</var>'s
   1.498 + <a href="#concept-attribute-value" title="concept-attribute-value">value</a> to <var title="">value</var>.
   1.499  </ol>
   1.500  
   1.501  <p>The
   1.502 @@ -4420,26 +4646,42 @@
   1.503  
   1.504  <hr>
   1.505  
   1.506 -<p>To <dfn id="concept-attribute-change" title="concept-attribute-change">change</dfn> an
   1.507 -<a href="#concept-attribute" title="concept-attribute">attribute</a> <var title="">attribute</var> to
   1.508 -<var title="">value</var>, set the <var title="">attribute</var>'s
   1.509 -<a href="#concept-attribute-value" title="concept-attribute-value">value</a> to <var title="">value</var>.
   1.510 -
   1.511  <!-- XXX move append/remove to attribute list? -->
   1.512  <p>To <dfn id="concept-element-attributes-append" title="concept-element-attributes-append">append</dfn> an
   1.513  <a href="#concept-attribute" title="concept-attribute">attribute</a> <var title="">attribute</var> to
   1.514  an <a href="#concept-element" title="concept-element">element</a> <var title="">element</var>,
   1.515 -append the <var title="">attribute</var> to the <var title="">element</var>'s
   1.516 -<a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a>.
   1.517 +run these steps:
   1.518 +
   1.519 +<ol>
   1.520 + <li><p><a href="#concept-mutation-dispatch-attributes" title="concept-mutation-dispatch-attributes">Dispatch</a> an
   1.521 + "<code>attributes</code>" <code><a href="#mutationrecord">MutationRecord</a></code> with <b>target</b>
   1.522 + set to <var title="">element</var>, <b>attributeName</b> set to
   1.523 + <var title="">attribute</var>'s <a href="#dom-attr-localname" title="dom-attr-localname">localName</a>,
   1.524 + <b>attributeNamespace</b> set to <var title="">attribute</var>'s
   1.525 + <a href="#dom-attr-namespaceuri" title="dom-attr-namespaceuri">namespaceURI</a>,
   1.526 + and <b>oldValue</b> set to null.
   1.527 +
   1.528 + <li><p>Append the <var title="">attribute</var> to the <var title="">element</var>'s
   1.529 + <a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a>.
   1.530 +</ol>
   1.531  
   1.532  <p>To <dfn id="concept-element-attributes-remove" title="concept-element-attributes-remove">remove</dfn> an
   1.533  <a href="#concept-attribute" title="concept-attribute">attribute</a> <var title="">attribute</var>
   1.534  from an <a href="#concept-element" title="concept-element">element</a> <var title="">element</var>,
   1.535 -remove the <var title="">attribute</var> from the <var title="">element</var>'s
   1.536 -<a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a>.
   1.537 -
   1.538 -<p class="XXX">These definitions will be expanded upon in due course for
   1.539 -mutations.
   1.540 +run these steps:
   1.541 +
   1.542 +<ol>
   1.543 + <li><p><a href="#concept-mutation-dispatch-attributes" title="concept-mutation-dispatch-attributes">Dispatch</a> an
   1.544 + "<code>attributes</code>" <code><a href="#mutationrecord">MutationRecord</a></code> with <b>target</b>
   1.545 + set to <var title="">element</var>, <b>attributeName</b> set to
   1.546 + <var title="">attribute</var>'s <a href="#dom-attr-localname" title="dom-attr-localname">localName</a>,
   1.547 + <b>attributeNamespace</b> set to <var title="">attribute</var>'s
   1.548 + <a href="#dom-attr-namespaceuri" title="dom-attr-namespaceuri">namespaceURI</a>, and <b>oldValue</b>
   1.549 + set to <var title="">attribute</var>'s <a href="#dom-attr-value" title="dom-attr-value">value</a>.
   1.550 +
   1.551 + <li><p>Remove the <var title="">attribute</var> from the <var title="">element</var>'s
   1.552 + <a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a>.
   1.553 +</ol>
   1.554  
   1.555  <hr>
   1.556  
   1.557 @@ -4508,6 +4750,11 @@
   1.558   than <var title="">length</var> let <var title="">count</var> be
   1.559   <var title="">length</var> minus <var title="">offset</var>.
   1.560  
   1.561 + <li><p><a href="#concept-mutation-dispatch-characterdata" title="concept-mutation-dispatch-characterData">Dispatch</a>
   1.562 + a "<code><a href="#characterdata">characterData</a></code>" <code><a href="#mutationrecord">MutationRecord</a></code> with <b>target</b>
   1.563 + set to <var title="">node</var> and <b>oldValue</b> set to
   1.564 + <var title="">node</var>'s <a href="#concept-cd-data" title="concept-CD-data">data</a>.
   1.565 +
   1.566   <li><p>Insert <var title="">data</var> into <var title="">node</var>'s
   1.567   <a href="#concept-cd-data" title="concept-CD-data">data</a> after <var title="">offset</var>
   1.568   <a class="external" href="http://dev.w3.org/2006/webapi/WebIDL/#dfn-code-unit" title="code unit">code units</a>.
   1.569 @@ -7985,6 +8232,7 @@
   1.570  
   1.571  <p>Thanks to
   1.572  
   1.573 +Adam Klein,
   1.574  Adrian Bateman,
   1.575  Brandon Slade,
   1.576  Cameron McCormack,
     2.1 --- a/Overview.src.html	Mon Feb 06 15:13:20 2012 +0100
     2.2 +++ b/Overview.src.html	Thu Feb 16 22:42:45 2012 +0100
     2.3 @@ -1372,14 +1372,23 @@
     2.4   increase its <span title=concept-range-end-offset>end offset</span> by
     2.5   <var title>count</var>.
     2.6  
     2.7 - <li><p>If <var title>node</var> is a <code>DocumentFragment</code>
     2.8 - <span title=concept-node>node</span>, insert its
     2.9 - <span title=concept-tree-child>children</span> (preserving
    2.10 - <span title=concept-tree-order>tree order</span>), before
    2.11 - <var title>child</var> or at the end of <var title>parent</var> if
    2.12 - <var title>child</var> is null.
    2.13 -
    2.14 - <li><p>Otherwise insert <var title>node</var> before
    2.15 + <li><p>Let <var title>addedNodes</var> be an ordered list of <span title=concept-node>nodes</span>.
    2.16 +
    2.17 + <li><p>If <var title="">node</var> is a <code>DocumentFragment</code>
    2.18 + <span title=concept-node>node</span>, append its
    2.19 + <span title=concept-tree-child>children</span> to <var title>addedNodes</var>
    2.20 + (preserving <span title=concept-tree-order>tree order</span>);
    2.21 + otherwise, append <var title>node</var> to <var title>addedNodes</var>.
    2.22 +
    2.23 + <li><p><span title=concept-mutation-dispatch-childlist>Dispatch</span> a
    2.24 + "<code>childList</code>" mutation with <b>target</b> set to <var title="">parent</var>,
    2.25 + <b>addedNodes</b> set to <var title>addedNodes</var>,
    2.26 + <b>nextSibling</b> set to <var title>child</var>, and <b>previousSibling</b> set to
    2.27 + <var title>child</var>'s <span title=concept-tree-previous-sibling>previous sibling</span>
    2.28 + or to <var title>parent</var>'s <span title=concept-tree-last-child>last child</span>
    2.29 + if <var title>child</var> is null.
    2.30 +
    2.31 + <li><p>Insert all nodes in <var title>addedNodes</var> before
    2.32   <var title>child</var> or at the end of <var title>parent</var> if
    2.33   <var title>child</var> is null.
    2.34  </ol>
    2.35 @@ -1567,6 +1576,21 @@
    2.36   <var title>index</var>, decrease its
    2.37   <span title=concept-range-end-offset>end offset</span> by one.
    2.38  
    2.39 + <li><p><span title=concept-mutation-dispatch-childlist>Dispatch</span> a
    2.40 + "<code>childList</code>" mutation with <b>target</b> set to <var title>parent</var>,
    2.41 + <b>removedNodes</b> set to a <code>NodeList</code> containing only <var title>node</var>,
    2.42 + <b>nextSibling</b> set to <var title>node</var>'s
    2.43 + <span title=concept-tree-next-sibling>next sibling</span>,
    2.44 + and <b>previousSibling</b> set to <var title>node</var>'s
    2.45 + <span title=concept-tree-previous-sibling>previous sibling</span>.
    2.46 +
    2.47 + <li><p>For each <span title=concept-tree-ancestor>ancestor</span> <var title>ancestor</var>
    2.48 + of <var title>node</var>, if <var title>ancestor</var> has any
    2.49 + <span title=registered-observer>registered observers</span> with the <code>subtree</code>
    2.50 + option set, <span title=concept-add-transient-observer>add</span>
    2.51 + an identical <span>transient observer</span> to <var title>node</var> for
    2.52 + each such subtree <span title=registered-observer>registration</span> on <var title>ancestor</var>.
    2.53 +
    2.54   <li><p>Remove <var title>node</var> from its <var title>parent</var>.
    2.55  </ol>
    2.56  
    2.57 @@ -1717,74 +1741,258 @@
    2.58  
    2.59  <h4>Mutation observers</h4>
    2.60  
    2.61 -<p class=XXX>This section will define the replacement for the
    2.62 -"Mutation Events" feature of the platform. For now it contains the interface
    2.63 -being implemented by vendors.
    2.64 -
    2.65  <pre class="idl">[Constructor(<span>MutationCallback</span> callback)]
    2.66  interface <dfn>MutationObserver</dfn> {
    2.67 -  void observe(<span>Node</span> target, <span>MutationObserverInit</span> options);
    2.68 -  void disconnect();
    2.69 +  void <span title=dom-MutationObserver-observe>observe</span>(<span>Node</span> target, <span>MutationObserverInit</span> options);
    2.70 +  void <span title=dom-MutationObserver-disconnect>disconnect</span>();
    2.71  };
    2.72  
    2.73  callback <dfn>MutationCallback</dfn> = void (<span>MutationRecord</span>[] mutations, <span>MutationObserver</span> observer);
    2.74  
    2.75  dictionary <dfn>MutationObserverInit</dfn> {
    2.76 -  // Mutation types
    2.77 -  boolean childList;     // If true, mutations affecting node’s childNodes are included.
    2.78 -  boolean attributes;    // If true, mutations affecting element’s attributes are included.
    2.79 -  boolean characterData; // If true, mutations affecting the value of CharacterData nodes are included.
    2.80 -  // [Note: If none of the known mutation types is specified, an Error is thrown]
    2.81 -
    2.82 -  // Subtree observation
    2.83 -  boolean subtree;  // If true, the observed set of nodes for this registration should include
    2.84 -                    // descendants of MutationTarget (behavior described below).
    2.85 -
    2.86 -  // Old values
    2.87 -  boolean attributeOldValue;
    2.88 -  // If true, MutationRecords describing changes to attributes should
    2.89 -  // contain the value of the attribute before the change. If true
    2.90 -  // without attribute: true specified, an Error is thrown.
    2.91 -
    2.92 -  boolean characterDataOldValue;
    2.93 -  // If true, MutationRecords describing changes to
    2.94 -  // CharacterData nodes should contain the value
    2.95 -  // of the node before the change. If true without
    2.96 -  // characterData: true, an Error is thrown.
    2.97 -
    2.98 -  // Filtering
    2.99 -  DOMString[] attributeFilter;
   2.100 -  // If provided, only changes to attributes with localName equaling
   2.101 -  // one of the provided strings will be delivered. If provided without
   2.102 -  // attribute: true, an Error is thrown.
   2.103 +  boolean <span title=dom-MutationObserverInit-childlist>childList</span>;
   2.104 +  boolean <span title=dom-MutationObserverInit-attributes>attributes</span>;
   2.105 +  boolean <span title=dom-MutationObserverInit-characterdata>characterData</span>;
   2.106 +  boolean <span title=dom-MutationObserverInit-subtree>subtree</span>;
   2.107 +  boolean <span title=dom-MutationObserverInit-attributeoldvalue>attributeOldValue</span>;
   2.108 +  boolean <span title=dom-MutationObserverInit-characterdataoldvalue>characterDataOldValue</span>;
   2.109 +  DOMString[] <span title=dom-MutationObserverInit-attributefilter>attributeFilter</span>;
   2.110  };
   2.111  
   2.112  interface <dfn>MutationRecord</dfn> {
   2.113 -  // Mutation type: one of 'childList', 'attributes', or 'characterData'
   2.114 -  readonly attribute DOMString type;
   2.115 -
   2.116 -  // For childList and attributes, target is the owner node affected.
   2.117 -  // For CharacterData, target is the node affected.
   2.118 -  readonly attribute <span>Node</span> target;
   2.119 -
   2.120 -  // For type == 'childList', Sequence of added and removed nodes in this operation.
   2.121 -  readonly attribute <span>NodeList</span> addedNodes;
   2.122 -  readonly attribute <span>NodeList</span> removedNodes;
   2.123 -
   2.124 -  // For type == 'childList', The siblings in childNodes immediately preceding following the first
   2.125 -  // and last nodes added and/or removed.
   2.126 -  readonly attribute <span>Node</span> previousSibling;
   2.127 -  readonly attribute <span>Node</span> nextSibling;
   2.128 -
   2.129 -  // For type == 'attribute', the name and namespaceURI of the attribute affected
   2.130 -  readonly attribute DOMString attributeName;
   2.131 -  readonly attribute DOMString attributeNamespace;
   2.132 -
   2.133 -  // For type == 'attribute' or 'characterData', if requested, the value immediately
   2.134 -  // preceding the mutation.
   2.135 -  readonly attribute DOMString oldValue;
   2.136 +  readonly attribute DOMString <span title=dom-MutationRecord-type>type</span>;
   2.137 +  readonly attribute <span>Node</span> <span title=dom-MutationRecord-target>target</span>;
   2.138 +  readonly attribute <span>NodeList</span>? <span title=dom-MutationRecord-addedNodes>addedNodes</span>;
   2.139 +  readonly attribute <span>NodeList</span>? <span title=dom-MutationRecord-removedNodes>removedNodes</span>;
   2.140 +  readonly attribute <span>Node</span>? <span title=dom-MutationRecord-previousSibling>previousSibling</span>;
   2.141 +  readonly attribute <span>Node</span>? <span title=dom-MutationRecord-nextSibling>nextSibling</span>;
   2.142 +  readonly attribute DOMString? <span title=dom-MutationRecord-attributeName>attributeName</span>;
   2.143 +  readonly attribute DOMString? <span title=dom-MutationRecord-attributeNamespace>attributeNamespace</span>;
   2.144 +  readonly attribute DOMString? <span title=dom-MutationRecord-oldValue>oldValue</span>;
   2.145  };</pre>
   2.146 -<!-- XXX remove inline comments when this is defined -->
   2.147 +
   2.148 +<p>When the constructor of the <code>MutationObserver</code> interface is invoked
   2.149 +with callback <var title>callback</var> and options <var title>options</var>, run these steps:
   2.150 +
   2.151 +<ol>
   2.152 +  <li><p>If <var title>callback</var> is null, <span title=concept-throw>throw</span> a "<code>NotFoundError</code>" and terminate these steps.
   2.153 +  <li><p>Return a <code>MutationObserver</code> <span title=mutation-observer-associated-callback>associated</span> with the callback.
   2.154 +</ol>
   2.155 +
   2.156 +Besides the properties listed in the IDL for <code>MutationObserver</code>, it has three internal properties:
   2.157 +<ul>
   2.158 +  <li><p>An <dfn title=mutation-observer-associated-callback>associated callback</dfn>.
   2.159 +  <li><p>A list of <span title=concept-node>nodes</span> on which it is <span title=registered-observer>registered</span>.
   2.160 +  <li><p>A queue of <code>MutationRecord</code>s which are <dfn title=mutation-observer-pending>pending</dfn> delivery.
   2.161 +</ul>
   2.162 +
   2.163 +<hr>
   2.164 +
   2.165 +<p>A <dfn title=registered-observer>registered observer</dfn> consists of an <b>observer</b> (an instance of <code>MutationObserver</code>),
   2.166 +a set of <b>options</b> (an instance of <code>MutationObserverInit</code>), and a <b>transient</b> variable (whose default value is false).
   2.167 +Each <code>Node</code> has a list of registered observers. A <dfn>transient observer</dfn> is a <span title=registered-observer>registered observer</span>
   2.168 +whose <b>transient</b> variable is set to true.
   2.169 +<!-- XXX Need a cross-reference from the microtask processing model explaining when to remove transient observers -->
   2.170 +
   2.171 +<hr>
   2.172 +
   2.173 +<p>When the <dfn title=dom-MutationObserver-observe><code>observe(<var title>target</var>, <var title>options</var>)</code></dfn>
   2.174 +method is called, these steps must be run:
   2.175 +
   2.176 +<ol>
   2.177 +  <li><p>If <var title>target</var> is not a <span title=concept-node>node</span>,
   2.178 +  <span title=concept-throw>throw</span> a "<code>NotFoundError</code>" and terminate these steps.
   2.179 +
   2.180 +  <li><p>If <var title>options</var> is null, or is not an instance of <code>MutationObserverInit</code>,
   2.181 +  <span title=concept-throw>throw</span> a "<code>TypeMismatchError</code>" and terminate these steps.
   2.182 +
   2.183 +  <li><p>Run these substeps, treating <var title>options</var> as the <span>context object</span>:
   2.184 +  <ol>
   2.185 +    <li><p>If neither <code>childList</code>, <code>attributes</code>, nor <code>characterData</code> is true,
   2.186 +    <span title=concept-throw>throw</span> a "<code>SyntaxError</code>" and terminate these steps.
   2.187 +
   2.188 +    <li><p>If <code>attributeOldValue</code> is true and <code>attributes</code> is not true,
   2.189 +    <span title=concept-throw>throw</span> a "<code>SyntaxError</code>" and terminate these steps.
   2.190 +
   2.191 +    <li><p>If <code>attributeFilter</code> is a non-empty array and <code>attributes</code> is not true,
   2.192 +    <span title=concept-throw>throw</span> a "<code>SyntaxError</code>" and terminate these steps.
   2.193 +
   2.194 +    <li><p>If <code>characterDataOldValue</code> is true and <code>characterData</code> is not true,
   2.195 +    <span title=concept-throw>throw</span> a "<code>SyntaxError</code>" and terminate these steps.
   2.196 +  </ol>
   2.197 +
   2.198 +  <li><p>If <var title>target</var>'s registration list already includes a registration associated with
   2.199 +  the <span>context object</span>, replace that registrations's options with <var title>options</var>.
   2.200 +
   2.201 +  <li><p>Otherwise, add a new <span title=registered-observer>registration</span> to <var title>target</var>'s registered observer list with the
   2.202 +  <span>context object</span> as the <var title>observer</var> and <var title>options</var> as the options,
   2.203 +  and add <var title>target</var> to <var title>observer</var>'s list of nodes on which it is registered.
   2.204 +</ol>
   2.205 +
   2.206 +<p>When the <dfn title=dom-MutationObserver-disconnect><code>disconnect</code></dfn> method is called, for each
   2.207 +<span title=concept-node>node</span> <var title>node</var> in the <span>context object</span>'s list of
   2.208 +<span title=concept-node>nodes</span>, remove any <span title=registered-observer>registration</span> on <var title>node</var> for which
   2.209 +the <span>context object</span> is the <b>observer</b>.
   2.210 +
   2.211 +<h4>Mutation observation algorithms</h4>
   2.212 +
   2.213 +To <dfn title=concept-mutation-dispatch-attributes>dispatch</dfn> an "<code>attributes</code>" MutationRecord
   2.214 +with target <var title>target</var>, attributeName <var title>name</var>, and oldValue <var title>oldValue</var>,
   2.215 +run these steps:
   2.216 +
   2.217 +<ol>
   2.218 +<li><p>Create a new MutationRecord <var title>record</var> with type initialized to "<code>attributes</code>", target initialized to <var title>target</var>,
   2.219 +and attributeName initialized to <var title>name</var>.
   2.220 +
   2.221 +<li><p>Create a copy of this record named <var title>recordWithOldValue</var> and initialize its oldValue to <var title>oldValue</var>.
   2.222 +
   2.223 +<li><p>For each <span title=registered-observer>registered observer</span> <var title>observer</var> (with options <var title>options</var>) in
   2.224 +
   2.225 +<var title>target</var>'s registered observer list, run these substeps:
   2.226 +  <ol>
   2.227 +    <li><p>If <var title>options</var> does not have the <code>attributes</code> option set, terminate these substeps (and run them for the next observer).
   2.228 +
   2.229 +    <li><p>If <var title>options</var> has a non-empty <code>attributeFilter</code> array, and <var title>name</var> is not in that array, terminate these substeps
   2.230 +    (and run them for the next observer).
   2.231 +
   2.232 +    <li><p>If <var title>options</var> has the <code>attributeOldValue</code> option set, append <var title>recordWithOldValue</var> to the observer's
   2.233 +    queue of pending mutations.
   2.234 +
   2.235 +    <li><p>Otherwise, append <var title>record</var> to the observer's queue of pending mutations.
   2.236 +    </ol>
   2.237 +     <li><p>For each <span title=concept-tree-ancestor>ancestor</span> <var title>ancestor</var> of target, and for each
   2.238 +     <span title=registered-observer>registered observer</span> <var title>observer</var> (with options <var title>options</var>) in <var title>ancestor</var>'s
   2.239 +     registered observer list, run these substeps:
   2.240 +    <ol>
   2.241 +
   2.242 +    <li><p>If <var title>options</var> does not have the <code>subtree</code> option set, terminate these substeps (and run them for the next observer).
   2.243 +
   2.244 +    <li><p>If <var title>options</var> does not have the <code>attributes</code> option set, terminate these substeps (and run them for the next observer).
   2.245 +
   2.246 +    <li><p>If <var title>options</var> has a non-empty <code>attributeFilter</code> array, and <var title>name</var> is not in that array, terminate these substeps
   2.247 +    (and run them for the next observer).
   2.248 +
   2.249 +    <li><p>If <var title>options</var> has the <code>attributeOldValue</code> option set, append <var title>recordWithOldValue</var> to the observer's
   2.250 +    queue of pending mutations.
   2.251 +
   2.252 +    <li><p>Otherwise, append <var title>record</var> to the observer's queue of <span title=mutation-observer-pending>pending</span> mutations.
   2.253 +  </ol>
   2.254 +</ol>
   2.255 +
   2.256 +To <dfn title=concept-mutation-dispatch-characterData>dispatch</dfn> a "<code>characterData</code>" MutationRecord
   2.257 +with target <var title>target</var> and oldValue <var title>oldValue</var>, run these steps:
   2.258 +
   2.259 +<ol>
   2.260 + <li><p>Create a new MutationRecord <var title>record</var> with type initialized to "<code>characterData</code>" and target initialized to <var title>target</var>.
   2.261 +
   2.262 + <li><p>Create a copy of this record named <var title>recordWithOldValue</var> and initialize its oldValue to <var title>oldValue</var>.
   2.263 +
   2.264 + <li><p>For each <span title=registered-observer>registered observer</span> <var title>observer</var> (with options <var title>options</var>) in
   2.265 + <var title>target</var>'s registered observer list, run these substeps:
   2.266 +   <ol>
   2.267 +    <li><p>If <var title>options</var> does not have the <code>characterData</code> option set, terminate these substeps (and run them for the next observer).
   2.268 +
   2.269 +    <li><p>If <var title>options</var> has the <code>characterDataOldValue</code> option set, append <var title>recordWithOldValue</var> to the observer's
   2.270 +    queue of pending mutations.
   2.271 +
   2.272 +    <li><p>Otherwise, append <var title>record</var> to the observer's queue of pending mutations.
   2.273 +   </ol>
   2.274 +
   2.275 + <li><p>For each <span title=concept-tree-ancestor>ancestor</span> <var title>ancestor</var> of target, and for each
   2.276 + <span title=registered-observer>registered observer</span> <var title>observer</var> (with options <var title>options</var>) in <var title>ancestor</var>'s
   2.277 + registered observer list, run these substeps:
   2.278 + <ol>
   2.279 +  <li><p>If <var title>options</var> does not have the <code>subtree</code> option set, terminate these substeps (and run them for the next observer).
   2.280 +
   2.281 +  <li><p>If <var title>options</var> does not have the <code>characterData</code> option set, terminate these substeps (and run them for the next observer).
   2.282 +
   2.283 +  <li><p>If <var title>options</var> has the <code>characterDataOldValue</code> option set, append <var title>recordWithOldValue</var> to the observer's
   2.284 +    queue of pending mutations.
   2.285 +
   2.286 +  <li><p>Otherwise, append <var title>record</var> to the observer's queue of <span title=mutation-observer-pending>pending</span> mutations.
   2.287 + </ol>
   2.288 +</ol>
   2.289 +
   2.290 +To <dfn title=concept-mutation-dispatch-childList>dispatch</dfn> a "<code>childList</code>" MutationRecord
   2.291 +with target <var title>target</var>, addedNodes <var title>addedNodes</var>, removedNodes <var title>removedNodes</var>, previousSibling <var title>previousSibling</var>,
   2.292 +and nextSibling <var title>nextSibling</var>, run these steps:
   2.293 +
   2.294 +<ol>
   2.295 + <li><p>Create a new MutationRecord <var title>record</var> with type initialized to "<code>childList</code>", target initialized to <var title>target</var>,
   2.296 + addedNodes initialized to <var title>addedNodes</var>, removedNodes initialized to <var title>removedNodes</var>,
   2.297 + previousSibling initialized to <var title>previousSibling</var>, and nextSibling initialized to.
   2.298 +
   2.299 + <li><p>For each <span title=registered-observer>registered observer</span> <var title>observer</var> (with options <var title>options</var>) in
   2.300 + <var title>target</var>'s registered observer list, run these substeps:
   2.301 + <ol>
   2.302 +  <li><p>If <var title>options</var> does not have the <code>childList</code> option set, terminate these substeps (and run them for the next observer).
   2.303 +
   2.304 +  <li><p>Append <var title>record</var> to the observer's queue of pending mutations.
   2.305 + </ol>
   2.306 +
   2.307 + <li><p>For each <span title=concept-tree-ancestor>ancestor</span> <var title>ancestor</var> of target, and for each
   2.308 + <span title=registered-observer>registered observer</span> <var title>observer</var> (with options <var title>options</var>) in <var title>ancestor</var>'s
   2.309 + registered observer list, run these substeps:
   2.310 + <ol>
   2.311 +  <li><p>If <var title>options</var> does not have the <code>subtree</code> option set, terminate these substeps (and run them for the next observer).
   2.312 +
   2.313 +  <li><p>If <var title>options</var> does not have the <code>childList</code> option set, terminate these substeps (and run them for the next observer).
   2.314 +
   2.315 +  <li><p>Append <var title>record</var> to the observer's queue of <span title=mutation-observer-pending>pending</span> mutations.
   2.316 + </ol>
   2.317 +</ol>
   2.318 +
   2.319 +To <dfn title=concept-add-transient-observer>add a transient observer</dfn> <var title>observer</var> with options <var title>options</var>
   2.320 +to a <span title=concept-node>node</span> <var title>node</var>, create a new <span title=registered-observer>registration</span> with <b>observer</b> set to
   2.321 +<var title>observer</var>, <b>options</b> set to <var title>options</var>, and <b>transient</b> set to true and append it to <var title>node</var>'s
   2.322 +list of <span title=registered-observer>registered observers</span>.
   2.323 +
   2.324 +<h4>MutationRecord attributes</h4>
   2.325 +
   2.326 +<p>The <dfn title=dom-MutationRecord-type><code>type</code></dfn> attribute must return
   2.327 +a string representing the type of the mutation, which must be one of the following:
   2.328 +<ul>
   2.329 +  <li>"<dfn title=dom-MutationRecord-type-attributes><code>attributes</code></dfn>"
   2.330 +  <li>"<dfn title=dom-MutationRecord-type-childList><code>childList</code></dfn>"
   2.331 +  <li>"<dfn title=dom-MutationRecord-type-characterData><code>characterData</code></dfn>"
   2.332 +</ul>
   2.333 +
   2.334 +<p>The <dfn title=dom-MutationRecord-target><code>target</code></dfn> attribute must
   2.335 +return the node this mutation affected, which differs depending on the <span title=mutation-record-type>type</span>.
   2.336 +For childList mutations, it must be the node whose children changed.
   2.337 +For attributes mutations, it must be the element whose attributes changed.
   2.338 +For characterData mutations, it must be the <code>CharacterData</code> node whose value changed.
   2.339 +
   2.340 +<p>The <dfn title=dom-MutationRecord-addedNodes><code>addedNodes</code></dfn> attribute must return
   2.341 +the list of nodes added in this mutation, if it was a childList mutation. Otherwise it must return null.
   2.342 +
   2.343 +<p>The <dfn title=dom-MutationRecord-removedNodes><code>removedNodes</code></dfn> attribute must return
   2.344 +the list of nodes removed in this mutation, if it was a childList mutation. Otherwise it must return null.
   2.345 +
   2.346 +<p>The <dfn title=dom-MutationRecord-previousSibling><code>previousSibling</code></dfn> attribute must return
   2.347 +the node which was the <span title=concept-tree-previous-sibling>previous sibling</span> of the first element of addedNodes when the mutation occurred, if addedNodes is non-empty,
   2.348 +or the node which was the <span title=concept-tree-previous-sibling>previous sibling</span> of the first element of removedNodes, if removedNodes is non-empty. Otherwise it must return null.
   2.349 +
   2.350 +<p>The <dfn title=dom-MutationRecord-nextSibling><code>nextSibling</code></dfn> attribute must return
   2.351 +the node which was the <span title=concept-tree-next-sibling>next sibling</span> of the last item in addedNodes when the mutation occurred, if addedNodes is non-empty,
   2.352 +or the node which was the <span title=concept-tree-next-sibling>next sibling</span> of the last element of removedNodes, if removedNodes is non-empty. Otherwise it must return null.
   2.353 +
   2.354 +<p>The <dfn title=dom-MutationRecord-attributeName><code>attributeName</code></dfn> attribute must return
   2.355 +the <code title=dom-attr-name>name</code> of the modified attribute if this is an "<code>attributes</code>" mutation. Otherwise it must return null.
   2.356 +
   2.357 +<p>The <dfn title=dom-MutationRecord-attributeNamespace><code>attributeNamespace</code></dfn> attribute must return
   2.358 +the <code title=dom-attr-namespaceuri>namespaceURI</code> of the modified attribute if this is an "<code>attributes</code>" mutation. Otherwise it must return null.
   2.359 +
   2.360 +<p>The <dfn title=dom-MutationRecord-oldValue><code>oldValue</code></dfn> attribute varies in behavior
   2.361 +based on the <span title=dom-MutationRecord-type>type</span> of mutation:
   2.362 +
   2.363 +<ul>
   2.364 +  <li><p>If type is "<code>childList</code>", it must return null.
   2.365 +  <li><p>If type is "<code>attributes</code>" and the registered observation had the attributeOldValue option set, must return
   2.366 +  the <span title=dom-attr-value>value</span> of the <span title=attr>attribute</span> just before the mutation was made.
   2.367 +  <li><p>If type is "<code>characterData</code>" and the registered observation had the characterDataOldValue option set, must return the value of
   2.368 +  the <span title=dom-MutationRecord-target>target</span>'s <span title=dom-characterdata-data>data</span> attribute just before the mutation was made.
   2.369 +</ul>
   2.370  
   2.371  
   2.372  <h3>Interface <code>Node</code></h3>
   2.373 @@ -3386,7 +3594,7 @@
   2.374   <span>affected by a base URL change</span>.
   2.375  
   2.376   <li><p>If <var title>node</var>'s
   2.377 - <span title=concept-tree-parent>parent</span> is not null, remove
   2.378 + <span title=concept-tree-parent>parent</span> is not null, <span title=concept-node-remove>remove</span>
   2.379   <var title>node</var> from its
   2.380   <span title=concept-tree-parent>parent</span>.
   2.381  
   2.382 @@ -4130,24 +4338,29 @@
   2.383   <var title>name</var>, <span title=concept-throw>throw</span> a
   2.384   "<code>NamespaceError</code>" and terminate these steps.
   2.385  
   2.386 - <li><p>If the <span>context object</span> does not have an
   2.387 + <li><p>Let <var title>attribute</var> be the
   2.388 + first <span title=concept-attribute>attribute</span> in the
   2.389 + <span>context object</span>'s <span title=concept-element-attribute>attribute list</span>
   2.390 + whose <span title=concept-attribute-name>name</span> is
   2.391 + <var title>name</var>, or null if there is no such
   2.392 + <span title=concept-attribute>attribute</span>.
   2.393 +
   2.394 + <li><p>If <var title>attribute</var> is null, create an
   2.395   <span title=concept-attribute>attribute</span> whose
   2.396   <span title=concept-attribute-name>name</span> is
   2.397 - <var title>name</var>, create an
   2.398 - <span title=concept-attribute>attribute</span>, whose
   2.399 - <span title=concept-attribute-name>name</span> is
   2.400   <var title>name</var> and
   2.401   <span title=concept-attribute-value>value</span> is <var title>value</var>,
   2.402   and then <span title=concept-element-attributes-append>append</span> this
   2.403   <span title=concept-attribute>attribute</span> to the
   2.404 - <span>context object</span>.
   2.405 -
   2.406 - <li><p>Otherwise, <span title=concept-attribute-change>change</span> the
   2.407 - first <span title=concept-attribute>attribute</span> in the
   2.408 - <span>context object</span>'s
   2.409 - <span title=concept-element-attribute>attribute list</span> whose
   2.410 - <span title=concept-attribute-name>name</span> is
   2.411 - <var title>name</var>, to <var title>value</var>.
   2.412 + <span>context object</span> and terminate these steps.
   2.413 +
   2.414 + <li><p><span title=concept-mutation-dispatch-attributes>Dispatch</span> an "<code>attributes</code>"
   2.415 + <code>MutationRecord</code> with <b>target</b> set to the <span>context object</span>,
   2.416 + <b>attributeName</b> set to <var title>attribute</var>'s <span title=dom-attr-localname>localName</span>,
   2.417 + <b>attributeNamespace</b> set to <var title>attribute</var>'s <span title=dom-attr-namespaceuri>namespaceURI</span>,
   2.418 + and <b>oldValue</b> set to <var title>attribute</var>'s <span title=dom-attr-value>value</span>.
   2.419 +
   2.420 + <li><p>Set <var title>attribute</var>'s <span title=concept-attribute-value>value</span> to <var title>value</var>.
   2.421  </ol>
   2.422  
   2.423  <p>The
   2.424 @@ -4193,14 +4406,18 @@
   2.425   "<code title>xmlns</code>", <span title=concept-throw>throw</span> a
   2.426   "<code>NamespaceError</code>" exception and terminate these steps.
   2.427  
   2.428 - <li><p>If the <span>context object</span> does not
   2.429 - <span title=concept-element-attribute-has>have</span> an
   2.430 + <li><p>Let <var title>attribute</var> be the
   2.431 + first <span title=concept-attribute>attribute</span> in the
   2.432 + <span>context object</span>'s
   2.433 + <span title=concept-element-attribute>attribute list</span>
   2.434 + whose <span title=concept-attribute-namespace>namespace</span> is
   2.435 + <var title>namespace</var> and whose
   2.436 + <span title=concept-attribute-local-name>local name</span>
   2.437 + is <var title>localName</var>, or null if there is no such
   2.438 + <span title=concept-attribute>attribute</span>.
   2.439 +
   2.440 + <li><p>If <var title="">attribute</var> is null, create an
   2.441   <span title=concept-attribute>attribute</span> whose
   2.442 - <span title=concept-attribute-namespace>namespace</span> is
   2.443 - <var title>namespace</var> and
   2.444 - <span title=concept-attribute-local-name>local name</span> is
   2.445 - <var title>localName</var>, create an
   2.446 - <span title=concept-attribute>attribute</span>, whose
   2.447   <span title=concept-attribute-name>name</span> is
   2.448   <var title>name</var>,
   2.449   <span title=concept-attribute-namespace>namespace</span> is
   2.450 @@ -4212,10 +4429,17 @@
   2.451   is <var title>value</var>, and then
   2.452   <span title=concept-element-attributes-append>append</span> this
   2.453   <span title=concept-attribute>attribute</span> to the
   2.454 - <span>context object</span>.
   2.455 -
   2.456 - <li><p>Otherwise, <span title=concept-attribute-change>change</span> that
   2.457 - <span title=concept-attribute>attribute</span> to <var title>value</var>.
   2.458 + <span>context object</span> and terminate these steps.
   2.459 +
   2.460 + <li><p><span title=concept-mutation-dispatch-attributes>Dispatch</span> an
   2.461 + "<code>attributes</code>" <code>MutationRecord</code> with <b>target</b>
   2.462 + set to the <span>context object</span>, <b>attributeName</b> set to
   2.463 + <var title>name</var>, <b>attributeNamespace</b> set to
   2.464 + <var title>namespace</var>, and <b>oldValue</b> set to
   2.465 + <var title>attribute</var>'s <span title=dom-attr-value>value</span>.
   2.466 +
   2.467 + <li><p>Set <var title>attribute</var>'s
   2.468 + <span title=concept-attribute-value>value</span> to <var title>value</var>.
   2.469  </ol>
   2.470  
   2.471  <p>The
   2.472 @@ -4432,26 +4656,42 @@
   2.473  
   2.474  <hr>
   2.475  
   2.476 -<p>To <dfn title=concept-attribute-change>change</dfn> an
   2.477 -<span title=concept-attribute>attribute</span> <var title>attribute</var> to
   2.478 -<var title>value</var>, set the <var title>attribute</var>'s
   2.479 -<span title=concept-attribute-value>value</span> to <var title>value</var>.
   2.480 -
   2.481  <!-- XXX move append/remove to attribute list? -->
   2.482  <p>To <dfn title=concept-element-attributes-append>append</dfn> an
   2.483  <span title=concept-attribute>attribute</span> <var title>attribute</var> to
   2.484  an <span title=concept-element>element</span> <var title>element</var>,
   2.485 -append the <var title>attribute</var> to the <var title>element</var>'s
   2.486 -<span title=concept-element-attribute>attribute list</span>.
   2.487 +run these steps:
   2.488 +
   2.489 +<ol>
   2.490 + <li><p><span title=concept-mutation-dispatch-attributes>Dispatch</span> an
   2.491 + "<code>attributes</code>" <code>MutationRecord</code> with <b>target</b>
   2.492 + set to <var title>element</var>, <b>attributeName</b> set to
   2.493 + <var title>attribute</var>'s <span title=dom-attr-localname>localName</span>,
   2.494 + <b>attributeNamespace</b> set to <var title>attribute</var>'s
   2.495 + <span title=dom-attr-namespaceuri>namespaceURI</span>,
   2.496 + and <b>oldValue</b> set to null.
   2.497 +
   2.498 + <li><p>Append the <var title>attribute</var> to the <var title="">element</var>'s
   2.499 + <span title=concept-element-attribute>attribute list</span>.
   2.500 +</ol>
   2.501  
   2.502  <p>To <dfn title=concept-element-attributes-remove>remove</dfn> an
   2.503  <span title=concept-attribute>attribute</span> <var title>attribute</var>
   2.504  from an <span title=concept-element>element</span> <var title>element</var>,
   2.505 -remove the <var title>attribute</var> from the <var title>element</var>'s
   2.506 -<span title=concept-element-attribute>attribute list</span>.
   2.507 -
   2.508 -<p class=XXX>These definitions will be expanded upon in due course for
   2.509 -mutations.
   2.510 +run these steps:
   2.511 +
   2.512 +<ol>
   2.513 + <li><p><span title=concept-mutation-dispatch-attributes>Dispatch</span> an
   2.514 + "<code>attributes</code>" <code>MutationRecord</code> with <b>target</b>
   2.515 + set to <var title>element</var>, <b>attributeName</b> set to
   2.516 + <var title>attribute</var>'s <span title=dom-attr-localname>localName</span>,
   2.517 + <b>attributeNamespace</b> set to <var title>attribute</var>'s
   2.518 + <span title=dom-attr-namespaceuri>namespaceURI</span>, and <b>oldValue</b>
   2.519 + set to <var title>attribute</var>'s <span title=dom-attr-value>value</span>.
   2.520 +
   2.521 + <li><p>Remove the <var title>attribute</var> from the <var title>element</var>'s
   2.522 + <span title=concept-element-attribute>attribute list</span>.
   2.523 +</ol>
   2.524  
   2.525  <hr>
   2.526  
   2.527 @@ -4520,6 +4760,11 @@
   2.528   than <var title>length</var> let <var title>count</var> be
   2.529   <var title>length</var> minus <var title>offset</var>.
   2.530  
   2.531 + <li><p><span title=concept-mutation-dispatch-characterData>Dispatch</span>
   2.532 + a "<code>characterData</code>" <code>MutationRecord</code> with <b>target</b>
   2.533 + set to <var title>node</var> and <b>oldValue</b> set to
   2.534 + <var title>node</var>'s <span title=concept-CD-data>data</span>.
   2.535 +
   2.536   <li><p>Insert <var title>data</var> into <var title>node</var>'s
   2.537   <span title=concept-CD-data>data</span> after <var title>offset</var>
   2.538   <span data-anolis-spec=webidl title="code unit">code units</span>.
   2.539 @@ -8013,6 +8258,7 @@
   2.540  
   2.541  <p>Thanks to
   2.542  
   2.543 +Adam Klein,
   2.544  Adrian Bateman,
   2.545  Brandon Slade,
   2.546  Cameron McCormack,
     3.1 --- a/dom-core.html	Mon Feb 06 15:13:20 2012 +0100
     3.2 +++ b/dom-core.html	Thu Feb 16 22:42:45 2012 +0100
     3.3 @@ -13,8 +13,8 @@
     3.4  
     3.5  <div class="head">
     3.6  <h1>DOM4</h1>
     3.7 - <h2 class="no-num no-toc" id="free-editor's-draft-6-february-2012">
     3.8 -  <span class="now3c">Free Editor's Draft 6 February 2012</span>
     3.9 + <h2 class="no-num no-toc" id="free-editor's-draft-16-february-2012">
    3.10 +  <span class="now3c">Free Editor's Draft 16 February 2012</span>
    3.11   </h2>
    3.12  
    3.13   <dl>
    3.14 @@ -42,7 +42,7 @@
    3.15  <p class="dontpublish copyright"><a href="http://creativecommons.org/publicdomain/zero/1.0/" rel="license"><img alt="CC0" src="http://i.creativecommons.org/p/zero/1.0/80x15.png"></a>
    3.16  To the extent possible under law, the editors have waived all copyright and
    3.17  related or neighboring rights to this work. In addition, as of
    3.18 -6 February 2012, the editors have made this specification available
    3.19 +16 February 2012, the editors have made this specification available
    3.20  under the
    3.21  <a href="http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0" rel="license">Open Web Foundation Agreement Version 1.0</a>,
    3.22  which is available at
    3.23 @@ -92,7 +92,9 @@
    3.24       <li><a href="#mutation-algorithms"><span class="secno">5.1.1 </span>Mutation algorithms</a></li>
    3.25       <li><a href="#mutation-methods"><span class="secno">5.1.2 </span>Mutation methods</a></li>
    3.26       <li><a href="#legacy-mutation-methods"><span class="secno">5.1.3 </span>Legacy mutation methods</a></li>
    3.27 -     <li><a href="#mutation-observers"><span class="secno">5.1.4 </span>Mutation observers</a></ol></li>
    3.28 +     <li><a href="#mutation-observers"><span class="secno">5.1.4 </span>Mutation observers</a></li>
    3.29 +     <li><a href="#mutation-observation-algorithms"><span class="secno">5.1.5 </span>Mutation observation algorithms</a></li>
    3.30 +     <li><a href="#mutationrecord-attributes"><span class="secno">5.1.6 </span>MutationRecord attributes</a></ol></li>
    3.31     <li><a href="#interface-node"><span class="secno">5.2 </span>Interface <code>Node</code></a></li>
    3.32     <li><a href="#interface-document"><span class="secno">5.3 </span>Interface <code>Document</code></a>
    3.33      <ol>
    3.34 @@ -1332,14 +1334,23 @@
    3.35   increase its <a href="#concept-range-end-offset" title="concept-range-end-offset">end offset</a> by
    3.36   <var title="">count</var>.
    3.37  
    3.38 + <li><p>Let <var title="">addedNodes</var> be an ordered list of <a href="#concept-node" title="concept-node">nodes</a>.
    3.39 +
    3.40   <li><p>If <var title="">node</var> is a <code><a href="#documentfragment">DocumentFragment</a></code>
    3.41 - <a href="#concept-node" title="concept-node">node</a>, insert its
    3.42 - <a href="#concept-tree-child" title="concept-tree-child">children</a> (preserving
    3.43 - <a href="#concept-tree-order" title="concept-tree-order">tree order</a>), before
    3.44 - <var title="">child</var> or at the end of <var title="">parent</var> if
    3.45 - <var title="">child</var> is null.
    3.46 -
    3.47 - <li><p>Otherwise insert <var title="">node</var> before
    3.48 + <a href="#concept-node" title="concept-node">node</a>, append its
    3.49 + <a href="#concept-tree-child" title="concept-tree-child">children</a> to <var title="">addedNodes</var>
    3.50 + (preserving <a href="#concept-tree-order" title="concept-tree-order">tree order</a>);
    3.51 + otherwise, append <var title="">node</var> to <var title="">addedNodes</var>.
    3.52 +
    3.53 + <li><p><a href="#concept-mutation-dispatch-childlist" title="concept-mutation-dispatch-childlist">Dispatch</a> a
    3.54 + "<code>childList</code>" mutation with <b>target</b> set to <var title="">parent</var>,
    3.55 + <b>addedNodes</b> set to <var title="">addedNodes</var>,
    3.56 + <b>nextSibling</b> set to <var title="">child</var>, and <b>previousSibling</b> set to
    3.57 + <var title="">child</var>'s <a href="#concept-tree-previous-sibling" title="concept-tree-previous-sibling">previous sibling</a>
    3.58 + or to <var title="">parent</var>'s <a href="#concept-tree-last-child" title="concept-tree-last-child">last child</a>
    3.59 + if <var title="">child</var> is null.
    3.60 +
    3.61 + <li><p>Insert all nodes in <var title="">addedNodes</var> before
    3.62   <var title="">child</var> or at the end of <var title="">parent</var> if
    3.63   <var title="">child</var> is null.
    3.64  </ol>
    3.65 @@ -1527,6 +1538,21 @@
    3.66   <var title="">index</var>, decrease its
    3.67   <a href="#concept-range-end-offset" title="concept-range-end-offset">end offset</a> by one.
    3.68  
    3.69 + <li><p><a href="#concept-mutation-dispatch-childlist" title="concept-mutation-dispatch-childlist">Dispatch</a> a
    3.70 + "<code>childList</code>" mutation with <b>target</b> set to <var title="">parent</var>,
    3.71 + <b>removedNodes</b> set to a <code><a href="#nodelist">NodeList</a></code> containing only <var title="">node</var>,
    3.72 + <b>nextSibling</b> set to <var title="">node</var>'s
    3.73 + <a href="#concept-tree-next-sibling" title="concept-tree-next-sibling">next sibling</a>,
    3.74 + and <b>previousSibling</b> set to <var title="">node</var>'s
    3.75 + <a href="#concept-tree-previous-sibling" title="concept-tree-previous-sibling">previous sibling</a>.
    3.76 +
    3.77 + <li><p>For each <a href="#concept-tree-ancestor" title="concept-tree-ancestor">ancestor</a> <var title="">ancestor</var>
    3.78 + of <var title="">node</var>, if <var title="">ancestor</var> has any
    3.79 + <a href="#registered-observer" title="registered-observer">registered observers</a> with the <code>subtree</code>
    3.80 + option set, <a href="#concept-add-transient-observer" title="concept-add-transient-observer">add</a>
    3.81 + an identical <a href="#transient-observer">transient observer</a> to <var title="">node</var> for
    3.82 + each such subtree <a href="#registered-observer" title="registered-observer">registration</a> on <var title="">ancestor</var>.
    3.83 +
    3.84   <li><p>Remove <var title="">node</var> from its <var title="">parent</var>.
    3.85  </ol>
    3.86  
    3.87 @@ -1675,74 +1701,258 @@
    3.88  
    3.89  <h4 id="mutation-observers"><span class="secno">5.1.4 </span>Mutation observers</h4>
    3.90  
    3.91 -<p class="XXX">This section will define the replacement for the
    3.92 -"Mutation Events" feature of the platform. For now it contains the interface
    3.93 -being implemented by vendors.
    3.94 -
    3.95  <pre class="idl">[Constructor(<a href="#mutationcallback">MutationCallback</a> callback)]
    3.96  interface <dfn id="mutationobserver">MutationObserver</dfn> {
    3.97 -  void observe(<a href="#node">Node</a> target, <a href="#mutationobserverinit">MutationObserverInit</a> options);
    3.98 -  void disconnect();
    3.99 +  void <a href="#dom-mutationobserver-observe" title="dom-MutationObserver-observe">observe</a>(<a href="#node">Node</a> target, <a href="#mutationobserverinit">MutationObserverInit</a> options);
   3.100 +  void <a href="#dom-mutationobserver-disconnect" title="dom-MutationObserver-disconnect">disconnect</a>();
   3.101  };
   3.102  
   3.103  callback <dfn id="mutationcallback">MutationCallback</dfn> = void (<a href="#mutationrecord">MutationRecord</a>[] mutations, <a href="#mutationobserver">MutationObserver</a> observer);
   3.104  
   3.105  dictionary <dfn id="mutationobserverinit">MutationObserverInit</dfn> {
   3.106 -  // Mutation types
   3.107 -  boolean childList;     // If true, mutations affecting node&rsquo;s childNodes are included.
   3.108 -  boolean attributes;    // If true, mutations affecting element&rsquo;s attributes are included.
   3.109 -  boolean characterData; // If true, mutations affecting the value of CharacterData nodes are included.
   3.110 -  // [Note: If none of the known mutation types is specified, an Error is thrown]
   3.111 -
   3.112 -  // Subtree observation
   3.113 -  boolean subtree;  // If true, the observed set of nodes for this registration should include
   3.114 -                    // descendants of MutationTarget (behavior described below).
   3.115 -
   3.116 -  // Old values
   3.117 -  boolean attributeOldValue;
   3.118 -  // If true, MutationRecords describing changes to attributes should
   3.119 -  // contain the value of the attribute before the change. If true
   3.120 -  // without attribute: true specified, an Error is thrown.
   3.121 -
   3.122 -  boolean characterDataOldValue;
   3.123 -  // If true, MutationRecords describing changes to
   3.124 -  // CharacterData nodes should contain the value
   3.125 -  // of the node before the change. If true without
   3.126 -  // characterData: true, an Error is thrown.
   3.127 -
   3.128 -  // Filtering
   3.129 -  DOMString[] attributeFilter;
   3.130 -  // If provided, only changes to attributes with localName equaling
   3.131 -  // one of the provided strings will be delivered. If provided without
   3.132 -  // attribute: true, an Error is thrown.
   3.133 +  boolean <span title="dom-MutationObserverInit-childlist">childList</span>;
   3.134 +  boolean <span title="dom-MutationObserverInit-attributes">attributes</span>;
   3.135 +  boolean <span title="dom-MutationObserverInit-characterdata">characterData</span>;
   3.136 +  boolean <span title="dom-MutationObserverInit-subtree">subtree</span>;
   3.137 +  boolean <span title="dom-MutationObserverInit-attributeoldvalue">attributeOldValue</span>;
   3.138 +  boolean <span title="dom-MutationObserverInit-characterdataoldvalue">characterDataOldValue</span>;
   3.139 +  DOMString[] <span title="dom-MutationObserverInit-attributefilter">attributeFilter</span>;
   3.140  };
   3.141  
   3.142  interface <dfn id="mutationrecord">MutationRecord</dfn> {
   3.143 -  // Mutation type: one of 'childList', 'attributes', or 'characterData'
   3.144 -  readonly attribute DOMString type;
   3.145 -
   3.146 -  // For childList and attributes, target is the owner node affected.
   3.147 -  // For CharacterData, target is the node affected.
   3.148 -  readonly attribute <a href="#node">Node</a> target;
   3.149 -
   3.150 -  // For type == 'childList', Sequence of added and removed nodes in this operation.
   3.151 -  readonly attribute <a href="#nodelist">NodeList</a> addedNodes;
   3.152 -  readonly attribute <a href="#nodelist">NodeList</a> removedNodes;
   3.153 -
   3.154 -  // For type == 'childList', The siblings in childNodes immediately preceding following the first
   3.155 -  // and last nodes added and/or removed.
   3.156 -  readonly attribute <a href="#node">Node</a> previousSibling;
   3.157 -  readonly attribute <a href="#node">Node</a> nextSibling;
   3.158 -
   3.159 -  // For type == 'attribute', the name and namespaceURI of the attribute affected
   3.160 -  readonly attribute DOMString attributeName;
   3.161 -  readonly attribute DOMString attributeNamespace;
   3.162 -
   3.163 -  // For type == 'attribute' or 'characterData', if requested, the value immediately
   3.164 -  // preceding the mutation.
   3.165 -  readonly attribute DOMString oldValue;
   3.166 +  readonly attribute DOMString <a href="#dom-mutationrecord-type" title="dom-MutationRecord-type">type</a>;
   3.167 +  readonly attribute <a href="#node">Node</a> <a href="#dom-mutationrecord-target" title="dom-MutationRecord-target">target</a>;
   3.168 +  readonly attribute <a href="#nodelist">NodeList</a>? <a href="#dom-mutationrecord-addednodes" title="dom-MutationRecord-addedNodes">addedNodes</a>;
   3.169 +  readonly attribute <a href="#nodelist">NodeList</a>? <a href="#dom-mutationrecord-removednodes" title="dom-MutationRecord-removedNodes">removedNodes</a>;
   3.170 +  readonly attribute <a href="#node">Node</a>? <a href="#dom-mutationrecord-previoussibling" title="dom-MutationRecord-previousSibling">previousSibling</a>;
   3.171 +  readonly attribute <a href="#node">Node</a>? <a href="#dom-mutationrecord-nextsibling" title="dom-MutationRecord-nextSibling">nextSibling</a>;
   3.172 +  readonly attribute DOMString? <a href="#dom-mutationrecord-attributename" title="dom-MutationRecord-attributeName">attributeName</a>;
   3.173 +  readonly attribute DOMString? <a href="#dom-mutationrecord-attributenamespace" title="dom-MutationRecord-attributeNamespace">attributeNamespace</a>;
   3.174 +  readonly attribute DOMString? <a href="#dom-mutationrecord-oldvalue" title="dom-MutationRecord-oldValue">oldValue</a>;
   3.175  };</pre>
   3.176 -<!-- XXX remove inline comments when this is defined -->
   3.177 +
   3.178 +<p>When the constructor of the <code><a href="#mutationobserver">MutationObserver</a></code> interface is invoked
   3.179 +with callback <var title="">callback</var> and options <var title="">options</var>, run these steps:
   3.180 +
   3.181 +<ol>
   3.182 +  <li><p>If <var title="">callback</var> is null, <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#notfounderror">NotFoundError</a></code>" and terminate these steps.
   3.183 +  <li><p>Return a <code><a href="#mutationobserver">MutationObserver</a></code> <a href="#mutation-observer-associated-callback" title="mutation-observer-associated-callback">associated</a> with the callback.
   3.184 +</ol>
   3.185 +
   3.186 +Besides the properties listed in the IDL for <code><a href="#mutationobserver">MutationObserver</a></code>, it has three internal properties:
   3.187 +<ul>
   3.188 +  <li><p>An <dfn id="mutation-observer-associated-callback" title="mutation-observer-associated-callback">associated callback</dfn>.
   3.189 +  <li><p>A list of <a href="#concept-node" title="concept-node">nodes</a> on which it is <a href="#registered-observer" title="registered-observer">registered</a>.
   3.190 +  <li><p>A queue of <code><a href="#mutationrecord">MutationRecord</a></code>s which are <dfn id="mutation-observer-pending" title="mutation-observer-pending">pending</dfn> delivery.
   3.191 +</ul>
   3.192 +
   3.193 +<hr>
   3.194 +
   3.195 +<p>A <dfn id="registered-observer" title="registered-observer">registered observer</dfn> consists of an <b>observer</b> (an instance of <code><a href="#mutationobserver">MutationObserver</a></code>),
   3.196 +a set of <b>options</b> (an instance of <code><a href="#mutationobserverinit">MutationObserverInit</a></code>), and a <b>transient</b> variable (whose default value is false).
   3.197 +Each <code><a href="#node">Node</a></code> has a list of registered observers. A <dfn id="transient-observer">transient observer</dfn> is a <a href="#registered-observer" title="registered-observer">registered observer</a>
   3.198 +whose <b>transient</b> variable is set to true.
   3.199 +<!-- XXX Need a cross-reference from the microtask processing model explaining when to remove transient observers -->
   3.200 +
   3.201 +<hr>
   3.202 +
   3.203 +<p>When the <dfn id="dom-mutationobserver-observe" title="dom-MutationObserver-observe"><code>observe(<var title="">target</var>, <var title="">options</var>)</code></dfn>
   3.204 +method is called, these steps must be run:
   3.205 +
   3.206 +<ol>
   3.207 +  <li><p>If <var title="">target</var> is not a <a href="#concept-node" title="concept-node">node</a>,
   3.208 +  <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#notfounderror">NotFoundError</a></code>" and terminate these steps.
   3.209 +
   3.210 +  <li><p>If <var title="">options</var> is null, or is not an instance of <code><a href="#mutationobserverinit">MutationObserverInit</a></code>,
   3.211 +  <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#typemismatcherror">TypeMismatchError</a></code>" and terminate these steps.
   3.212 +
   3.213 +  <li><p>Run these substeps, treating <var title="">options</var> as the <a href="#context-object">context object</a>:
   3.214 +  <ol>
   3.215 +    <li><p>If neither <code>childList</code>, <code>attributes</code>, nor <code><a href="#characterdata">characterData</a></code> is true,
   3.216 +    <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#syntaxerror">SyntaxError</a></code>" and terminate these steps.
   3.217 +
   3.218 +    <li><p>If <code>attributeOldValue</code> is true and <code>attributes</code> is not true,
   3.219 +    <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#syntaxerror">SyntaxError</a></code>" and terminate these steps.
   3.220 +
   3.221 +    <li><p>If <code>attributeFilter</code> is a non-empty array and <code>attributes</code> is not true,
   3.222 +    <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#syntaxerror">SyntaxError</a></code>" and terminate these steps.
   3.223 +
   3.224 +    <li><p>If <code>characterDataOldValue</code> is true and <code><a href="#characterdata">characterData</a></code> is not true,
   3.225 +    <a href="#concept-throw" title="concept-throw">throw</a> a "<code><a href="#syntaxerror">SyntaxError</a></code>" and terminate these steps.
   3.226 +  </ol>
   3.227 +
   3.228 +  <li><p>If <var title="">target</var>'s registration list already includes a registration associated with
   3.229 +  the <a href="#context-object">context object</a>, replace that registrations's options with <var title="">options</var>.
   3.230 +
   3.231 +  <li><p>Otherwise, add a new <a href="#registered-observer" title="registered-observer">registration</a> to <var title="">target</var>'s registered observer list with the
   3.232 +  <a href="#context-object">context object</a> as the <var title="">observer</var> and <var title="">options</var> as the options,
   3.233 +  and add <var title="">target</var> to <var title="">observer</var>'s list of nodes on which it is registered.
   3.234 +</ol>
   3.235 +
   3.236 +<p>When the <dfn id="dom-mutationobserver-disconnect" title="dom-MutationObserver-disconnect"><code>disconnect</code></dfn> method is called, for each
   3.237 +<a href="#concept-node" title="concept-node">node</a> <var title="">node</var> in the <a href="#context-object">context object</a>'s list of
   3.238 +<a href="#concept-node" title="concept-node">nodes</a>, remove any <a href="#registered-observer" title="registered-observer">registration</a> on <var title="">node</var> for which
   3.239 +the <a href="#context-object">context object</a> is the <b>observer</b>.
   3.240 +
   3.241 +<h4 id="mutation-observation-algorithms"><span class="secno">5.1.5 </span>Mutation observation algorithms</h4>
   3.242 +
   3.243 +To <dfn id="concept-mutation-dispatch-attributes" title="concept-mutation-dispatch-attributes">dispatch</dfn> an "<code>attributes</code>" MutationRecord
   3.244 +with target <var title="">target</var>, attributeName <var title="">name</var>, and oldValue <var title="">oldValue</var>,
   3.245 +run these steps:
   3.246 +
   3.247 +<ol>
   3.248 +<li><p>Create a new MutationRecord <var title="">record</var> with type initialized to "<code>attributes</code>", target initialized to <var title="">target</var>,
   3.249 +and attributeName initialized to <var title="">name</var>.
   3.250 +
   3.251 +<li><p>Create a copy of this record named <var title="">recordWithOldValue</var> and initialize its oldValue to <var title="">oldValue</var>.
   3.252 +
   3.253 +<li><p>For each <a href="#registered-observer" title="registered-observer">registered observer</a> <var title="">observer</var> (with options <var title="">options</var>) in
   3.254 +
   3.255 +<var title="">target</var>'s registered observer list, run these substeps:
   3.256 +  <ol>
   3.257 +    <li><p>If <var title="">options</var> does not have the <code>attributes</code> option set, terminate these substeps (and run them for the next observer).
   3.258 +
   3.259 +    <li><p>If <var title="">options</var> has a non-empty <code>attributeFilter</code> array, and <var title="">name</var> is not in that array, terminate these substeps
   3.260 +    (and run them for the next observer).
   3.261 +
   3.262 +    <li><p>If <var title="">options</var> has the <code>attributeOldValue</code> option set, append <var title="">recordWithOldValue</var> to the observer's
   3.263 +    queue of pending mutations.
   3.264 +
   3.265 +    <li><p>Otherwise, append <var title="">record</var> to the observer's queue of pending mutations.
   3.266 +    </ol>
   3.267 +     <li><p>For each <a href="#concept-tree-ancestor" title="concept-tree-ancestor">ancestor</a> <var title="">ancestor</var> of target, and for each
   3.268 +     <a href="#registered-observer" title="registered-observer">registered observer</a> <var title="">observer</var> (with options <var title="">options</var>) in <var title="">ancestor</var>'s
   3.269 +     registered observer list, run these substeps:
   3.270 +    <ol>
   3.271 +
   3.272 +    <li><p>If <var title="">options</var> does not have the <code>subtree</code> option set, terminate these substeps (and run them for the next observer).
   3.273 +
   3.274 +    <li><p>If <var title="">options</var> does not have the <code>attributes</code> option set, terminate these substeps (and run them for the next observer).
   3.275 +
   3.276 +    <li><p>If <var title="">options</var> has a non-empty <code>attributeFilter</code> array, and <var title="">name</var> is not in that array, terminate these substeps
   3.277 +    (and run them for the next observer).
   3.278 +
   3.279 +    <li><p>If <var title="">options</var> has the <code>attributeOldValue</code> option set, append <var title="">recordWithOldValue</var> to the observer's
   3.280 +    queue of pending mutations.
   3.281 +
   3.282 +    <li><p>Otherwise, append <var title="">record</var> to the observer's queue of <a href="#mutation-observer-pending" title="mutation-observer-pending">pending</a> mutations.
   3.283 +  </ol>
   3.284 +</ol>
   3.285 +
   3.286 +To <dfn id="concept-mutation-dispatch-characterdata" title="concept-mutation-dispatch-characterData">dispatch</dfn> a "<code><a href="#characterdata">characterData</a></code>" MutationRecord
   3.287 +with target <var title="">target</var> and oldValue <var title="">oldValue</var>, run these steps:
   3.288 +
   3.289 +<ol>
   3.290 + <li><p>Create a new MutationRecord <var title="">record</var> with type initialized to "<code><a href="#characterdata">characterData</a></code>" and target initialized to <var title="">target</var>.
   3.291 +
   3.292 + <li><p>Create a copy of this record named <var title="">recordWithOldValue</var> and initialize its oldValue to <var title="">oldValue</var>.
   3.293 +
   3.294 + <li><p>For each <a href="#registered-observer" title="registered-observer">registered observer</a> <var title="">observer</var> (with options <var title="">options</var>) in
   3.295 + <var title="">target</var>'s registered observer list, run these substeps:
   3.296 +   <ol>
   3.297 +    <li><p>If <var title="">options</var> does not have the <code><a href="#characterdata">characterData</a></code> option set, terminate these substeps (and run them for the next observer).
   3.298 +
   3.299 +    <li><p>If <var title="">options</var> has the <code>characterDataOldValue</code> option set, append <var title="">recordWithOldValue</var> to the observer's
   3.300 +    queue of pending mutations.
   3.301 +
   3.302 +    <li><p>Otherwise, append <var title="">record</var> to the observer's queue of pending mutations.
   3.303 +   </ol>
   3.304 +
   3.305 + <li><p>For each <a href="#concept-tree-ancestor" title="concept-tree-ancestor">ancestor</a> <var title="">ancestor</var> of target, and for each
   3.306 + <a href="#registered-observer" title="registered-observer">registered observer</a> <var title="">observer</var> (with options <var title="">options</var>) in <var title="">ancestor</var>'s
   3.307 + registered observer list, run these substeps:
   3.308 + <ol>
   3.309 +  <li><p>If <var title="">options</var> does not have the <code>subtree</code> option set, terminate these substeps (and run them for the next observer).
   3.310 +
   3.311 +  <li><p>If <var title="">options</var> does not have the <code><a href="#characterdata">characterData</a></code> option set, terminate these substeps (and run them for the next observer).
   3.312 +
   3.313 +  <li><p>If <var title="">options</var> has the <code>characterDataOldValue</code> option set, append <var title="">recordWithOldValue</var> to the observer's
   3.314 +    queue of pending mutations.
   3.315 +
   3.316 +  <li><p>Otherwise, append <var title="">record</var> to the observer's queue of <a href="#mutation-observer-pending" title="mutation-observer-pending">pending</a> mutations.
   3.317 + </ol>
   3.318 +</ol>
   3.319 +
   3.320 +To <dfn id="concept-mutation-dispatch-childlist" title="concept-mutation-dispatch-childList">dispatch</dfn> a "<code>childList</code>" MutationRecord
   3.321 +with target <var title="">target</var>, addedNodes <var title="">addedNodes</var>, removedNodes <var title="">removedNodes</var>, previousSibling <var title="">previousSibling</var>,
   3.322 +and nextSibling <var title="">nextSibling</var>, run these steps:
   3.323 +
   3.324 +<ol>
   3.325 + <li><p>Create a new MutationRecord <var title="">record</var> with type initialized to "<code>childList</code>", target initialized to <var title="">target</var>,
   3.326 + addedNodes initialized to <var title="">addedNodes</var>, removedNodes initialized to <var title="">removedNodes</var>,
   3.327 + previousSibling initialized to <var title="">previousSibling</var>, and nextSibling initialized to.
   3.328 +
   3.329 + <li><p>For each <a href="#registered-observer" title="registered-observer">registered observer</a> <var title="">observer</var> (with options <var title="">options</var>) in
   3.330 + <var title="">target</var>'s registered observer list, run these substeps:
   3.331 + <ol>
   3.332 +  <li><p>If <var title="">options</var> does not have the <code>childList</code> option set, terminate these substeps (and run them for the next observer).
   3.333 +
   3.334 +  <li><p>Append <var title="">record</var> to the observer's queue of pending mutations.
   3.335 + </ol>
   3.336 +
   3.337 + <li><p>For each <a href="#concept-tree-ancestor" title="concept-tree-ancestor">ancestor</a> <var title="">ancestor</var> of target, and for each
   3.338 + <a href="#registered-observer" title="registered-observer">registered observer</a> <var title="">observer</var> (with options <var title="">options</var>) in <var title="">ancestor</var>'s
   3.339 + registered observer list, run these substeps:
   3.340 + <ol>
   3.341 +  <li><p>If <var title="">options</var> does not have the <code>subtree</code> option set, terminate these substeps (and run them for the next observer).
   3.342 +
   3.343 +  <li><p>If <var title="">options</var> does not have the <code>childList</code> option set, terminate these substeps (and run them for the next observer).
   3.344 +
   3.345 +  <li><p>Append <var title="">record</var> to the observer's queue of <a href="#mutation-observer-pending" title="mutation-observer-pending">pending</a> mutations.
   3.346 + </ol>
   3.347 +</ol>
   3.348 +
   3.349 +To <dfn id="concept-add-transient-observer" title="concept-add-transient-observer">add a transient observer</dfn> <var title="">observer</var> with options <var title="">options</var>
   3.350 +to a <a href="#concept-node" title="concept-node">node</a> <var title="">node</var>, create a new <a href="#registered-observer" title="registered-observer">registration</a> with <b>observer</b> set to
   3.351 +<var title="">observer</var>, <b>options</b> set to <var title="">options</var>, and <b>transient</b> set to true and append it to <var title="">node</var>'s
   3.352 +list of <a href="#registered-observer" title="registered-observer">registered observers</a>.
   3.353 +
   3.354 +<h4 id="mutationrecord-attributes"><span class="secno">5.1.6 </span>MutationRecord attributes</h4>
   3.355 +
   3.356 +<p>The <dfn id="dom-mutationrecord-type" title="dom-MutationRecord-type"><code>type</code></dfn> attribute must return
   3.357 +a string representing the type of the mutation, which must be one of the following:
   3.358 +<ul>
   3.359 +  <li>"<dfn id="dom-mutationrecord-type-attributes" title="dom-MutationRecord-type-attributes"><code>attributes</code></dfn>"
   3.360 +  <li>"<dfn id="dom-mutationrecord-type-childlist" title="dom-MutationRecord-type-childList"><code>childList</code></dfn>"
   3.361 +  <li>"<dfn id="dom-mutationrecord-type-characterdata" title="dom-MutationRecord-type-characterData"><code>characterData</code></dfn>"
   3.362 +</ul>
   3.363 +
   3.364 +<p>The <dfn id="dom-mutationrecord-target" title="dom-MutationRecord-target"><code>target</code></dfn> attribute must
   3.365 +return the node this mutation affected, which differs depending on the <span title="mutation-record-type">type</span>.
   3.366 +For childList mutations, it must be the node whose children changed.
   3.367 +For attributes mutations, it must be the element whose attributes changed.
   3.368 +For characterData mutations, it must be the <code><a href="#characterdata">CharacterData</a></code> node whose value changed.
   3.369 +
   3.370 +<p>The <dfn id="dom-mutationrecord-addednodes" title="dom-MutationRecord-addedNodes"><code>addedNodes</code></dfn> attribute must return
   3.371 +the list of nodes added in this mutation, if it was a childList mutation. Otherwise it must return null.
   3.372 +
   3.373 +<p>The <dfn id="dom-mutationrecord-removednodes" title="dom-MutationRecord-removedNodes"><code>removedNodes</code></dfn> attribute must return
   3.374 +the list of nodes removed in this mutation, if it was a childList mutation. Otherwise it must return null.
   3.375 +
   3.376 +<p>The <dfn id="dom-mutationrecord-previoussibling" title="dom-MutationRecord-previousSibling"><code>previousSibling</code></dfn> attribute must return
   3.377 +the node which was the <a href="#concept-tree-previous-sibling" title="concept-tree-previous-sibling">previous sibling</a> of the first element of addedNodes when the mutation occurred, if addedNodes is non-empty,
   3.378 +or the node which was the <a href="#concept-tree-previous-sibling" title="concept-tree-previous-sibling">previous sibling</a> of the first element of removedNodes, if removedNodes is non-empty. Otherwise it must return null.
   3.379 +
   3.380 +<p>The <dfn id="dom-mutationrecord-nextsibling" title="dom-MutationRecord-nextSibling"><code>nextSibling</code></dfn> attribute must return
   3.381 +the node which was the <a href="#concept-tree-next-sibling" title="concept-tree-next-sibling">next sibling</a> of the last item in addedNodes when the mutation occurred, if addedNodes is non-empty,
   3.382 +or the node which was the <a href="#concept-tree-next-sibling" title="concept-tree-next-sibling">next sibling</a> of the last element of removedNodes, if removedNodes is non-empty. Otherwise it must return null.
   3.383 +
   3.384 +<p>The <dfn id="dom-mutationrecord-attributename" title="dom-MutationRecord-attributeName"><code>attributeName</code></dfn> attribute must return
   3.385 +the <code title="dom-attr-name"><a href="#dom-attr-name">name</a></code> of the modified attribute if this is an "<code>attributes</code>" mutation. Otherwise it must return null.
   3.386 +
   3.387 +<p>The <dfn id="dom-mutationrecord-attributenamespace" title="dom-MutationRecord-attributeNamespace"><code>attributeNamespace</code></dfn> attribute must return
   3.388 +the <code title="dom-attr-namespaceuri"><a href="#dom-attr-namespaceuri">namespaceURI</a></code> of the modified attribute if this is an "<code>attributes</code>" mutation. Otherwise it must return null.
   3.389 +
   3.390 +<p>The <dfn id="dom-mutationrecord-oldvalue" title="dom-MutationRecord-oldValue"><code>oldValue</code></dfn> attribute varies in behavior
   3.391 +based on the <a href="#dom-mutationrecord-type" title="dom-MutationRecord-type">type</a> of mutation:
   3.392 +
   3.393 +<ul>
   3.394 +  <li><p>If type is "<code>childList</code>", it must return null.
   3.395 +  <li><p>If type is "<code>attributes</code>" and the registered observation had the attributeOldValue option set, must return
   3.396 +  the <a href="#dom-attr-value" title="dom-attr-value">value</a> of the <a href="#attr" title="attr">attribute</a> just before the mutation was made.
   3.397 +  <li><p>If type is "<code><a href="#characterdata">characterData</a></code>" and the registered observation had the characterDataOldValue option set, must return the value of
   3.398 +  the <a href="#dom-mutationrecord-target" title="dom-MutationRecord-target">target</a>'s <a href="#dom-characterdata-data" title="dom-characterdata-data">data</a> attribute just before the mutation was made.
   3.399 +</ul>
   3.400  
   3.401  
   3.402  <h3 id="interface-node"><span class="secno">5.2 </span>Interface <code><a href="#node">Node</a></code></h3>
   3.403 @@ -3341,7 +3551,7 @@
   3.404   <a href="#affected-by-a-base-url-change">affected by a base URL change</a>.
   3.405  
   3.406   <li><p>If <var title="">node</var>'s
   3.407 - <a href="#concept-tree-parent" title="concept-tree-parent">parent</a> is not null, remove
   3.408 + <a href="#concept-tree-parent" title="concept-tree-parent">parent</a> is not null, <a href="#concept-node-remove" title="concept-node-remove">remove</a>
   3.409   <var title="">node</var> from its
   3.410   <a href="#concept-tree-parent" title="concept-tree-parent">parent</a>.
   3.411  
   3.412 @@ -4075,24 +4285,29 @@
   3.413   <var title="">name</var>, <a href="#concept-throw" title="concept-throw">throw</a> a
   3.414   "<code><a href="#namespaceerror">NamespaceError</a></code>" and terminate these steps.
   3.415  
   3.416 - <li><p>If the <a href="#context-object">context object</a> does not have an
   3.417 + <li><p>Let <var title="">attribute</var> be the
   3.418 + first <a href="#concept-attribute" title="concept-attribute">attribute</a> in the
   3.419 + <a href="#context-object">context object</a>'s <a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a>
   3.420 + whose <a href="#concept-attribute-name" title="concept-attribute-name">name</a> is
   3.421 + <var title="">name</var>, or null if there is no such
   3.422 + <a href="#concept-attribute" title="concept-attribute">attribute</a>.
   3.423 +
   3.424 + <li><p>If <var title="">attribute</var> is null, create an
   3.425   <a href="#concept-attribute" title="concept-attribute">attribute</a> whose
   3.426   <a href="#concept-attribute-name" title="concept-attribute-name">name</a> is
   3.427 - <var title="">name</var>, create an
   3.428 - <a href="#concept-attribute" title="concept-attribute">attribute</a>, whose
   3.429 - <a href="#concept-attribute-name" title="concept-attribute-name">name</a> is
   3.430   <var title="">name</var> and
   3.431   <a href="#concept-attribute-value" title="concept-attribute-value">value</a> is <var title="">value</var>,
   3.432   and then <a href="#concept-element-attributes-append" title="concept-element-attributes-append">append</a> this
   3.433   <a href="#concept-attribute" title="concept-attribute">attribute</a> to the
   3.434 - <a href="#context-object">context object</a>.
   3.435 -
   3.436 - <li><p>Otherwise, <a href="#concept-attribute-change" title="concept-attribute-change">change</a> the
   3.437 - first <a href="#concept-attribute" title="concept-attribute">attribute</a> in the
   3.438 - <a href="#context-object">context object</a>'s
   3.439 - <a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a> whose
   3.440 - <a href="#concept-attribute-name" title="concept-attribute-name">name</a> is
   3.441 - <var title="">name</var>, to <var title="">value</var>.
   3.442 + <a href="#context-object">context object</a> and terminate these steps.
   3.443 +
   3.444 + <li><p><a href="#concept-mutation-dispatch-attributes" title="concept-mutation-dispatch-attributes">Dispatch</a> an "<code>attributes</code>"
   3.445 + <code><a href="#mutationrecord">MutationRecord</a></code> with <b>target</b> set to the <a href="#context-object">context object</a>,
   3.446 + <b>attributeName</b> set to <var title="">attribute</var>'s <a href="#dom-attr-localname" title="dom-attr-localname">localName</a>,
   3.447 + <b>attributeNamespace</b> set to <var title="">attribute</var>'s <a href="#dom-attr-namespaceuri" title="dom-attr-namespaceuri">namespaceURI</a>,
   3.448 + and <b>oldValue</b> set to <var title="">attribute</var>'s <a href="#dom-attr-value" title="dom-attr-value">value</a>.
   3.449 +
   3.450 + <li><p>Set <var title="">attribute</var>'s <a href="#concept-attribute-value" title="concept-attribute-value">value</a> to <var title="">value</var>.
   3.451  </ol>
   3.452  
   3.453  <p>The
   3.454 @@ -4138,14 +4353,18 @@
   3.455   "<code title="">xmlns</code>", <a href="#concept-throw" title="concept-throw">throw</a> a
   3.456   "<code><a href="#namespaceerror">NamespaceError</a></code>" exception and terminate these steps.
   3.457  
   3.458 - <li><p>If the <a href="#context-object">context object</a> does not
   3.459 - <a href="#concept-element-attribute-has" title="concept-element-attribute-has">have</a> an
   3.460 + <li><p>Let <var title="">attribute</var> be the
   3.461 + first <a href="#concept-attribute" title="concept-attribute">attribute</a> in the
   3.462 + <a href="#context-object">context object</a>'s
   3.463 + <a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a>
   3.464 + whose <a href="#concept-attribute-namespace" title="concept-attribute-namespace">namespace</a> is
   3.465 + <var title="">namespace</var> and whose
   3.466 + <a href="#concept-attribute-local-name" title="concept-attribute-local-name">local name</a>
   3.467 + is <var title="">localName</var>, or null if there is no such
   3.468 + <a href="#concept-attribute" title="concept-attribute">attribute</a>.
   3.469 +
   3.470 + <li><p>If <var title="">attribute</var> is null, create an
   3.471   <a href="#concept-attribute" title="concept-attribute">attribute</a> whose
   3.472 - <a href="#concept-attribute-namespace" title="concept-attribute-namespace">namespace</a> is
   3.473 - <var title="">namespace</var> and
   3.474 - <a href="#concept-attribute-local-name" title="concept-attribute-local-name">local name</a> is
   3.475 - <var title="">localName</var>, create an
   3.476 - <a href="#concept-attribute" title="concept-attribute">attribute</a>, whose
   3.477   <a href="#concept-attribute-name" title="concept-attribute-name">name</a> is
   3.478   <var title="">name</var>,
   3.479   <a href="#concept-attribute-namespace" title="concept-attribute-namespace">namespace</a> is
   3.480 @@ -4157,10 +4376,17 @@
   3.481   is <var title="">value</var>, and then
   3.482   <a href="#concept-element-attributes-append" title="concept-element-attributes-append">append</a> this
   3.483   <a href="#concept-attribute" title="concept-attribute">attribute</a> to the
   3.484 - <a href="#context-object">context object</a>.
   3.485 -
   3.486 - <li><p>Otherwise, <a href="#concept-attribute-change" title="concept-attribute-change">change</a> that
   3.487 - <a href="#concept-attribute" title="concept-attribute">attribute</a> to <var title="">value</var>.
   3.488 + <a href="#context-object">context object</a> and terminate these steps.
   3.489 +
   3.490 + <li><p><a href="#concept-mutation-dispatch-attributes" title="concept-mutation-dispatch-attributes">Dispatch</a> an
   3.491 + "<code>attributes</code>" <code><a href="#mutationrecord">MutationRecord</a></code> with <b>target</b>
   3.492 + set to the <a href="#context-object">context object</a>, <b>attributeName</b> set to
   3.493 + <var title="">name</var>, <b>attributeNamespace</b> set to
   3.494 + <var title="">namespace</var>, and <b>oldValue</b> set to
   3.495 + <var title="">attribute</var>'s <a href="#dom-attr-value" title="dom-attr-value">value</a>.
   3.496 +
   3.497 + <li><p>Set <var title="">attribute</var>'s
   3.498 + <a href="#concept-attribute-value" title="concept-attribute-value">value</a> to <var title="">value</var>.
   3.499  </ol>
   3.500  
   3.501  <p>The
   3.502 @@ -4375,26 +4601,42 @@
   3.503  
   3.504  <hr>
   3.505  
   3.506 -<p>To <dfn id="concept-attribute-change" title="concept-attribute-change">change</dfn> an
   3.507 -<a href="#concept-attribute" title="concept-attribute">attribute</a> <var title="">attribute</var> to
   3.508 -<var title="">value</var>, set the <var title="">attribute</var>'s
   3.509 -<a href="#concept-attribute-value" title="concept-attribute-value">value</a> to <var title="">value</var>.
   3.510 -
   3.511  <!-- XXX move append/remove to attribute list? -->
   3.512  <p>To <dfn id="concept-element-attributes-append" title="concept-element-attributes-append">append</dfn> an
   3.513  <a href="#concept-attribute" title="concept-attribute">attribute</a> <var title="">attribute</var> to
   3.514  an <a href="#concept-element" title="concept-element">element</a> <var title="">element</var>,
   3.515 -append the <var title="">attribute</var> to the <var title="">element</var>'s
   3.516 -<a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a>.
   3.517 +run these steps:
   3.518 +
   3.519 +<ol>
   3.520 + <li><p><a href="#concept-mutation-dispatch-attributes" title="concept-mutation-dispatch-attributes">Dispatch</a> an
   3.521 + "<code>attributes</code>" <code><a href="#mutationrecord">MutationRecord</a></code> with <b>target</b>
   3.522 + set to <var title="">element</var>, <b>attributeName</b> set to
   3.523 + <var title="">attribute</var>'s <a href="#dom-attr-localname" title="dom-attr-localname">localName</a>,
   3.524 + <b>attributeNamespace</b> set to <var title="">attribute</var>'s
   3.525 + <a href="#dom-attr-namespaceuri" title="dom-attr-namespaceuri">namespaceURI</a>,
   3.526 + and <b>oldValue</b> set to null.
   3.527 +
   3.528 + <li><p>Append the <var title="">attribute</var> to the <var title="">element</var>'s
   3.529 + <a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a>.
   3.530 +</ol>
   3.531  
   3.532  <p>To <dfn id="concept-element-attributes-remove" title="concept-element-attributes-remove">remove</dfn> an
   3.533  <a href="#concept-attribute" title="concept-attribute">attribute</a> <var title="">attribute</var>
   3.534  from an <a href="#concept-element" title="concept-element">element</a> <var title="">element</var>,
   3.535 -remove the <var title="">attribute</var> from the <var title="">element</var>'s
   3.536 -<a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a>.
   3.537 -
   3.538 -<p class="XXX">These definitions will be expanded upon in due course for
   3.539 -mutations.
   3.540 +run these steps:
   3.541 +
   3.542 +<ol>
   3.543 + <li><p><a href="#concept-mutation-dispatch-attributes" title="concept-mutation-dispatch-attributes">Dispatch</a> an
   3.544 + "<code>attributes</code>" <code><a href="#mutationrecord">MutationRecord</a></code> with <b>target</b>
   3.545 + set to <var title="">element</var>, <b>attributeName</b> set to
   3.546 + <var title="">attribute</var>'s <a href="#dom-attr-localname" title="dom-attr-localname">localName</a>,
   3.547 + <b>attributeNamespace</b> set to <var title="">attribute</var>'s
   3.548 + <a href="#dom-attr-namespaceuri" title="dom-attr-namespaceuri">namespaceURI</a>, and <b>oldValue</b>
   3.549 + set to <var title="">attribute</var>'s <a href="#dom-attr-value" title="dom-attr-value">value</a>.
   3.550 +
   3.551 + <li><p>Remove the <var title="">attribute</var> from the <var title="">element</var>'s
   3.552 + <a href="#concept-element-attribute" title="concept-element-attribute">attribute list</a>.
   3.553 +</ol>
   3.554  
   3.555  <hr>
   3.556  
   3.557 @@ -4463,6 +4705,11 @@
   3.558   than <var title="">length</var> let <var title="">count</var> be
   3.559   <var title="">length</var> minus <var title="">offset</var>.
   3.560  
   3.561 + <li><p><a href="#concept-mutation-dispatch-characterdata" title="concept-mutation-dispatch-characterData">Dispatch</a>
   3.562 + a "<code><a href="#characterdata">characterData</a></code>" <code><a href="#mutationrecord">MutationRecord</a></code> with <b>target</b>
   3.563 + set to <var title="">node</var> and <b>oldValue</b> set to
   3.564 + <var title="">node</var>'s <a href="#concept-cd-data" title="concept-CD-data">data</a>.
   3.565 +
   3.566   <li><p>Insert <var title="">data</var> into <var title="">node</var>'s
   3.567   <a href="#concept-cd-data" title="concept-CD-data">data</a> after <var title="">offset</var>
   3.568   <a class="external" data-anolis-spec="webidl" href="http://dev.w3.org/2006/webapi/WebIDL/#dfn-code-unit" title="code unit">code units</a>.
   3.569 @@ -7937,6 +8184,7 @@
   3.570  
   3.571  <p>Thanks to
   3.572  
   3.573 +Adam Klein,
   3.574  Adrian Bateman,
   3.575  Brandon Slade,
   3.576  Cameron McCormack,