diff --git a/index.html b/index.html index f17e69b..c17aed9 100644 --- a/index.html +++ b/index.html @@ -257,15 +257,15 @@ ] } ], - "publishISODate": "2024-04-10T00:00:00.000Z", - "generatedSubtitle": "W3C Editor's Draft 10 April 2024" + "publishISODate": "2024-04-16T00:00:00.000Z", + "generatedSubtitle": "W3C Editor's Draft 16 April 2024" }

DOM Parsing and Serialization

DOMParser, XMLSerializer, innerHTML, and similar APIs

-

W3C Editor's Draft

+

W3C Editor's Draft

More details about this document
@@ -363,7 +363,7 @@

DOM Parsing and Serialization

03 November 2023 W3C Process Document. -

+

Candidate Recommendation Exit Criteria

@@ -435,7 +435,7 @@

DOM Parsing and Serialization

For example: the innerHTML API is a common way to both +

For example: the innerHTML API is a common way to both parse and serialize a DOM (it does both). If a particular Node, has the following in-memory DOM:
HTMLDivElement (nodeName: "div")
@@ -449,14 +449,14 @@ 

DOM Parsing and Serialization

"text!")

And the HTMLDivElement node is stored in a variable myDiv, then to serialize myDiv's children simply get (read) the - Element's innerHTML property (this triggers the serialization): + Element's innerHTML property (this triggers the serialization):
var serializedChildren = myDiv.innerHTML;
 // serializedChildren has the value:
 // "<span>some </span><em>text!</em>"

To parse new children for myDiv from a string (replacing its existing - children), simply set the innerHTML property (this triggers + children), simply set the innerHTML property (this triggers parsing of the assigned string):

myDiv.innerHTML = "<span>new</span><em>children!</em>";
@@ -551,70 +551,25 @@

DOM Parsing and Serialization

2.3 The InnerHTML mixin

+

2.3 The InnerHTML mixin

-
WebIDLinterface mixin InnerHTML {
-  [CEReactions] attribute [LegacyNullToEmptyString] HTMLString innerHTML;
-};
+  
 
-Element includes InnerHTML;
-ShadowRoot includes InnerHTML;
- - - -

The innerHTML IDL attribute represents the markup of the - element's contents. - -

-
element . innerHTML [ = value ] -
Returns a fragment of HTML or XML that represents the element's contents. - -

Can be set, to replace the contents of the element with nodes parsed from the given string. - -

In the case of an XML document, throws a "InvalidStateError" - DOMException if the element cannot be serialized to XML, - or a "SyntaxError" DOMException if the given string is - not well-formed. -

- -

On getting, return the result of invoking the fragment serializing algorithm on the - context object providing true for the require well-formed flag (this - might throw an exception instead of returning a string). - -

On setting, these steps must be run: - -

    -
  1. Let context element be the context object's - host if the context object is a - ShadowRoot object, or the context object otherwise. - -
  2. Let fragment be the result of invoking the fragment parsing algorithm with - the new value as markup, and with context element. - -
  3. If the context object is a template element, then let - context object be the template's template contents (a - DocumentFragment). - -
    Note

    Setting innerHTML on a template element will replace - all the nodes in its template contents - (template.content) rather than its children.

    - -
  4. Replace all with fragment within the context object. -
+

The definition of InnerHTML has moved to the HTML Standard.

-

2.4 Extensions to the Element interface

+

2.4 Extensions to the Element interface

-
WebIDLpartial interface Element {
-  [CEReactions] attribute [LegacyNullToEmptyString] HTMLString outerHTML;
-  [CEReactions] undefined insertAdjacentHTML(DOMString position, HTMLString text);
+  
WebIDLpartial interface Element {
+  [CEReactions] attribute [LegacyNullToEmptyString] HTMLString outerHTML;
+  [CEReactions] undefined insertAdjacentHTML(DOMString position, HTMLString text);
 };

The outerHTML IDL attribute represents the markup of the - Element and its contents. + Element and its contents.

element . outerHTML [ = value ] @@ -622,46 +577,46 @@

DOM Parsing and Serialization

XML document, throws a "InvalidStateError" - DOMException if the element cannot be serialized to XML, or a - "SyntaxError" DOMException if the given string is not +

In the case of an XML document, throws a "InvalidStateError" + DOMException if the element cannot be serialized to XML, or a + "SyntaxError" DOMException if the given string is not well-formed. -

Throws a "NoModificationAllowedError" DOMException +

Throws a "NoModificationAllowedError" DOMException if the parent of the element is a Document.

-

On getting, return the result of invoking the fragment serializing algorithm on a - fictional node whose only child is the context object providing true for the - require well-formed flag (this might throw an exception instead of returning a string). +

On getting, return the result of invoking the fragment serializing algorithm on a + fictional node whose only child is the context object providing true for the + require well-formed flag (this might throw an exception instead of returning a string).

On setting, the following steps must be run:

    -
  1. Let parent be the context object's parent. +
  2. Let parent be the context object's parent.
  3. If parent is null, terminate these steps. There would be no way to obtain a reference to the nodes created even if the remaining steps were run.
  4. If parent is a Document, throw a - "NoModificationAllowedError" DOMException. + "NoModificationAllowedError" DOMException. -
  5. If parent is a DocumentFragment, let parent be a - new Element with: +
  6. If parent is a DocumentFragment, let parent be a + new Element with: -
  7. Let fragment be the result of invoking the fragment parsing algorithm with +
  8. Let fragment be the result of invoking the fragment parsing algorithm with the new value as markup, and parent as the context element. -
  9. Replace the context object with fragment within the - context object's parent. +
  10. Replace the context object with fragment within the + context object's parent.
@@ -685,11 +640,11 @@

DOM Parsing and Serialization

SyntaxError" DOMException if the arguments - have invalid values (e.g., in the case of an XML document, if the given string is not +

Throws a "SyntaxError" DOMException if the arguments + have invalid values (e.g., in the case of an XML document, if the given string is not well-formed). -

Throws a "NoModificationAllowedError" DOMException if +

Throws a "NoModificationAllowedError" DOMException if the given position isn't possible (e.g. inserting elements after the root element of a Document).

@@ -706,22 +661,22 @@

DOM Parsing and Serialization

beforebegin"
If position is an ASCII case-insensitive match for the string "afterend" -
Let context be the context object's parent. +
Let context be the context object's parent.

If context is null or a Document, throw a - "NoModificationAllowedError" DOMException. + "NoModificationAllowedError" DOMException.

If position is an ASCII case-insensitive match for the string "afterbegin"
If position is an ASCII case-insensitive match for the string "beforeend" -
Let context be the context object. +
Let context be the context object.
Otherwise -
Throw a "SyntaxError" DOMException. +
Throw a "SyntaxError" DOMException.
-
  • If context is not an Element or the following are all true: +
  • If context is not an Element or the following are all true: -

    let context be a new Element with +

    let context be a new Element with

    -
  • Let fragment be the result of invoking the fragment parsing algorithm with +
  • Let fragment be the result of invoking the fragment parsing algorithm with text as markup, and context as the context element.
  • Use the first matching item from this list: @@ -749,32 +704,32 @@

    DOM Parsing and Serialization

    If position is an ASCII case-insensitive match for the string "beforebegin" -
    Insert fragment into the context object's parent before - the context object. +
    Insert fragment into the context object's parent before + the context object.
    If position is an ASCII case-insensitive match for the string "afterbegin" -
    Insert fragment into the context object before its +
    Insert fragment into the context object before its first child.
    If position is an ASCII case-insensitive match for the string "beforeend" -
    Append fragment to the context object. +
    Append fragment to the context object.
    If position is an ASCII case-insensitive match for the string "afterend" -
    Insert fragment into the context object's parent before - the context object's next sibling. +
    Insert fragment into the context object's parent before + the context object's next sibling.

  • -
    Note

    No special handling for template elements is included in the +

    Note

    No special handling for template elements is included in the above "afterbegin" and "beforeend" cases. As with other direct - Node-manipulation APIs (and unlike innerHTML), + Node-manipulation APIs (and unlike innerHTML), insertAdjacentHTML does not include any special handling for - template elements. In most cases you will wish to use - template.content.insertAdjacentHTML - instead of directly manipulating the child nodes of a template + template elements. In most cases you will wish to use + template.content.insertAdjacentHTML + instead of directly manipulating the child nodes of a template element.

    @@ -782,12 +737,12 @@

    DOM Parsing and Serialization

    2.5 Extensions to the Range interface

    WebIDLpartial interface Range {
    -  [CEReactions, NewObject] DocumentFragment createContextualFragment(HTMLString fragment);
    +  [CEReactions, NewObject] DocumentFragment createContextualFragment(HTMLString fragment);
     };
    docFragment = range . createContextualFragment ( fragment ) -
    Returns a DocumentFragment, created from the markup string +
    Returns a DocumentFragment, created from the markup string fragment using range's start node as the context in which fragment is parsed.
    @@ -796,16 +751,16 @@

    DOM Parsing and Serialization

    context object's start node. +
  • Let node be the context object's start node.

    Let element be as follows, depending on node's interface:

    Document -
    DocumentFragment +
    DocumentFragment
    null -
    Element +
    Element
    node
    Text @@ -828,17 +783,17 @@

    DOM Parsing and Serialization

    HTML namespace;

  • -

    let element be a new Element with +

    let element be a new Element with

    -
  • Let fragment node be the result of invoking the fragment parsing algorithm +
  • Let fragment node be the result of invoking the fragment parsing algorithm with fragment as markup, and element as the context element. @@ -857,89 +812,52 @@

    DOM Parsing and Serialization

    3.1 Parsing

    -

    The following steps form the fragment parsing algorithm, whose arguments are a - markup string and a context element: - -

      -
    1. If the context element's node document is an HTML document: let - algorithm be the HTML fragment parsing algorithm. - -

      If the context element's node document is an XML document: let - algorithm be the XML fragment parsing algorithm. + -

    2. Let new children be the result of invoking algorithm with - markup as the input, and context element as the - context element. - -
    3. Let fragment be a new DocumentFragment whose - node document is context element's node document. - -
    4. Append each Node in new children to fragment (in - tree order). - -
      Note

      This ensures the node document for the new nodes is correct.

      - -
    5. Return the value of fragment. -
    +

    The definition of fragment parsing algorithm has moved to the HTML Standard.

    3.2 Serializing

    -

    The following steps form the fragment serializing algorithm, whose arguments are a - Node node and a flag require well-formed: - -

      -
    1. Let context document be the value of node's node document. - -
    2. If context document is an HTML document, return an - HTML serialization of node. - -
    3. Otherwise, context document is an XML document; return an - XML serialization of node passing the flag require well-formed. - -
      Note

      The XML serialization defined in this document conforms to the requirements - of the XML fragment serialization algorithm defined in [HTML5].

      -
    + -

    To produce an HTML serialization of a Node node, the - user agent must run the HTML fragment serialization algorithm on node and return - the string produced. +

    The definition of fragment serializing algorithm has moved to the HTML Standard.

    -

    3.2.1 XML Serialization

    +

    3.2.1 XML Serialization

    -

    An XML serialization differs from an HTML serialization in the following ways: +

    An XML serialization differs from an HTML serialization in the following ways:

    -

    Otherwise, the algorithm for producing an XML serialization is designed to produce a +

    Otherwise, the algorithm for producing an XML serialization is designed to produce a serialization that is compatible with the HTML parser. For example, elements in the - HTML namespace that contain no child nodes are serialized with an explicit begin and end + HTML namespace that contain no child nodes are serialized with an explicit begin and end tag rather than using the empty-element tag syntax. -

    Note

    Per [DOM4], Attr objects do not inherit from Node, and +

    Note

    Per [DOM4], Attr objects do not inherit from Node, and thus cannot be serialized by the XML serialization algorithm. An attempt to serialize an Attr object will result in an empty string. -

    To produce an XML serialization of a Node node given - a flag require well-formed, run the following steps: +

    To produce an XML serialization of a Node node given + a flag require well-formed, run the following steps:

    1. Let namespace be a context namespace with value null. - The context namespace tracks the XML serialization algorithm's current default - namespace. The context namespace is changed when either an Element Node has + The context namespace tracks the XML serialization algorithm's current default + namespace. The context namespace is changed when either an Element Node has a default namespace declaration, or the algorithm generates a default namespace declaration for - the Element Node to match its own namespace. The algorithm assumes no namespace + the Element Node to match its own namespace. The algorithm assumes no namespace (null) to start.
    2. Let prefix map be a new namespace prefix map. @@ -957,10 +875,10 @@

      DOM Parsing and Serialization

      XML serialization algorithm on node passing the context namespace namespace, namespace prefix map prefix map, generated namespace prefix index reference to - prefix index, and the flag require well-formed. If an + prefix index, and the flag require well-formed. If an exception occurs during the execution of the algorithm, - then catch that exception and throw an "InvalidStateError" - DOMException. + then catch that exception and throw an "InvalidStateError" + DOMException.

    Each of the following algorithms for producing an XML serialization of a DOM node @@ -969,7 +887,7 @@

    DOM Parsing and Serialization

    context namespace namespace

  • A namespace prefix map prefix map
  • A generated namespace prefix index prefix index -
  • The require well-formed flag +
  • The require well-formed flag
  • The XML serialization algorithm @@ -979,7 +897,7 @@

    DOM Parsing and Serialization

    -
    Element +
    Element
    Run the algorithm for XML serializing an Element node node.
    Document @@ -993,7 +911,7 @@

    DOM Parsing and Serialization

    Text

    Run the algorithm for XML serializing a Text node node. -
    DocumentFragment +
    DocumentFragment
    Run the algorithm for XML serializing a DocumentFragment node node.
    DocumentType @@ -1006,7 +924,7 @@

    DOM Parsing and Serialization

    TypeError. Only Nodes and Attr objects can be serialized by +

    Throw a TypeError. Only Nodes and Attr objects can be serialized by this algorithm.
    @@ -1014,11 +932,11 @@

    DOM Parsing and Serialization

    3.2.1.1 XML serializing an Element node
    - The algorithm for producing an XML serialization of a DOM node of type Element is as + The algorithm for producing an XML serialization of a DOM node of type Element is as follows:
      -
    1. If the require well-formed flag is set (its value is true), +
    2. If the require well-formed flag is set (its value is true), and this node's localName attribute contains the character ":" (U+003A COLON) or does not match the XML Name production, then throw an exception; the serialization of this node would not be a well-formed @@ -1036,25 +954,25 @@

      DOM Parsing and Serialization

      prefix map, copy a namespace prefix map and let map be the result. -

    3. Let local prefixes map be an empty map. The map has unique Node +
    4. Let local prefixes map be an empty map. The map has unique Node prefix strings as its keys, with corresponding namespaceURI - Node values as the map's key values (in this map, the null namespace is + Node values as the map's key values (in this map, the null namespace is represented by the empty string). -
      Note

      This map is local to each element. It is used to ensure there are no conflicting +

      Note

      This map is local to each element. It is used to ensure there are no conflicting prefixes should a new namespace prefix attribute need to be generated. It is also used to enable skipping of duplicate prefix definitions when writing an element's attributes: the map allows the algorithm to distinguish between a prefix in the - namespace prefix map that might be locally-defined (to the current Element) and + namespace prefix map that might be locally-defined (to the current Element) and one that is not.

    5. Let local default namespace be the result of recording the namespace information for node given map and local prefixes map. -
      Note

      The above step will update map with any found namespace prefix +

      Note

      The above step will update map with any found namespace prefix definitions, add the found prefix definitions to the local prefixes map and return a local default namespace value defined by a default namespace attribute if one exists. Otherwise it returns null.

      @@ -1091,14 +1009,14 @@

      DOM Parsing and Serialization

      retrieving a preferred prefix string prefix from map given namespace ns. -
      Note

      The above may return null if no namespace key ns exists +

      Note

      The above may return null if no namespace key ns exists in map.

    6. If the value of prefix matches "xmlns", then run the following steps:
        -
      1. If the require well-formed flag is set, then throw an error. An - Element with prefix "xmlns" +
      2. If the require well-formed flag is set, then throw an error. An + Element with prefix "xmlns" will not legally round-trip in a conforming XML parser.
      3. Let candidate prefix be the value of prefix. @@ -1107,8 +1025,8 @@

        DOM Parsing and Serialization

        Found a suitable namespace prefix: if candidate prefix is not null (a namespace prefix is defined which maps to ns), then: -
        Note

        The following may serialize a different - prefix than the Element's existing +

        Note

        The following may serialize a different + prefix than the Element's existing prefix if it already had one. However, the retrieving a preferred prefix string algorithm already tried to match the existing prefix if possible.

        @@ -1128,7 +1046,7 @@

        DOM Parsing and Serialization

        context namespace is changed to the declared default, rather than this node's own namespace). -
        Note

        Any default namespace definitions or namespace prefixes that define the +

        Note

        Any default namespace definitions or namespace prefixes that define the XML namespace are omitted when serializing this node's attributes.

      4. Append the value of qualified name to markup. @@ -1136,7 +1054,7 @@

        DOM Parsing and Serialization

        Note

        By this step, there is no namespace or prefix mapping declaration in this +

        Note

        By this step, there is no namespace or prefix mapping declaration in this node (or any parent node visited by this algorithm) that defines prefix otherwise the step labelled Found a suitable namespace prefix would have been followed. The sub-steps that follow will create a new namespace prefix declaration @@ -1158,7 +1076,7 @@

        DOM Parsing and Serialization

        Note

        The following serializes a namespace prefix declaration for prefix +

        Note

        The following serializes a namespace prefix declaration for prefix which was just added to the map.

          @@ -1171,7 +1089,7 @@

          DOM Parsing and Serialization

          ="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK);
        1. The result of serializing an attribute value given ns and the - require well-formed flag as input; + require well-formed flag as input;
        2. """ (U+0022 QUOTATION MARK). @@ -1187,7 +1105,7 @@

          DOM Parsing and Serialization

          local default namespace is not null and its value is not equal to ns, then: -
          Note

          At this point, the namespace for this node still needs to be serialized, but +

          Note

          At this point, the namespace for this node still needs to be serialized, but there's no prefix (or candidate prefix) availble; the following uses the default namespace declaration to define the namespace--optionally replacing an existing default declaration if present.

          @@ -1201,15 +1119,15 @@

          DOM Parsing and Serialization

          inherited ns be ns. -
          Note

          The new default namespace will be used in the serialization to define this +

          Note

          The new default namespace will be used in the serialization to define this node's namespace and act as the context namespace for its - children.

          + children.

        3. Append the value of qualified name to markup.
        4. Append the following to markup, in the order listed: -
          Note

          The following serializes the new (or replacement) default namespace +

          Note

          The following serializes the new (or replacement) default namespace definition.

            @@ -1220,7 +1138,7 @@

            DOM Parsing and Serialization

            ="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK);
          1. The result of serializing an attribute value given ns and the - require well-formed flag as input; + require well-formed flag as input;
          2. """ (U+0022 QUOTATION MARK).
          @@ -1231,7 +1149,7 @@

          DOM Parsing and Serialization

          localName, let the value of inherited ns be ns, and append the value of qualified name to markup. -
          Note

          All of the combinations where ns is not equal to +

          Note

          All of the combinations where ns is not equal to inherited ns are handled above such that node will be serialized preserving its original namespaceURI.

        @@ -1240,10 +1158,10 @@

        DOM Parsing and Serialization

        XML serialization of node's attributes given map, prefix index, local prefixes map, ignore namespace definition attribute flag, and - require well-formed flag. + require well-formed flag.

      5. If ns is the HTML namespace, and the node's list of - children is empty, and the node's localName matches any + children is empty, and the node's localName matches any one of the following void elements: "area", "base", @@ -1273,7 +1191,7 @@

        DOM Parsing and Serialization

        skip end tag flag to true.

      6. If ns is not the HTML namespace, and the node's list of - children is empty, then append "/" (U+002F SOLIDUS) to markup + children is empty, then append "/" (U+002F SOLIDUS) to markup and set the skip end tag flag to true.
      7. Append ">" (U+003E GREATER-THAN SIGN) to markup. @@ -1283,19 +1201,19 @@

        DOM Parsing and Serialization

        HTML namespace, and the node's localName matches the string "template", then this is a - template element. Append to markup the result of - XML serializing a DocumentFragment node given the template element's - template contents (a DocumentFragment), providing + template element. Append to markup the result of + XML serializing a DocumentFragment node given the template element's + template contents (a DocumentFragment), providing inherited ns, map, prefix index, and the - require well-formed flag. + require well-formed flag. -
        Note

        This allows template content to round-trip , given the rules for +

        Note

        This allows template content to round-trip , given the rules for parsing XHTML documents.

      8. Otherwise, append to markup the result of running the - XML serialization algorithm on each of node's children, in - tree order, providing inherited ns, map, - prefix index, and the require well-formed flag. + XML serialization algorithm on each of node's children, in + tree order, providing inherited ns, map, + prefix index, and the require well-formed flag.
      9. Append the following to markup, in the order listed:
          @@ -1316,7 +1234,7 @@

          DOM Parsing and Serialization

          local default namespace value defined by a default namespace attribute if one exists. Otherwise it returns null.

          -

          When recording the namespace information for an Element +

          When recording the namespace information for an Element element, given a namespace prefix map map and a local prefixes map (initially empty), the user agent must run the following steps: @@ -1328,7 +1246,7 @@

          DOM Parsing and Serialization

          attributes, in the order they are specified in the element's attribute list: -
          Note

          The following conditional steps find namespace prefixes. Only attributes +

          Note

          The following conditional steps find namespace prefixes. Only attributes in the XMLNS namespace are considered (e.g., attributes made to look like namespace declarations via setAttribute("xmlns:pretend-prefix", "pretend-namespace") are not included).

          @@ -1359,7 +1277,7 @@

          DOM Parsing and Serialization

          XML namespace, then stop running these steps, and return to Main to visit the next attribute. -
          Note

          XML namespace definitions in prefixes are completely ignored (in +

          Note

          XML namespace definitions in prefixes are completely ignored (in order to avoid unnecessary work when there might be prefix conflicts). XML namespaced elements are always handled uniformly by prefixing (and overriding if necessary) the element's localname with the reserved "xml" prefix.

          @@ -1372,7 +1290,7 @@

          DOM Parsing and Serialization

          Main to visit the next attribute. -
          Note

          This step avoids adding duplicate prefix definitions for the same namespace +

          Note

          This step avoids adding duplicate prefix definitions for the same namespace in the map. This has the side-effect of avoiding later serialization of duplicate namespace prefix declarations in any descendant nodes.

          @@ -1387,7 +1305,7 @@

          DOM Parsing and Serialization

          Note

          The empty string is a legitimate return value and is not converted to +

          Note

          The empty string is a legitimate return value and is not converted to null.

        @@ -1402,7 +1320,7 @@

        DOM Parsing and Serialization

        namespace prefix map will be populated by previously seen namespaceURIs and all their previously encountered prefix associations for a given node and its ancestors. -

        Note

        Note: the last seen prefix for a given +

        Note

        Note: the last seen prefix for a given namespaceURI is at the end of its respective list. The list is searched to find potentially matching prefixes, and if no matches are found for the given namespaceURI, then the last prefix in the list is used. See @@ -1426,7 +1344,7 @@

        DOM Parsing and Serialization

        Note

        There will always be at least one prefix value in the list.

        +
        Note

        There will always be at least one prefix value in the list.

        1. If prefix matches preferred prefix, then stop running these steps @@ -1463,7 +1381,7 @@

          DOM Parsing and Serialization

          Note

          The steps in retrieve a preferred prefix string use the list to +

          Note

          The steps in retrieve a preferred prefix string use the list to track the most recently used (MRU) prefix associated with a given namespace, which will be the prefix at the end of the list. This list may contain duplicates of the same prefix value seen earlier (and that's OK).

          @@ -1473,11 +1391,11 @@

          DOM Parsing and Serialization

          3.2.1.1.3 Serializing an Element's attributes
          -

          The XML serialization of the attributes of an Element +

          The XML serialization of the attributes of an Element element together with a namespace prefix map map, a generated namespace prefix index prefix index reference, a local prefixes map, a ignore namespace definition attribute flag, and a - require well-formed flag, is the result of the following algorithm: + require well-formed flag, is the result of the following algorithm:

          1. Let result be the empty string. @@ -1494,7 +1412,7 @@

            DOM Parsing and Serialization

            attributes, in the order they are specified in the element's attribute list:
              -
            1. If the require well-formed flag is set (its value is true), and the +
            2. If the require well-formed flag is set (its value is true), and the localname set contains a tuple whose values match those of a new tuple consisting of attr's namespaceURI attribute and localName attribute, then throw an exception; the serialization of @@ -1525,14 +1443,14 @@

              DOM Parsing and Serialization

              value is the XML namespace; -
              Note

              The XML namespace cannot be redeclared and survive +

              Note

              The XML namespace cannot be redeclared and survive round-tripping (unless it defines the prefix "xml"). To avoid this problem, this algorithm always prefixes elements in the XML namespace with "xml" and drops any related definitions as seen in the above condition.

            3. the attr's prefix is null and the ignore namespace definition attribute flag is true (the - Element's default namespace attribute should be skipped); + Element's default namespace attribute should be skipped);
            4. the attr's prefix is not null and either
                @@ -1551,16 +1469,16 @@

                DOM Parsing and Serialization

                require well-formed flag is set (its value is true), and +
              • If the require well-formed flag is set (its value is true), and the value of attr's value attribute matches the XMLNS namespace, then throw an exception; the serialization of this attribute would produce invalid XML because the XMLNS namespace is reserved and cannot be applied as an element's namespace via XML parsing. -
                Note

                DOM APIs do allow creation of elements in the XMLNS namespace but +

                Note

                DOM APIs do allow creation of elements in the XMLNS namespace but with strict qualifications.

                -
              • If the require well-formed flag is set (its value is true), and +
              • If the require well-formed flag is set (its value is true), and the value of attr's value attribute is the empty string, then throw an exception; namespace prefix declarations cannot be used to undeclare a namespace (use a default namespace declaration instead). @@ -1587,7 +1505,7 @@

                DOM Parsing and Serialization

                ="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK);

              • The result of serializing an attribute value given attribute namespace - and the require well-formed flag as input; + and the require well-formed flag as input;
              • """ (U+0022 QUOTATION MARK).
            @@ -1599,7 +1517,7 @@

            DOM Parsing and Serialization

            :" (U+003A COLON). -

          2. If the require well-formed flag is set (its value is true), and this +
          3. If the require well-formed flag is set (its value is true), and this attr's localName attribute contains the character ":" (U+003A COLON) or does not match the XML Name production or equals "xmlns" and attribute namespace is null, then @@ -1613,7 +1531,7 @@

            DOM Parsing and Serialization

            ="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK);

          4. The result of serializing an attribute value given attr's - value attribute and the require well-formed flag as input; + value attribute and the require well-formed flag as input;
          5. """ (U+0022 QUOTATION MARK).
          @@ -1622,10 +1540,10 @@

          DOM Parsing and Serialization

          serializing an attribute value given an attribute value and - require well-formed flag, the user agent must run the following steps: + require well-formed flag, the user agent must run the following steps:

            -
          1. If the require well-formed flag is set (its value is true), and +
          2. If the require well-formed flag is set (its value is true), and attribute value contains characters that are not matched by the XML Char production, then throw an exception; the serialization of this attribute value would fail to produce a well-formed element serialization. @@ -1643,7 +1561,7 @@

            DOM Parsing and Serialization

            >" with "&gt;"

          -
          Note

          This matches behavior present in browsers, and goes above and beyond the grammar +

          Note

          This matches behavior present in browsers, and goes above and beyond the grammar requirement in the XML specification's AttValue production by also replacing ">" characters.

        @@ -1677,7 +1595,7 @@

        DOM Parsing and Serialization

        producing an XML serialization of a DOM node of type Document is as follows: -

        If the require well-formed flag is set (its value is true), and this +

        If the require well-formed flag is set (its value is true), and this node has no documentElement (the documentElement attribute's value is null), then throw an exception; the serialization of this node would not be a well-formed @@ -1687,11 +1605,11 @@

        DOM Parsing and Serialization

        child child of node, in tree order, run the +

      10. For each child child of node, in tree order, run the XML serialization algorithm on the child passing along the provided arguments, and append the result to serialized document. -
        Note

        This will serialize any number of ProcessingInstruction and Comment +

        Note

        This will serialize any number of ProcessingInstruction and Comment nodes both before and after the Document's documentElement node, including at most one DocumentType node. (Text nodes are not allowed as children of the Document.)

        @@ -1706,7 +1624,7 @@

        DOM Parsing and Serialization

        producing an XML serialization of a DOM node of type Comment is as follows: -

        If the require well-formed flag is set (its value is true), and +

        If the require well-formed flag is set (its value is true), and node's data contains characters that are not matched by the XML Char production or contains "--" (two adjacent U+002D HYPHEN-MINUS characters) or that ends with a "-" (U+002D HYPHEN-MINUS) character, then @@ -1726,7 +1644,7 @@

        DOM Parsing and Serialization

        require well-formed flag is set (its value is true), and +
      11. If the require well-formed flag is set (its value is true), and node's data contains characters that are not matched by the XML Char production, then throw an exception; the serialization of this node's data would not be well-formed. @@ -1750,15 +1668,15 @@

        DOM Parsing and Serialization

        3.2.1.5 XML serializing a DocumentFragment node
        The algorithm for producing an XML serialization of a DOM node of type - DocumentFragment is as follows: + DocumentFragment is as follows:
        1. Let markup the empty string. -
        2. For each child child of node, in tree order, run the +
        3. For each child child of node, in tree order, run the XML serialization algorithm on the child given namespace, prefix map, a reference to prefix index, and flag - require well-formed. Concatenate the result to markup. + require well-formed. Concatenate the result to markup.
        4. Return the value of markup.
        @@ -1771,12 +1689,12 @@

        DOM Parsing and Serialization

        require well-formed flag is true and the node's +
      12. If the require well-formed flag is true and the node's publicId attribute contains characters that are not matched by the XML PubidChar production, then throw an exception; the serialization of this node would not be a well-formed document type declaration. -
      13. If the require well-formed flag is true and the node's +
      14. If the require well-formed flag is true and the node's systemId attribute contains characters that are not matched by the XML Char production or that contains both a """ (U+0022 QUOTATION MARK) and a "'" (U+0027 APOSTROPHE), then throw an exception; the serialization of this @@ -1789,7 +1707,7 @@

        DOM Parsing and Serialization

        " (U+0020 SPACE) to markup.

      15. Append the value of the node's name - attribute to markup. For a node belonging to an HTML document, the + attribute to markup. For a node belonging to an HTML document, the value will be all lowercase.
      16. If the node's publicId is not the empty string then append @@ -1843,13 +1761,13 @@

        DOM Parsing and Serialization

        ProcessingInstruction is as follows:
          -
        1. If the require well-formed flag is set (its value is true), and +
        2. If the require well-formed flag is set (its value is true), and node's target contains a ":" (U+003A COLON) character or is an ASCII case-insensitive match for the string "xml", then throw an exception; the serialization of this node's target would not be well-formed. -
        3. If the require well-formed flag is set (its value is true), and +
        4. If the require well-formed flag is set (its value is true), and node's data contains characters that are not matched by the XML Char production or contains the string "?>" (U+003F QUESTION MARK, U+003E GREATER-THAN SIGN), then throw an exception; the serialization of this @@ -1891,15 +1809,11 @@

          DOM Parsing and Serialization

          active document;

        5. Parsing concepts: - a fragment parsing context; - the HTML fragment parsing algorithm; - the HTML fragment serialization algorithm; + the fragment parsing algorithm; + the fragment serializing algorithm; HTML parser; parsing XHTML documents; - the XML fragment parsing algorithm; - the XML fragment serialization algorithm; XML parser; -
        6. A scripting flag
        7. A document location
        8. The following elements: meta, @@ -1907,8 +1821,9 @@

          DOM Parsing and Serialization

          script and template

        9. void elements -
        10. The template's template contents +
        11. The template's template contents
        12. The [CEReactions] IDL extended attribute +
        13. The innerHTML property;
        14. The DOM specification [DOM4] defines the following terms used in this document: @@ -1928,9 +1843,8 @@

          DOM Parsing and Serialization

          namespace concept; a node document; the append, - insert, - replace and - replace all operations; + insert and + replace operations; tree order; a range's start node; document URL; @@ -1959,7 +1873,7 @@

          DOM Parsing and Serialization

          element.namespaceURI and element.prefix attributes, setAttribute method -
        15. The Node interface +
        16. The Node interface
        17. The ProcessingInstruction interface and its target attribute
        18. The Range interface @@ -2046,7 +1960,7 @@

          DOM Parsing and Serialization

          innerHTML and outerHTML +

          Special thanks to Ian Hickson for first defining the innerHTML and outerHTML attributes, and the insertAdjacentHTML method in [HTML5] and his useful comments.

          @@ -2128,11 +2042,9 @@

          DOM Parsing and Serialization

          § 2.3 The InnerHTML mixin (2) (3) (4) (5) (6) (7) -

        19. - § 2.4 Extensions to the Element interface (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) + § 2.4 Extensions to the Element interface (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14)
        20. - § 2.5 Extensions to the Range interface (2) + § 2.5 Extensions to the Range interface (2)

      17. - -