[TASK] Normalize the DOCTYPE declaration#866
Merged
oliverklee merged 1 commit intomasterfrom Apr 23, 2020
Merged
Conversation
Ensure that the DOCTYPE declaration consists of uppercase `DOCTYPE` and lowercase root element name (`html`). This is done when the `DOMDocument` is created from an HTML source. Once the `DOMDocument` has been created, the `DOMDocumentType` cannot be changed, so the document type declaration must be manipulated (if necessary) in the HTML beforehand. (Since only HTML documents are supported, the declaration is only normalized when the root element name is HTML, in whatever case - the precise specification for any element name involves lists of various Unicode character ranges which it would be superfluous to allow for and try to match. PHP's `DOMDocument`/`libxml` itself will output the `DOCTYPE` keyword in uppercase in any case.) This normalization is consistent with the relevant part of the [polyglot markup specification]( https://dev.w3.org/html5/html-polyglot/html-polyglot.html#doctype ). While polyglot markup is primarily intended for serialization of HTML as XML (we don't actually support outputting as XHTML), is also recommended for maximum interoperability and robustness when rendering HTML. This also makes the output consistent with that of `Masterminds/html5-php` and would eliminate the need to change associated tests specifically for #831. Closes #858.
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.
Ensure that the DOCTYPE declaration consists of uppercase
DOCTYPEandlowercase root element name (
html).This is done when the
DOMDocumentis created from an HTML source. Once theDOMDocumenthas been created, theDOMDocumentTypecannot be changed, so thedocument type declaration must be manipulated (if necessary) in the HTML
beforehand. (Since only HTML documents are supported, the declaration is only
normalized when the root element name is HTML, in whatever case - the precise
specification for any element name involves lists of various Unicode character
ranges which it would be superfluous to allow for and try to match. PHP's
DOMDocument/libxmlitself will output theDOCTYPEkeyword in uppercase inany case.)
This normalization is consistent with the relevant part of the
polyglot markup specification.
While polyglot markup is primarily intended for serialization of HTML as XML
(we don't actually support outputting as XHTML), is also recommended for maximum
interoperability and robustness when rendering HTML.
This also makes the output consistent with that of
Masterminds/html5-phpandwould eliminate the need to change associated tests specifically for #831.
Closes #858.