Processing Instruction: Serialize with "?>" close#12654
Conversation
|
I've done a quick survey of some major browsers using the following: const doc = document.createDocumentFragment();
doc.append( document.createElement( 'p' ) );
doc.firstChild.append( document.createProcessingInstruction( 't', 'd' ) );
doc.firstChild.outerHTML
|
|
This seems like a change we should make. We don't want |
| by the value of <var>current node</var>'s <span data-x="concept-cd-data">data</span>, | ||
| followed by a single U+003E GREATER-THAN SIGN character (>).</p> | ||
| followed by the literal string "<code data-x="">?></code>" (U+003F QUESTION MARK, | ||
| U+003E GREATER-THAN SIGN).</p> |
There was a problem hiding this comment.
Maybe we can take this opportunity to clean this up a bit. For strings we don't have to state the code points afterwards.
Instead of referencing the IDL attribute we want to reference https://dom.spec.whatwg.org/#concept-pi-target.
We don't have to say U+0020 SPACE character. We can just say U+0020 SPACE.
There was a problem hiding this comment.
I updated the DOM reference for PI target. There was an existing example I reused from elsewhere.
The section was inconsistent and needlessly verbose, especially compared with the preceding shadow host rules that exclusively uses quoted strings instead of mentioning Unicode codepoints. I've preferred the string form every except for isolated U+0020 SPACE.
The change is more involved, but I think the result is cleaner, clearer, and more consistent. The resulting DocumentType serialization seems particularly improved:
-Append "<!DOCTYPE" (U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN CAPITAL LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL LETTER E), followed by a space (U+0020 SPACE), followed by the value of current node's name, followed by ">" (U+003E GREATER-THAN SIGN).
+Append "<!DOCTYPE ", followed by the value of current node's name, and "?>".There was a problem hiding this comment.
I notice one related point in the DOM features section. PI interface and PI target are listed separatedly, while other interfaces are on the same bullet point. Shall I combine them?
- Document interface and its doctype attribute
- ProcessingInstruction interface
- …
- processing instruction target
This could be:
- ProcessingInstruction interface and its target attribute
There was a problem hiding this comment.
Thanks, this made me realize we had the wrong link (also in another place). Fixed.
|
Yea the arguments here are good. Consider blink interested. |
- character by character string descriptiongs - U+0020 SPACE doesn't need "character"
|
@foolip can you update your test PR to match this change? |
|
I've updated web-platform-tests/wpt#57486 to match now. |
For whatwg/html#12654. Co-authored-by: Jon Surrell <sirreal@users.noreply.github.com>
…tions in HTML, a=testonly Automatic update from web-platform-tests Test serialization of processing instructions in HTML For whatwg/html#12654. Co-authored-by: Jon Surrell <sirreal@users.noreply.github.com> -- wpt-commits: 982cb52d1f024036bfe8722ee63e9ad869b5db24 wpt-pr: 57486
Processing Instructions are currently serialized as
"<?" + target + " " + data + ">":If serialized in this way, data ending in
?would result in different data on next parse:This is resolved be serializing with a final
?>instead of>. This should preserve arbitrary PI data correctly. This idea was already considered: #12118 (comment)Benefits:
Drawbacks:
See related tests: web-platform-tests/wpt#57486
(See WHATWG Working Mode: Changes for more details.)
/dynamic-markup-insertion.html ( diff )
/infrastructure.html ( diff )
/parsing.html ( diff )