HtmlStreamWriter Class
- Experimental (WEBPLATEXP0002)
The writer of the HTML streamed into an element or a shadow root (https://whatpr.org/html/12758/dynamic-markup-insertion.html#stream-html), returned by Element.StreamAppendHtmlUnsafe and the other streaming methods: the chunks are parsed as they are written, by a fragment parser that inserts the nodes directly into the target (before the reference child), so the template for elements patch the content as it arrives. In JavaScript, the methods return a WritableStream whose sink is this writer.
[Experimental("WEBPLATEXP0002", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public sealed class HtmlStreamWriterProperties
| Name | Description |
|---|---|
| IsCompleted | Gets whether the stream is closed or aborted: the writer cannot be written to anymore. |
IsCompleted
HtmlStreamWriter.csMethods
| Name | Description |
|---|---|
| Abort() | Aborts the parser: the rest of the input is not parsed, and the script elements that are still open never run. |
| Close() | Parses the end of the input (the close algorithm of https://whatpr.org/html/12758/dynamic-markup-insertion.html#stream-html). |
| Write(string) | Parses a chunk of HTML, after the previous chunks (the write algorithm of https://whatpr.org/html/12758/dynamic-markup-insertion.html#stream-html). |
Abort()
HtmlStreamWriter.csAborts the parser: the rest of the input is not parsed, and the script elements that are still open never run.
public void Abort()Close()
HtmlStreamWriter.csParses the end of the input (the close algorithm of https://whatpr.org/html/12758/dynamic-markup-insertion.html#stream-html).
public void Close()Exceptions
InvalidOperationException- The writer is closed or aborted.
Write(string)
HtmlStreamWriter.csParses a chunk of HTML, after the previous chunks (the write algorithm of https://whatpr.org/html/12758/dynamic-markup-insertion.html#stream-html).
Parameters
chunkstring
Exceptions
InvalidOperationException- The writer is closed or aborted.
DomException- The reference child is no longer a child of the target: the parser is aborted.