Conversation
noamr
force-pushed
the
noamr/stream-html
branch
from
August 5, 2026 09:32
df24ea2 to
e416732
Compare
5 tasks done
noamr
force-pushed
the
noamr/stream-html
branch
from
August 6, 2026 16:23
e416732 to
5106e9d
Compare
noamr
force-pushed
the
noamr/stream-html
branch
from
August 6, 2026 19:46
deb55bb to
e97c374
Compare
noamr
force-pushed
the
noamr/stream-html
branch
from
August 7, 2026 20:17
d5a18a7 to
b19b385
Compare
noamr
force-pushed
the
noamr/stream-html
branch
from
August 11, 2026 15:49
d87ab8d to
4880d38
Compare
noamr
force-pushed
the
noamr/stream-html
branch
from
August 11, 2026 20:18
2de75ec to
ce9f49b
Compare
noamr
added a commit
to web-platform-tests/wpt
that referenced
this pull request
Aug 12, 2026
See whatwg/html#12758 Note that tests that assert how this works with <template for> are still tentative as that PR is still not landed.
zcorpan
approved these changes
Aug 12, 2026
noamr
force-pushed
the
noamr/stream-html
branch
from
August 12, 2026 13:02
421aa3f to
043dcdf
Compare
noamr
force-pushed
the
noamr/stream-html
branch
from
August 12, 2026 13:25
043dcdf to
286c499
Compare
noamr
force-pushed
the
noamr/stream-html
branch
from
August 12, 2026 16:08
286c499 to
146266b
Compare
noamr
force-pushed
the
noamr/stream-html
branch
from
August 14, 2026 08:56
146266b to
6e5c251
Compare
zcorpan
approved these changes
Aug 27, 2026
noamr
force-pushed
the
noamr/stream-html
branch
from
August 28, 2026 12:34
8376fee to
82e9336
Compare
noamr
force-pushed
the
noamr/stream-html
branch
3 times, most recently
from
August 28, 2026 14:27
8b318d5 to
2a95737
Compare
noamr
force-pushed
the
noamr/stream-html
branch
from
September 1, 2026 15:11
2a95737 to
67cae0b
Compare
noamr
force-pushed
the
noamr/stream-html
branch
2 times, most recently
from
September 1, 2026 17:07
b3835c2 to
a7f0a86
Compare
noamr
force-pushed
the
noamr/stream-html
branch
from
September 1, 2026 20:38
a7f0a86 to
9b016ad
Compare
noamr
force-pushed
the
noamr/stream-html
branch
from
September 1, 2026 20:44
9b016ad to
b61ef7d
Compare
noamr
force-pushed
the
noamr/stream-html
branch
from
September 2, 2026 10:26
b61ef7d to
8ae6011
Compare
noamr
force-pushed
the
noamr/stream-html
branch
from
September 2, 2026 14:58
8ae6011 to
f4db75c
Compare
zcorpan
approved these changes
Sep 4, 2026
Member
|
I squashed this and rebased it on #12756. Two conflicts, both from my "Don't look up custom element definitions for sanitized-away elements" commit (fab5f2b) and this PR independently factoring
Otherwise the diff is unchanged from before the rebase. |
zcorpan
reviewed
Sep 16, 2026
…ocumentTypeChildNode
…d handling
Net changes since the previously pushed version:
Stream semantics
* write() and close() no longer wait for scripts. write() resolves once the chunk has been parsed
as far as possible. If the parser is blocked on a parser-blocking script, input written in the
meantime accumulates and is parsed after that script runs. close() appends an explicit EOF and
resolves. Deferred and module scripts then run in later tasks, one per task.
* The streaming parser is now a script-created parser. Otherwise it would reach EOF at the end of
every chunk, rather than at the explicit EOF that close() appends.
* Removed the "reference child displaced" flag. A displaced reference child is only checked when
writing a chunk; close() doesn't check it. If the reference child is moved while a chunk is being
parsed (by a script or a custom element reaction), the nodes that would have been inserted before
it are dropped, and the next write() rejects with "HierarchyRequestError".
* Aborting the parser marks the script elements on the stack of open elements as already started,
so a partially parsed script never runs. It also unblocks rendering on pending and deferred
scripts. Removed the unused AbortSignal abort reason term.
Fragment parser script execution
* Fragment parsers block on scripts through the existing pending parsing-blocking script and the
parser pause flag. When the script is ready, a task runs the main parser's steps for executing
it, then resumes the parser.
* Added "run a fragment parser", and "execute the deferred scripts", which is the deferred-script
loop from "the end", now shared with fragment parsers.
* "The end" (stop parsing): fragment parsers pop the stack of open elements, so open elements such
as object, textarea and media elements are processed. They then queue a task to execute the
deferred scripts and return. There is no event loop spin, and no DOMContentLoaded or load on the
inert document.
* Push an element queue for fragment parsers too, so that when streaming into a connected node,
upgrades and lifecycle callbacks run before the next streamed script.
* SVG script elements are not processed when the fragment parser's script target document is its
own inert document, i.e., when it does not run scripts. This mirrors HTML scripts being marked as
already started.
* "Parser scripting disabled" is described as an initial value that initializing a fragment parser
overrides.
Element creation
* When creating an element, an intended parent that is in the insertion target redirection map is
replaced by its redirect target. When streaming, elements whose intended parent is the root html
element, or an element that the sanitizer replaces with its children, are therefore created in
the target's node document. Before, they were created in the parser's inert document and adopted
on insertion. They are now created the same way as their descendants, which are created after
their parent has been inserted into the target's node document.
API surface
* Streaming into an HTML or SVG script element throws "NotSupportedError". This applies to the
unsafe methods as well as the safe ones.
* The domintro now says that streamHTML*() and streamReplaceWithHTML*() remove the existing content
when they are called. The intro describes the corrected script timing.
Editorial
* Corrected the "stop parsing" fragment-case note, and listed all the Streams editors in [STREAMS].
* Infra wording ("of", "return"), inlined refChild, and wrapping fixes.
The change that keeps declarative shadow roots off elements that are replaced with their children
is sanitizer-only, so it moved to the streaming-sanitizer branch (#12756).
…agency reactions, abort and render-blocking, stream realm, force async note, Trusted Types domintros
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add streaming HTML insertion methods to Element, ShadowRoot, and ChildNode
Introduce safe and unsafe streaming HTML parsing and insertion methods:
Element&ShadowRoot: streamHTML(), streamHTMLUnsafe(), streamAppendHTML(), streamAppendHTMLUnsafe(), streamPrependHTML(), and streamPrependHTMLUnsafe()ChildNode: streamBeforeHTML(), streamBeforeHTMLUnsafe(), streamAfterHTML(), streamAfterHTMLUnsafe(), streamReplaceWithHTML(), and streamReplaceWithHTMLUnsafe()This allows developers to parse and stream HTML directly into specific positions of the DOM tree using
WritableStream.writeAlgorithm: converts chunks to DOMString, revalidates thatreferenceChild(if present) is still a child oftarget(aborting the parser and rejecting withHierarchyRequestErrorif displaced), feeds the chunk to the parser, and resolves when characters and parser-blocking scripts have executed.closeAlgorithm: revalidatesreferenceChild, appends an explicit EOF to the parser's input stream to finish parsing, and executes deferred and module scripts.abortAlgorithm: aborts the underlying HTML parser.Streaming fragment parsers can execute scripts when
runScriptsis true:script target document. Script elements created by the parser receive anintended documentset to this document.runScriptsis false (default), thescript target documentis the temporary inert document, preventing script execution.runScriptsis true, thescript target documentis the context element's node document.<script>element throws aNotSupportedErrorDOMException.HTMLTemplateElementinsertion targets are redirected to theircontentDocumentFragment before any mutation.ChildNodemethods, disconnected nodes are validated viaparent for HTML streaming(throwingHierarchyRequestErrorif no suitable parent exists).replace all with nullforstreamHTMLor removal of the node forstreamReplaceWithHTML).Unsafe streaming methods accept
(SetHTMLUnsafeOptions or TrustedHTMLParserOptions)using theStreamsink type.Closes #2142
streamHTMLtests web-platform-tests/wpt#61748(https://github.com/whatwg/meta/blob/main/COMMITTING.md) to use.
(See WHATWG Working Mode: Changes for more details.)
/dynamic-markup-insertion.html ( diff )
/index.html ( diff )
/infrastructure.html ( diff )
/parsing.html ( diff )
/references.html ( diff )
/scripting.html ( diff )
/xhtml.html ( diff )