From 02cb9fc6aefa63e25af88139e72cb27cea28ecad Mon Sep 17 00:00:00 2001
From: Anne van Kesteren
Let algorithm be the HTML fragment parsing algorithm.
Let algorithm be the HTML fragment parsing algorithm.
If context's node document is an XML document, then set algorithm to the XML fragment parsing - algorithm.
If context's node document is an XML + document, then set algorithm to the XML fragment parsing + algorithm.
Let new children be the result of invoking algorithm given - markup, with context set to - context.
Let newChildren be the result of invoking algorithm given + context and markup.
Let fragment be a new DocumentFragment
whose node
- document is context's node document.
Let fragment be a new DocumentFragment
whose node
+ document is context's node document.
Append each Node
in new
- children to fragment (in tree order).
For each node of newChildren, in tree order: append node to fragment.
-This ensures the node document for the new nodes is correct.
-This ensures the node document for the new nodes is correct.
+ -Return fragment.
Return fragment.
The following steps form the HTML fragment parsing algorithm. The algorithm
- takes as input an Parts marked fragment case in algorithms in the parser section are
- parts that only occur if the parser was created for the purposes of this algorithm. The algorithms have been annotated
- with such markings for informational purposes only; such markings have no normative weight. If it
- is possible for a condition described as a fragment case to occur even when the
- parser wasn't created for the purposes of handling this algorithm, then that is an error in the
- specification. The HTML fragment parsing algorithm given an Parts marked fragment case in algorithms in the HTML
+ parser section are parts that only occur if the parser was created for the purposes of this
+ algorithm. The algorithms have been annotated with such markings for informational purposes only;
+ such markings have no normative weight. If it is possible for a condition described as a
+ fragment case to occur even when the parser wasn't created for the purposes of
+ handling this algorithm, then that is an error in the specification. Create a new Let document be a If the
- node document of the context element is in
- quirks mode, then let the If context's node document is
+ in quirks mode, then set document's mode to " If allowDeclarativeShadowRoots is true, then set the Otherwise, if context's node
+ document is in limited-quirks mode, then set document's mode to " Create a new HTML parser, and associate it with the just created
- If allowDeclarativeShadowRoots is true, then set document's allow declarative shadow roots to
+ true. Create a new HTML parser, and associate it with document. Set the state of the HTML parser's tokenization stage as
follows, switching on the context element:Element
's Parsing HTML fragments
-
Element
node, referred to as the context element, which gives the context for
- the parser, input, a string to parse, and an optional boolean
- allowDeclarativeShadowRoots (default false). It returns a list of zero or more
- nodes.Element
node context, string input, and an
+ optional boolean allowDeclarativeShadowRoots (default false) are the following steps.
+ They return a list of zero or more nodes.
-
Document
node, and mark it as being an HTML document.Document
node whose type is "html
".Document
be in quirks mode.
- Otherwise, if the
- node document of the context element is in
- limited-quirks mode, then let the Document
be in limited-quirks
- mode. Otherwise, leave the Document
in no-quirks mode.quirks
".Document
's
- allow declarative shadow
- roots to true.limited-quirks
".Document
node.
-
@@ -134364,35 +134342,29 @@ console.assert(container.firstChild instanceof SuperP);
transitions.title
textarea
style
xmp
iframe
noembed
noframes
script
noscript
plaintext
Let root be a new html
element with no attributes.
Let root be the result of creating an
+ element given document, "html
", and the HTML
+ namespace.
Append the element root to the Document
node created
- above.
Append root to + document.
Set up the parser's stack of open elements so that it contains just the single - element root.
-Set up the HTML parser's stack of open elements so that it + contains just the single element root.
If the context element is a
- template
element, push "in
- template" onto the stack of template insertion modes so that it is the new
- current template insertion mode.
If context is a template
+ element, then push "in template" onto the
+ stack of template insertion modes so that it is the new current template
+ insertion mode.
Create a start tag token whose name is the local name of context and whose attributes are the attributes of context.
-Let this start tag token be the start tag token of the context node, e.g. for the purposes of determining - if it is an HTML integration point.
+Let this start tag token be the start tag token of context, e.g. for the purposes of determining if it is + an HTML integration point.
Set the parser's form
element pointer to the nearest node to the
- context element that is a form
- element (going straight up the ancestor chain, and including the element itself, if it is a
- form
element), if any. (If there is no such form
element, the
- form
element pointer keeps its initial value, null.)
Set the HTML parser's form
element pointer to the
+ nearest node to context that is a
+ form
element (going straight up the ancestor chain, and including the element
+ itself, if it is a form
element), if any. (If there is no such form
+ element, the form
element pointer keeps its initial value,
+ null.)
Place the input into the input stream for the HTML - parser just created. The encoding confidence is irrelevant.
-Place the input into the input stream for the HTML + parser just created. The encoding confidence is irrelevant.
Start the parser and let it run until it has consumed all the characters just inserted into - the input stream.
-Start the HTML parser and let it run until it has consumed all the characters + just inserted into the input stream.
Return the child - nodes of root, in tree order.
-Return root's children, in tree + order.
The XML fragment parsing algorithm either returns a Document
or throws
- a "SyntaxError
" DOMException
. Given a string
- input and a context element context, the
- algorithm is as follows:
The XML fragment parsing algorithm given an Element
node context and a string input, runs the
+ following steps. They return a list of nodes.
Create a new XML parser.
-Create a new XML parser.
Feed the - parser just created the string corresponding to the start tag of the context element, declaring - all the namespace prefixes that are in scope on that element in the DOM, as well as declaring - the default namespace (if any) that is in scope on that element in the DOM.
+Feed the parser just created the string corresponding to the start tag of context, declaring all the namespace prefixes that are + in scope on that element in the DOM, as well as declaring the default namespace (if any) that is + in scope on that element in the DOM.
A namespace prefix is in scope if the DOM lookupNamespaceURI()
method
on the element would return a non-null value for that prefix.
The default namespace is the namespace for which the DOM isDefaultNamespace()
method on the element would return true.
No
- DOCTYPE
is passed to the parser, and therefore no external subset is
- referenced, and therefore no entities will be recognized.
Feed the parser just created the string input.
+No DOCTYPE
is passed to the parser, and therefore no
+ external subset is referenced, and therefore no entities will be recognized.
Feed the parser just created the string corresponding to the end tag of the context element.
-Feed the parser just created the string input.
If there is an XML well-formedness or XML namespace well-formedness error, then throw a
- "SyntaxError
" DOMException
.
Feed the parser just created the string corresponding to the end tag of context.
If the document element of the resulting Document
has any sibling
- nodes, then throw a "SyntaxError
" DOMException
.
If there is an XML well-formedness or XML namespace well-formedness error, then throw a
+ "SyntaxError
" DOMException
.
If the document element of the resulting Document
has any
+ sibling nodes, then throw a "SyntaxError
"
+ DOMException
.
Return the child nodes of the document element of the resulting
- Document
, in tree order.
Return the resulting Document
node's document element's children, in tree order.