Re: [whatwg/dom] Consider more name validation loosening (Issue #1373)

cscott left a comment (whatwg/dom#1373)

I can confirm that the existing html5lib tests contain a number of "illegal" doctypes of this sort which pass the HTML parser, like `<!DOCTYPE ...>` in https://github.com/html5lib/html5lib-tests/blob/master/tree-construction/doctype01.dat#L348.  So I'd also be in favor of making the doctype consistent.

Processing instructions I don't care as much about, since those are more relevant to XHTML serializations. https://developer.mozilla.org/en-US/docs/Web/API/ProcessingInstruction says "Warning: ProcessingInstruction nodes are only supported in XML documents, not in HTML documents. In these, a process instruction will be considered as a comment and be represented as a Comment object in the tree."  This isn't actually reflected in the DOM spec for (eg) https://dom.spec.whatwg.org/#ref-for-dom-document-createprocessinginstruction%E2%91%A0.  But on Chrome at least:
```
doc = (new DOMParser()).parseFromString("<?xml-stylesheet href=\"mycss.css\"?>", "text/html");
new XMLSerializer().serializeToString(doc);
```
returns
```
<!--?xml-stylesheet href="mycss.css"?--><html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>'
```
so in a purely pedantic sense there is no need for `document.createProcessingInstruction` to be able to create processing instructions *at all* in order to allow DOM methods to be used to parse *HTML* because when parsing *HTML* we are using `document.createComment` to create the nodes for this construction.

tl;dr I think it's fine for document.createProcessingInstruction to be XML only and as such maintain the XML name rules.  But `createDocumentType` is used for HTML parsing and as such should allow the HTML character set.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1373#issuecomment-2892200952
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1373/2892200952@github.com>

Received on Monday, 19 May 2025 20:34:45 UTC