fix: Only use HTML rules if mimeType matches #338
This file contains 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
karfau added a commit to karfau/xmldom that referenced this pull request
Feb 15, 2022
karfau added a commit that referenced this pull request
Feb 15, 2022
- always set `Document.type` and `Document.contentType` - `Document.createElement` properly HTML casing and (X)HTML namespacing https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument https://dom.spec.whatwg.org/#dom-document-createelement
when `mimeType` is `text/html`. The `mimeType` can now optionally be passed to the `DOMHandler` constructor. Documented `DOMHandler` constructor and all properties. - For XML documents the XHTML and SVG mime types are preserved as expected. - `Document.documentURI` is no longer initialized with the undocumented `Locator.systemId` value. - Deprecate `DOMParserOptions.domBuilder` since state would be preserved between calls to `DOMParser.parseFromString` which can have unexpected side effects, especially since we are now using the `DOMHandler` to manage the mimeType and defaultNamespace.
Instead of accessing `this.options` in `DOMParser.parseToString`, the default values are now applied in the constructor. Since the locator passed to `options` is no longer being modified, the type of the option was changed to boolean. There is no change in behavior in this commit, since truthy and falsy values are accepted as well.
Instead of accessing `this.options` in `DOMParser.parseToString`, the default values are now applied in the constructor.
Instead of accessing `this.options` in `DOMParser.parseToString`, use `this.errorHandler`.
which points to a class instead of an instance and is only meant for internal testing. BREAKING CHANGE: If you used to configure `DOMParserOptions.domBuilder`. You might be able to configure the `domHandler` instead, but should be avoided. This is only there for testing purposes.
All options are now taken care of by the constructor and are available as individual properties. Most are marked as `readonly`, some are `private`. BREAKING CHANGE: If you used `DOMParser.options` after creating an instance. You can still read the individual properties from the instance, but there is no longer a way to mutate them, so you need to really pass the required options when constructing them.
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.