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" }
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 @@ 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.
-
-
innerHTML
[ = value ]
- 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: - -
template
element, then let
- context object be the template
's template contents (a
- DocumentFragment
).
-
-
-
- The definition of InnerHTML
has moved to the HTML Standard.
Element
interfaceElement
interfaceWebIDLpartial interface
"Element
{ - [CEReactions] attribute [LegacyNullToEmptyString] HTMLStringouterHTML
; - [CEReactions] undefinedinsertAdjacentHTML
(DOMString position, HTMLString text); +WebIDLpartial interface
Element
{ + [CEReactions] attribute [LegacyNullToEmptyString] HTMLStringouterHTML
; + [CEReactions] undefinedinsertAdjacentHTML
(DOMString position, HTMLString text); };The
outerHTML
IDL attribute represents the markup of the -and its contents. +
Element
and its contents.
Element
-
- 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 aDocument
.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:
-
@@ -685,11 +640,11 @@- Let parent be the context object's parent. +
- Let parent be the context object's parent.
- 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.
- If parent is a
Document
, throw a - "NoModificationAllowedError
"DOMException
. + "NoModificationAllowedError
"DOMException
. -- If parent is a
DocumentFragment
, let parent be a - newwith: +
Element
- If parent is a
DocumentFragment
, let parent be a + newwith:
Element
-
body
as its local name,- The HTML namespace as its namespace, and -
- The context object's node document as its node document. +
- The context object's node document as its node document.
- Let fragment be the result of invoking the fragment parsing algorithm with +
- Let fragment be the result of invoking the fragment parsing algorithm with the new value as markup, and parent as the context element. -
- Replace the context object with fragment within the - context object's parent. +
- Replace the context object with fragment within the + context object's parent.
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 "
@@ -706,22 +661,22 @@NoModificationAllowedError
"DOMException
if the given position isn't possible (e.g. inserting elements after the root element of aDocument
).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
or the following are all true: +
Element
- If context is not an
or the following are all true:
Element
-
- context's node document is an HTML document, @@ -731,17 +686,17 @@
DOM Parsing and Serialization
HTML namespace;
let context be a new
with +
Element
let context be a new
with
Element
-
body
as its local name,- The HTML namespace as its namespace, and -
- The context object's node document as its node document. +
- The context object's node document as its node document.
- 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.
NoteNo special handling for
template
elements is included in the +@@ -782,12 +737,12 @@NoteNo 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 atemplate
+template
elements. In most cases you will wish to use + template.content.insertAdjacentHTML
+ instead of directly manipulating the child nodes of atemplate
element.DOM Parsing and Serialization
2.5 Extensions to the
interface
Range
WebIDLpartial interface
Range
{ - [CEReactions, NewObject] DocumentFragmentcreateContextualFragment
(HTMLString fragment); + [CEReactions, NewObject] DocumentFragmentcreateContextualFragment
(HTMLString fragment); };@@ -796,16 +751,16 @@
- 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.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-
- "
body
" as its local name,- The HTML namespace as its namespace, and -
- The context object's node document as its node document. +
- The context object's node document as its node document.
- 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
-
The following steps form the fragment parsing algorithm, whose arguments are a - markup string and a context element: - -
-
+- 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. + -
- Let new children be the result of invoking algorithm with - markup as the input, and context element as the - context element. - -
- Let fragment be a new
DocumentFragment
whose - node document is context element's node document. - -- Append each Node in new children to fragment (in - tree order). - -
- -NoteThis ensures the node document for the new nodes is correct.
- Return the value of fragment. -
The definition of
fragment parsing algorithm
has moved to the HTML Standard.- The following steps form the fragment serializing algorithm, whose arguments are a -
Node
node and a flag require well-formed: - --
+ -- Let context document be the value of node's node document. - -
- If context document is an HTML document, return an - HTML serialization of node. - -
- Otherwise, context document is an XML document; return an - XML serialization of node passing the flag require well-formed. - -
-NoteThe 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.+ - An XML serialization differs from an HTML serialization in the following ways: +
An XML serialization differs from an HTML serialization in the following ways:
-
-Elements
and attributes will always be serialized such +Elements
and attributes will always be serialized such that theirnamespaceURI
is preserved. In some cases this means that an existingprefix
, prefix declaration attribute or default namespace declaration attribute - might be dropped, substituted or changed. An HTML serialization does not attempt to + might be dropped, substituted or changed. An HTML serialization does not attempt to preserve thenamespaceURI
. -Elements
not in the HTML namespace containing no children, are +Elements
not in the HTML namespace containing no children, are serialized using the empty-element tag syntax (i.e., according to the XML EmptyElemTag production).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. -
NotePer [DOM4],
Attr
objects do not inherit from Node, and +NotePer [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:
- 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 anElement
Node has + The context namespace tracks the XML serialization algorithm's current default + namespace. The context namespace is changed when either anElement
Node has a default namespace declaration, or the algorithm generates a default namespace declaration for - theElement
Node to match its own namespace. The algorithm assumes no namespace + theElement
Node to match its own namespace. The algorithm assumes no namespace (null
) to start.- 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
- 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 typeElement
is as follows:-
- If the require well-formed flag is set (its value is
true
), +- If the require well-formed flag is set (its value is
true
), and this node'slocalName
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. -
- Let local prefixes map be an empty map. The map has unique Node +
- Let local prefixes map be an empty map. The map has unique Node
prefix
strings as its keys, with correspondingnamespaceURI
- Node values as the map's key values (in this map, thenull
namespace is + Node values as the map's key values (in this map, thenull
namespace is represented by the empty string). -NoteThis map is local to each element. It is used to ensure there are no conflicting +
NoteThis 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 aprefix
in the - namespace prefix map that might be locally-defined (to the currentElement
) and + namespace prefix map that might be locally-defined (to the currentElement
) and one that is not.- Let local default namespace be the result of recording the namespace information for node given map and local prefixes map. -
NoteThe above step will update map with any found namespace prefix +
@@ -1091,14 +1009,14 @@NoteThe 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
.DOM Parsing and Serialization
retrieving a preferred prefix string prefix from map given namespace ns. -
NoteThe above may return
null
if no namespace key ns exists +NoteThe above may return
null
if no namespace key ns exists in map.- If the value of prefix matches "
xmlns
", then run the following steps:-
- If the require well-formed flag is set, then throw an error. An -
Element
withprefix
"xmlns
" +- If the require well-formed flag is set, then throw an error. An +
Element
withprefix
"xmlns
" will not legally round-trip in a conforming XML parser.- 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: -NoteThe following may serialize a different -
prefix
than theElement
's existing +@@ -1128,7 +1046,7 @@NoteThe following may serialize a different +
prefix
than theElement
's existingprefix
if it already had one. However, the retrieving a preferred prefix string algorithm already tried to match the existing prefix if possible.DOM Parsing and Serialization
context namespace is changed to the declared default, rather than this node's own namespace). -
NoteAny default namespace definitions or namespace prefixes that define the +
NoteAny default namespace definitions or namespace prefixes that define the XML namespace are omitted when serializing this node's attributes.
- Append the value of qualified name to markup. @@ -1136,7 +1054,7 @@
DOM Parsing and Serialization
NoteBy this step, there is no namespace or prefix mapping declaration in this +
NoteBy 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
NoteThe following serializes a namespace prefix declaration for prefix +
NoteThe 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);
- The result of serializing an attribute value given ns and the - require well-formed flag as input; + require well-formed flag as input;
- "
"
" (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: -NoteAt this point, the namespace for this node still needs to be serialized, but +
@@ -1201,15 +1119,15 @@NoteAt 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.DOM Parsing and Serialization
inherited ns be ns. -
NoteThe new default namespace will be used in the serialization to define this +
+ children.NoteThe new default namespace will be used in the serialization to define this node's namespace and act as the context namespace for its - children.
- Append the value of qualified name to markup.
- Append the following to markup, in the order listed: -
NoteThe following serializes the new (or replacement) default namespace +
NoteThe following serializes the new (or replacement) default namespace definition.
@@ -1220,7 +1138,7 @@
@@ -1231,7 +1149,7 @@DOM Parsing and Serialization
="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK);
- The result of serializing an attribute value given ns and the - require well-formed flag as input; + require well-formed flag as input;
- "
"
" (U+0022 QUOTATION MARK).DOM Parsing and Serialization
localName, let the value of inherited ns be ns, and append the value of qualified name to markup. -
NoteAll of the combinations where ns is not equal to +
@@ -1240,10 +1158,10 @@NoteAll of the combinations where ns is not equal to inherited ns are handled above such that node will be serialized preserving its original
namespaceURI
.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.
- 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'slocalName
matches any one of the following void elements: "area
", "base
", @@ -1273,7 +1191,7 @@DOM Parsing and Serialization
skip end tag flag to
true
.- 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 totrue
.- 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 (aDocumentFragment
), providing +template
element. Append to markup the result of + XML serializing a DocumentFragment node given the template element's + template contents (aDocumentFragment
), providing inherited ns, map, prefix index, and the - require well-formed flag. + require well-formed flag. -NoteThis allows template content to round-trip , given the rules for +
NoteThis allows template content to round-trip , given the rules for parsing XHTML documents.
- 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.
- 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, 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 @@
Element
DOM Parsing and Serialization
attributes, in the order they are specified in the element's attribute list: -
NoteThe following conditional steps find namespace prefixes. Only attributes +
@@ -1359,7 +1277,7 @@NoteThe 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).DOM Parsing and Serialization
XML namespace, then stop running these steps, and return to Main to visit the next attribute. -
NoteXML namespace definitions in prefixes are completely ignored (in +
@@ -1372,7 +1290,7 @@NoteXML 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.DOM Parsing and Serialization
Main to visit the next attribute. -
NoteThis step avoids adding duplicate prefix definitions for the same namespace +
@@ -1387,7 +1305,7 @@NoteThis 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.
DOM Parsing and Serialization
NoteThe empty string is a legitimate return value and is not converted to +
@@ -1402,7 +1320,7 @@NoteThe empty string is a legitimate return value and is not converted to
null
.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. -
NoteNote: the last seen
prefix
for a given ++NoteNote: the last seen
prefix
for a givennamespaceURI
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 givennamespaceURI
, then the lastprefix
in the list is used. See @@ -1426,7 +1344,7 @@DOM Parsing and Serialization
NoteThere will always be at least one prefix value in the list.
NoteThere will always be at least one prefix value in the list.
- If prefix matches preferred prefix, then stop running these steps @@ -1463,7 +1381,7 @@
DOM Parsing and Serialization
NoteThe steps in retrieve a preferred prefix string use the list to +
@@ -1473,11 +1391,11 @@NoteThe 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).
DOM Parsing and Serialization
-
The XML serialization of the attributes of an
+
Element
The XML serialization of the attributes of an
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:
Element
- 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:
-
- If the require well-formed flag is set (its value is
true
), and the +- 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'snamespaceURI
attribute andlocalName
attribute, then throw an exception; the serialization of @@ -1525,14 +1443,14 @@DOM Parsing and Serialization
value is the XML namespace; -
NoteThe XML namespace cannot be redeclared and survive +
NoteThe 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.- the attr's
prefix
isnull
and the ignore namespace definition attribute flag istrue
(the -Element
's default namespace attribute should be skipped); +Element
's default namespace attribute should be skipped);- the attr's
prefix
is notnull
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'svalue
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. -NoteDOM APIs do allow creation of elements in the XMLNS namespace but +
-NoteDOM 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'svalue
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;
- "
@@ -1599,7 +1517,7 @@"
" (U+0022 QUOTATION MARK).DOM Parsing and Serialization
:" (U+003A COLON). -
- 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 attr'slocalName
attribute contains the character ":
" (U+003A COLON) or does not match the XML Name production or equals "xmlns
" and attribute namespace isnull
, then @@ -1613,7 +1531,7 @@DOM Parsing and Serialization
="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK);
- 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;- "
@@ -1622,10 +1540,10 @@"
" (U+0022 QUOTATION MARK).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:
-
-- 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 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 "
>
"NoteThis matches behavior present in browsers, and goes above and beyond the grammar +
@@ -1677,7 +1595,7 @@NoteThis matches behavior present in browsers, and goes above and beyond the grammar requirement in the XML specification's AttValue production by also replacing "
>
" characters.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 nodocumentElement
(thedocumentElement
attribute's value isnull
), 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 +
- 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. -
NoteThis will serialize any number of ProcessingInstruction and Comment +
@@ -1706,7 +1624,7 @@NoteThis 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.)
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'sdata
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 +- If the require well-formed flag is set (its value is
true
), and node'sdata
contains characters that are not matched by the XML Char production, then throw an exception; the serialization of this node'sdata
would not be well-formed. @@ -1750,15 +1668,15 @@DOM Parsing and Serialization
The algorithm for producing an XML serialization of a DOM node of type - DocumentFragment is as follows: + DocumentFragment is as follows:
@@ -1771,12 +1689,12 @@
- Let markup the empty string. -
- For each child child of node, in tree order, run the +
- 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.
- Return the value of markup.
DOM Parsing and Serialization
require well-formed flag is
true
and the node's +- If the require well-formed flag is
true
and the node'spublicId
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. -- If the require well-formed flag is
true
and the node's +- If the require well-formed flag is
true
and the node'ssystemId
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.
- 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.- If the node's
publicId
is not the empty string then append @@ -1843,13 +1761,13 @@DOM Parsing and Serialization
ProcessingInstruction 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'starget
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'starget
would not be well-formed. -- 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'sdata
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;
- 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; -
- A scripting flag
- A document location
- The following elements: meta, @@ -1907,8 +1821,9 @@
DOM Parsing and Serialization
script and template
- void elements -
- The template's template contents +
- The template's template contents
- The [CEReactions] IDL extended attribute +
- The innerHTML property;
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 -
- The Node interface +
- The Node interface
- The ProcessingInstruction interface and its target attribute
- 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
@@ -2128,11 +2042,9 @@outerHTML
attributes, and theinsertAdjacentHTML
method in [HTML5] and his useful comments.DOM Parsing and Serialization
§ 2.3 The InnerHTML mixin (2) (3) (4) (5) (6) (7) -
- - § 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)
- - § 2.5 Extensions to the Range interface (2) + § 2.5 Extensions to the Range interface (2)
@@ -2218,36 +2130,6 @@DOM Parsing and Serialization
§ 2.2 The XMLSerializer interface (2) - -
- - -Referenced in:
- -@@ -2289,34 +2171,18 @@DOM Parsing and Serialization
§ 2.5 Extensions to the Range interface (2) -
- -- Permalink - --Referenced in:
- -+Referenced in:
@@ -2330,59 +2196,25 @@DOM Parsing and Serialization
§ 2.2 The XMLSerializer interface
- - § 2.3 The InnerHTML mixin -
- - § 2.4 Extensions to the Element interface -
- - § 3.2 Serializing + § 2.4 Extensions to the Element interface
- - § 3.2.1 XML Serialization (2) (3) + § 3.2.1 XML Serialization (2) (3)
- - § 3.2.1.1 XML serializing an Element node (2) (3) (4) (5) (6) (7) + § 3.2.1.1 XML serializing an Element node (2) (3) (4) (5) (6) (7)
- - § 3.2.1.1.3 Serializing an Element's attributes (2) (3) (4) (5) (6) (7) (8) (9) + § 3.2.1.1.3 Serializing an Element's attributes (2) (3) (4) (5) (6) (7) (8) (9)
- - § 3.2.1.2 XML serializing a Document node + § 3.2.1.2 XML serializing a Document node
- - § 3.2.1.3 XML serializing a Comment node + § 3.2.1.3 XML serializing a Comment node
- - § 3.2.1.4 XML serializing a Text node + § 3.2.1.4 XML serializing a Text node
- - § 3.2.1.5 XML serializing a DocumentFragment node -
- - § 3.2.1.6 XML serializing a DocumentType node (2) -
- - § 3.2.1.7 XML serializing a ProcessingInstruction node (2) -
- -- -- Permalink - --Referenced in:
--
-- - § 3.2 Serializing -
- - § 3.2.1 XML Serialization (2) -
-- -- Permalink - --Referenced in:
-@@ -2893,40 +2725,30 @@DOM Parsing and Serialization
- -
- Permalink - --Referenced in:
--
-- - § 3.1 Parsing -
-+Referenced in:
-+Referenced in:
@@ -2952,30 +2774,6 @@DOM Parsing and Serialization
§ 3.2.1.1 XML serializing an Element node - -
@@ -2989,16 +2787,6 @@DOM Parsing and Serialization
§ 3.2.1.1 XML serializing an Element node -
@@ -3048,13 +2836,11 @@DOM Parsing and Serialization
§ 2.3 The InnerHTML mixin (2) (3) (4) -
- - § 2.4 Extensions to the Element interface (2) (3) (4) + § 2.4 Extensions to the Element interface (2) (3) (4)
- - § 3.2.1.1 XML serializing an Element node (2) + § 3.2.1.1 XML serializing an Element node (2)
- - § A. Dependencies + § A. Dependencies
@@ -3078,11 +2864,9 @@DOM Parsing and Serialization
§ 2.3 The InnerHTML mixin (2) (3) + § 2.4 Extensions to the Element interface
- - § 2.4 Extensions to the Element interface -
- - § 3.2.1.1 XML serializing an Element node (2) + § 3.2.1.1 XML serializing an Element node (2)
@@ -3130,17 +2930,15 @@DOM Parsing and Serialization
§ 2.3 The InnerHTML mixin -
- - § 2.4 Extensions to the Element interface + § 2.4 Extensions to the Element interface
- - § 3.2.1 XML Serialization (2) + § 3.2.1 XML Serialization (2)
- - § 3.2.1.1 XML serializing an Element node (2) (3) (4) + § 3.2.1.1 XML serializing an Element node (2) (3) (4)
- - § 3.2.1.2 XML serializing a Document node + § 3.2.1.2 XML serializing a Document node
- - § 3.2.1.5 XML serializing a DocumentFragment node + § 3.2.1.5 XML serializing a DocumentFragment node
@@ -3212,11 +3010,7 @@DOM Parsing and Serialization
§ 2.5 Extensions to the Range interface
- - § 3.1 Parsing -
- - § 3.2 Serializing -
- - § 3.2.1.6 XML serializing a DocumentType node + § 3.2.1.6 XML serializing a DocumentType node
@@ -3261,10 +3055,6 @@DOM Parsing and Serialization
§ 2.4 Extensions to the Element interface (2) (3) (4) (5)
- § 2.5 Extensions to the Range interface (2) (3) -
- - § 3.1 Parsing (2) (3) (4) (5) -
- - § 3.2 Serializing
@@ -3277,8 +3067,6 @@DOM Parsing and Serialization
§ 2.4 Extensions to the Element interface -
- - § 3.1 Parsing
@@ -3304,18 +3092,6 @@DOM Parsing and Serialization
§ 2.4 Extensions to the Element interface - -
@@ -3326,13 +3102,11 @@DOM Parsing and Serialization
§ 3.1 Parsing -
- - § 3.2.1.1 XML serializing an Element node + § 3.2.1.1 XML serializing an Element node
- - § 3.2.1.2 XML serializing a Document node + § 3.2.1.2 XML serializing a Document node
- - § 3.2.1.5 XML serializing a DocumentFragment node + § 3.2.1.5 XML serializing a DocumentFragment node
@@ -3366,13 +3140,7 @@DOM Parsing and Serialization
§ 2.3 The InnerHTML mixin -
- - § 2.4 Extensions to the Element interface (2) -
- - § 3.1 Parsing -
- - § 3.2 Serializing + § 2.4 Extensions to the Element interface (2)
@@ -3590,19 +3358,15 @@DOM Parsing and Serialization
§ 2.3 The InnerHTML mixin -
- - § 2.4 Extensions to the Element interface -
- - § 2.5 Extensions to the Range interface (2) (3) + § 2.4 Extensions to the Element interface
- - § 3.1 Parsing + § 2.5 Extensions to the Range interface (2) (3)
- - § 3.2.1 XML Serialization + § 3.2.1 XML Serialization
- - § 3.2.1.1 XML serializing an Element node + § 3.2.1.1 XML serializing an Element node
- - § 3.2.1.5 XML serializing a DocumentFragment node + § 3.2.1.5 XML serializing a DocumentFragment node
@@ -3616,19 +3380,17 @@DOM Parsing and Serialization
§ 1. Introduction
- - § 2.3 The InnerHTML mixin + § 2.4 Extensions to the Element interface (2) (3) (4) (5) (6)
- - § 2.4 Extensions to the Element interface (2) (3) (4) (5) (6) + § 2.5 Extensions to the Range interface (2)
- - § 2.5 Extensions to the Range interface (2) + § 3.2.1 XML Serialization (2) (3) (4) (5)
- - § 3.2.1 XML Serialization (2) (3) (4) (5) + § 3.2.1.1 XML serializing an Element node (2) (3) (4)
- - § 3.2.1.1 XML serializing an Element node (2) (3) (4) + § 3.2.1.1.1 Recording the namespace
- - § 3.2.1.1.1 Recording the namespace -
- - § 3.2.1.1.3 Serializing an Element's attributes (2) + § 3.2.1.1.3 Serializing an Element's attributes (2)
@@ -3708,13 +3470,9 @@DOM Parsing and Serialization
§ 2.4 Extensions to the Element interface
- - § 3.1 Parsing (2) -
- - § 3.2 Serializing (2) + § 3.2.1 XML Serialization (2) (3) (4) (5)
- - § 3.2.1 XML Serialization (2) (3) (4) (5) -
- - § 3.2.1.1 XML serializing an Element node (2) + § 3.2.1.1 XML serializing an Element node (2)
@@ -3786,11 +3544,9 @@DOM Parsing and Serialization
§ 2.3 The InnerHTML mixin (2) -
- - § 2.4 Extensions to the Element interface (2) (3) (4) (5) (6) (7) (8) + § 2.4 Extensions to the Element interface (2) (3) (4) (5) (6) (7) (8)
- - § 3.2.1 XML Serialization + § 3.2.1 XML Serialization
@@ -3802,11 +3558,9 @@DOM Parsing and Serialization
§ 2.3 The InnerHTML mixin -
- - § 2.4 Extensions to the Element interface + § 2.4 Extensions to the Element interface
- - § 3.2.1 XML Serialization + § 3.2.1 XML Serialization
@@ -3830,9 +3584,7 @@DOM Parsing and Serialization
§ 2.3 The InnerHTML mixin -
- - § 2.4 Extensions to the Element interface (2) (3) + § 2.4 Extensions to the Element interface (2) (3)
@@ -3960,11 +3712,9 @@DOM Parsing and Serialization
§ 2.3 The InnerHTML mixin -
- - § 2.4 Extensions to the Element interface (2) + § 2.4 Extensions to the Element interface (2)
- - § 2.5 Extensions to the Range interface + § 2.5 Extensions to the Range interface