New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@xmldom/xmldom

Package Overview
Dependencies
Maintainers
4
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xmldom/xmldom - npm Package Compare versions

Comparing version 0.9.0-beta.9 to 0.9.0-beta.10

31

CHANGELOG.md

@@ -7,2 +7,33 @@ # Changelog

## [0.9.0-beta.10](https://github.com/xmldom/xmldom/compare/0.9.0-beta.9...0.9.0-beta.10)
### Fixed
- dom: prevent iteration over deleted items [`#514`](https://github.com/xmldom/xmldom/pull/514)/ [`#499`](https://github.com/xmldom/xmldom/issues/499)
### Chore
- use prettier plugin for jsdoc [`#513`](https://github.com/xmldom/xmldom/pull/513)
Thank you, [@qtow](https://github.com/qtow), [@shunkica](https://github.com/shunkica), [@homer0](https://github.com/homer0), for your contributions
## [0.8.10](https://github.com/xmldom/xmldom/compare/0.8.9...0.8.10)
### Fixed
- dom: prevent iteration over deleted items [`#514`](https://github.com/xmldom/xmldom/pull/514)/ [`#499`](https://github.com/xmldom/xmldom/issues/499)
Thank you, [@qtow](https://github.com/qtow), for your contributions
## [0.7.13](https://github.com/xmldom/xmldom/compare/0.7.12...0.7.13)
### Fixed
- dom: prevent iteration over deleted items [`#514`](https://github.com/xmldom/xmldom/pull/514)/ [`#499`](https://github.com/xmldom/xmldom/issues/499)
Thank you, [@qtow](https://github.com/qtow), for your contributions
## [0.9.0-beta.9](https://github.com/xmldom/xmldom/compare/0.9.0-beta.8...0.9.0-beta.9)

@@ -9,0 +40,0 @@

156

index.d.ts

@@ -9,8 +9,8 @@ /// <reference lib="dom" />

*
* @throws TypeError if target is not an object
*
* @throws {TypeError}
* If target is not an object.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
* @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign
*/
function assign<T, S>(target:T, source:S): T & S;
function assign<T, S>(target: T, source: S): T & S;
/**

@@ -33,5 +33,7 @@ * Only returns true if `value` matches MIME_TYPE.HTML, which indicates an HTML document.

*
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec
* @see DOMParser.prototype.parseFromString
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02
* MDN
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype
* WHATWG HTML Spec
* @see {@link DOMParser.prototype.parseFromString}
*/

@@ -45,3 +47,4 @@ enum MIME_TYPE {

* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
* WHATWG HTML Spec
*/

@@ -52,3 +55,4 @@ HTML = 'text/html',

*
* @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration
* @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType
* registration
* @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303

@@ -70,3 +74,4 @@ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia

*
* @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration
* @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType
* registration
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec

@@ -111,3 +116,3 @@ * @see https://en.wikipedia.org/wiki/XHTML Wikipedia

/**
* The `xmlns:` namespace
* The `xmlns:` namespace.
*

@@ -123,3 +128,3 @@ * @see https://www.w3.org/2000/xmlns/

class ParseError extends Error {
constructor(message:string, locator?:any);
constructor(message: string, locator?: any);
}

@@ -131,2 +136,3 @@ // END ./lib/conventions.js

* The error class for errors reported by the DOM API.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMException

@@ -142,13 +148,12 @@ * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html

/**
* The DOMImplementation interface represents an object providing methods
* which are not dependent on any particular document.
* The DOMImplementation interface represents an object providing methods which are not
* dependent on any particular document.
* Such an object is returned by the `Document.implementation` property.
*
* __The individual methods describe the differences compared to the specs.__
* __The individual methods describe the differences compared to the specs.__.
*
* @constructor
*
* @class
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core
* (Initial)
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1
* Core (Initial)
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core

@@ -168,10 +173,8 @@ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core

*
* @returns {Document} the XML document
*
* @see DOMImplementation.createHTMLDocument
*
* @returns {Document} The XML document.
* @see {@link DOMImplementation.createHTMLDocument}
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM
* Level 2 Core (initial)
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
* Level 2 Core (initial)
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
*/

@@ -191,11 +194,10 @@ createDocument(

* @returns {DocumentType} which can either be used with `DOMImplementation.createDocument`
* upon document creation or can be put into the document via methods like
* `Node.insertBefore()` or `Node.replaceChild()`
*
* upon document creation or can be put into the document via methods
* like `Node.insertBefore()` or `Node.replaceChild()`
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType
* MDN
* MDN
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM
* Level 2 Core
* Level 2 Core
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living
* Standard
* Standard
*/

@@ -216,4 +218,3 @@ createDocumentType(

*
* @see DOMImplementation.createDocument
*
* @see {@link DOMImplementation.createDocument}
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument

@@ -226,10 +227,11 @@ * @see https://dom.spec.whatwg.org/#html-document

* The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given
* feature is supported. The different implementations fairly diverged in what kind of features
* were reported. The latest version of the spec settled to force this method to always return
* true, where the functionality was accurate and in use.
* feature is supported. The different implementations fairly diverged in what kind of
* features were reported. The latest version of the spec settled to force this method to
* always return true, where the functionality was accurate and in use.
*
* @deprecated It is deprecated and modern browsers return true in all cases.
*
* @deprecated
* It is deprecated and modern browsers return true in all cases.
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1
* Core
* @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard

@@ -250,11 +252,10 @@ */

/**
* The DOMParser interface provides the ability to parse XML or HTML source code
* from a string into a DOM `Document`.
* The DOMParser interface provides the ability to parse XML or HTML source code from a
* string into a DOM `Document`.
*
* _xmldom is different from the spec in that it allows an `options` parameter,
* to control the behavior._
* to control the behavior._.
*
* @class
* @param {DOMParserOptions} [options]
* @constructor
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser

@@ -267,7 +268,7 @@ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization

/**
* The DOMParser interface provides the ability to parse XML or HTML source code
* from a string into a DOM `Document`.
* The DOMParser interface provides the ability to parse XML or HTML source code from a string
* into a DOM `Document`.
*
* _xmldom is different from the spec in that it allows an `options` parameter,
* to control the behavior._
* to control the behavior._.
*

@@ -279,3 +280,4 @@ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser

/**
* Parses `source` using the options in the way configured by the `DOMParserOptions` of `this`
* Parses `source` using the options in the way configured by the `DOMParserOptions` of
* `this`
* `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created, otherwise an XML

@@ -285,17 +287,20 @@ * `Document` is created.

* __It behaves different from the description in the living standard__:
* - Uses the `options` passed to the `DOMParser` constructor to modify the
* behavior.
* - Any unexpected input is reported to `onError` with either a `warning`, `error` or `fatalError` level.
* - Any `fatalError` throws a `ParseError` which prevents further processing.
* - Any error thrown by `onError` is converted to a `ParseError` which prevents further processing
* - If no `Document` was created during parsing it is reported as a `fatalError`.
* - Uses the `options` passed to the `DOMParser` constructor to modify the behavior.
* - Any unexpected input is reported to `onError` with either a `warning`, `error` or
* `fatalError` level.
* - Any `fatalError` throws a `ParseError` which prevents further processing.
* - Any error thrown by `onError` is converted to a `ParseError` which prevents further
* processing - If no `Document` was created during parsing it is reported as a `fatalError`.
*
* @throws ParseError for any `fatalError` or anything that is thrown by `onError`
* @throws TypeError for any invalid `mimeType`
* @returns the `Document` node
*
* @returns The `Document` node.
* @throws {ParseError}
* for any `fatalError` or anything that is thrown by `onError`
* @throws {TypeError} for any invalid `mimeType`
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
* @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev
*/
parseFromString(source: string, mimeType: MIME_TYPE = MIME_TYPE.XML_TEXT): Document;
parseFromString(
source: string,
mimeType: MIME_TYPE = MIME_TYPE.XML_TEXT
): Document;
}

@@ -313,3 +318,3 @@

* @private
* @see conventions.assign
* @see {@link conventions.assign}
*/

@@ -320,4 +325,4 @@ readonly assign?: typeof Object.assign;

* parser.
* __**Warning: By configuring a faulty implementation,
* the specified behavior can completely be broken.**__
* *****Warning: By configuring a faulty implementation,
* the specified behavior can completely be broken*****.
*

@@ -334,4 +339,5 @@ * @private

* but it receives different argument types than before 0.9.0.
* @throws If it is an object.
*
* @deprecated
* @throws {TypeError} If it is an object.
*/

@@ -362,11 +368,13 @@ readonly errorHandler?: ErrorHandlerFunction;

*
* Be aware that many `warning`s are considered an error
* that prevents further processing in most implementations.
* Be aware that many `warning`s are considered an error that prevents further processing in
* most implementations.
*
* @param level the error level as reported by the SAXParser
* @param message the error message
* @param context the DOMHandler instance used for parsing
*
* @see onErrorStopParsing
* @see onWarningStopParsing
* @param level
* The error level as reported by the SAXParser.
* @param message
* The error message.
* @param context
* The DOMHandler instance used for parsing.
* @see {@link onErrorStopParsing}
* @see {@link onWarningStopParsing}
*/

@@ -393,4 +401,4 @@ readonly onError?: ErrorHandlerFunction;

*
* @see DOMParserOptions.onError
* @see onWarningStopParsing
* @see {@link DOMParserOptions.onError}
* @see {@link onWarningStopParsing}
*/

@@ -402,4 +410,4 @@ function onErrorStopParsing(): void | never;

*
* @see DOMParserOptions.onError
* @see onErrorStopParsing
* @see {@link DOMParserOptions.onError}
* @see {@link onErrorStopParsing}
*/

@@ -406,0 +414,0 @@ function onWarningStopParsing(): never;

@@ -6,11 +6,11 @@ 'use strict';

*
* Works with anything that has a `length` property and index access properties, including NodeList.
* Works with anything that has a `length` property and index access properties,
* including NodeList.
*
* @param {T[] | { length: number; [number]: T }} list
* @param {function (item: T, index: number, list:T[]):boolean} predicate
* @param {Partial<Pick<ArrayConstructor['prototype'], 'find'>>?} ac
* Allows injecting a custom implementation in tests (`Array.prototype` by default).
* @returns {T | undefined}
* @template {unknown} T
* @param {Array<T> | ({length:number, [number]: T})} list
* @param {function (item: T, index: number, list:Array<T> | ({length:number, [number]: T})):boolean} predicate
* @param {Partial<Pick<ArrayConstructor['prototype'], 'find'>>?} ac `Array.prototype` by default,
* allows injecting a custom implementation in tests
* @returns {T | undefined}
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find

@@ -43,8 +43,9 @@ * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find

*
* @template T
* @param {T} object the object to freeze
* @param {Pick<ObjectConstructor, 'freeze'>} [oc=Object] `Object` by default,
* allows to inject custom object constructor for tests
* @param {T} object
* The object to freeze.
* @param {Pick<ObjectConstructor, 'freeze'>} [oc=Object]
* `Object` by default,
* allows to inject custom object constructor for tests.
* @returns {Readonly<T>}
*
* @template {Object} T
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze

@@ -65,6 +66,5 @@ */

* @param {Object | null | undefined} source
*
* @returns {Object} target
* @throws TypeError if target is not an object
*
* @returns {Object} The target with the merged/overridden properties.
* @throws {TypeError}
* If target is not an object.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

@@ -90,4 +90,4 @@ * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign

*
* If the attribute is present, its value must either be the empty string
* or a value that is an ASCII case-insensitive match for the attribute's canonical name,
* If the attribute is present, its value must either be the empty string, or a value that is
* an ASCII case-insensitive match for the attribute's canonical name,
* with no leading or trailing whitespace.

@@ -130,7 +130,8 @@ *

* Check if `name` is matching one of the HTML boolean attribute names.
* This method doesn't check if such attributes are allowed in the context of the current document/parsing.
* This method doesn't check if such attributes are allowed in the context of the current
* document/parsing.
*
* @param {string} name
* @return {boolean}
* @see HTML_BOOLEAN_ATTRIBUTES
* @returns {boolean}
* @see {@link HTML_BOOLEAN_ATTRIBUTES}
* @see https://html.spec.whatwg.org/#boolean-attributes

@@ -145,10 +146,27 @@ * @see https://html.spec.whatwg.org/#attributes-3

* Void elements only have a start tag; end tags must not be specified for void elements.
* These elements should be written as self closing like this: `<area />`.
* These elements should be written as self-closing like this: `<area />`.
* This should not be confused with optional tags that HTML allows to omit the end tag for
* (like `li`, `tr` and others), which can have content after them,
* so they can not be written as self closing.
* xmldom does not have any logic for optional end tags cases and will report them as a warning.
* Content that would go into the unopened element will instead be added as a sibling text node.
* so they can not be written as self-closing.
* xmldom does not have any logic for optional end tags cases,
* and will report them as a warning.
* Content that would go into the unopened element,
* will instead be added as a sibling text node.
*
* @type {Readonly<{area: boolean, col: boolean, img: boolean, wbr: boolean, link: boolean, hr: boolean, source: boolean, br: boolean, input: boolean, param: boolean, meta: boolean, embed: boolean, track: boolean, base: boolean}>}
* @type {Readonly<{
* area: boolean;
* col: boolean;
* img: boolean;
* wbr: boolean;
* link: boolean;
* hr: boolean;
* source: boolean;
* br: boolean;
* input: boolean;
* param: boolean;
* meta: boolean;
* embed: boolean;
* track: boolean;
* base: boolean;
* }>}
* @see https://html.spec.whatwg.org/#void-elements

@@ -176,8 +194,8 @@ * @see https://html.spec.whatwg.org/#optional-tags

* Check if `tagName` is matching one of the HTML void element names.
* This method doesn't check if such tags are allowed
* in the context of the current document/parsing.
* This method doesn't check if such tags are allowed in the context of the current
* document/parsing.
*
* @param {string} tagName
* @return {boolean}
* @see HTML_VOID_ELEMENTS
* @returns {boolean}
* @see {@link HTML_VOID_ELEMENTS}
* @see https://html.spec.whatwg.org/#void-elements

@@ -193,4 +211,4 @@ */

*
* @see isHTMLEscapableRawTextElement
* @see isHTMLRawTextElement
* @see {@link isHTMLEscapableRawTextElement}
* @see {@link isHTMLRawTextElement}
* @see https://html.spec.whatwg.org/#raw-text-elements

@@ -208,9 +226,9 @@ * @see https://html.spec.whatwg.org/#escapable-raw-text-elements

* Check if `tagName` is matching one of the HTML raw text element names.
* This method doesn't check if such tags are allowed
* in the context of the current document/parsing.
* This method doesn't check if such tags are allowed in the context of the current
* document/parsing.
*
* @param {string} tagName
* @return {boolean}
* @see isHTMLEscapableRawTextElement
* @see HTML_RAW_TEXT_ELEMENTS
* @returns {boolean}
* @see {@link isHTMLEscapableRawTextElement}
* @see {@link HTML_RAW_TEXT_ELEMENTS}
* @see https://html.spec.whatwg.org/#raw-text-elements

@@ -225,9 +243,9 @@ * @see https://html.spec.whatwg.org/#escapable-raw-text-elements

* Check if `tagName` is matching one of the HTML escapable raw text element names.
* This method doesn't check if such tags are allowed
* in the context of the current document/parsing.
* This method doesn't check if such tags are allowed in the context of the current
* document/parsing.
*
* @param {string} tagName
* @return {boolean}
* @see isHTMLRawTextElement
* @see HTML_RAW_TEXT_ELEMENTS
* @returns {boolean}
* @see {@link isHTMLRawTextElement}
* @see {@link HTML_RAW_TEXT_ELEMENTS}
* @see https://html.spec.whatwg.org/#raw-text-elements

@@ -245,3 +263,2 @@ * @see https://html.spec.whatwg.org/#escapable-raw-text-elements

* @returns {mimeType is 'text/html'}
*
* @see https://www.iana.org/assignments/media-types/text/html

@@ -256,8 +273,7 @@ * @see https://en.wikipedia.org/wiki/HTML

/**
* For both the `text/html` and the `application/xhtml+xml` namespace
* the spec defines that the HTML namespace is provided as the default.
* For both the `text/html` and the `application/xhtml+xml` namespace the spec defines that the
* HTML namespace is provided as the default.
*
* @param {string} mimeType
* @returns {boolean}
*
* @see https://dom.spec.whatwg.org/#dom-document-createelement

@@ -274,5 +290,7 @@ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument

*
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec
* @see DOMParser.prototype.parseFromString
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02
* MDN
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype
* WHATWG HTML Spec
* @see {@link DOMParser.prototype.parseFromString}
*/

@@ -286,3 +304,4 @@ var MIME_TYPE = freeze({

* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
* WHATWG HTML Spec
*/

@@ -294,3 +313,4 @@ HTML: 'text/html',

*
* @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration
* @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType
* registration
* @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303

@@ -314,3 +334,4 @@ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia

*
* @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration
* @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType
* registration
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec

@@ -331,3 +352,4 @@ * @see https://en.wikipedia.org/wiki/XHTML Wikipedia

/**
* @typedef {'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'} MimeType
* @typedef {'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}
* MimeType
*/

@@ -343,5 +365,8 @@ /**

/**
* Only returns true if `mimeType` is one of the allowed values for `DOMParser.parseFromString`.
* Only returns true if `mimeType` is one of the allowed values for
* `DOMParser.parseFromString`.
*
* @param {string} mimeType
* @returns {mimeType is 'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}
*
*/

@@ -379,3 +404,3 @@ function isValidMimeType(mimeType) {

/**
* The `xmlns:` namespace
* The `xmlns:` namespace.
*

@@ -390,5 +415,6 @@ * @see https://www.w3.org/2000/xmlns/

*
* @class
* @param {string} message
* @param {any?} locator Optional, can provide details about the location in the source
* @constructor
* @param {any} [locator]
* Optional, can provide details about the location in the source.
*/

@@ -395,0 +421,0 @@ function ParseError(message, locator) {

@@ -31,6 +31,6 @@ 'use strict';

* >
* > 1. the two-character sequence #xD #xA
* > 2. the two-character sequence #xD #x85
* > 3. the single character #x85
* > 4. the single character #x2028
* > 1. the two-character sequence #xD #xA,
* > 2. the two-character sequence #xD #x85,
* > 3. the single character #x85,
* > 4. the single character #x2028,
* > 5. any #xD character that is not immediately followed by #xA or #x85.

@@ -40,2 +40,3 @@ *

* @returns {string}
* @prettierignore
*/

@@ -54,13 +55,14 @@ function normalizeLineEndings(input) {

* @typedef DOMParserOptions
* @property {typeof conventions.assign} [assign=Object.assign || conventions.assign]
* The method to use instead of `Object.assign` (or if not available `conventions.assign`),
* which is used to copy values from the options before they are used for parsing.
* @property {typeof assign} [assign]
* The method to use instead of `conventions.assign`, which is used to copy values from
* `options` before they are used for parsing.
* @property {typeof DOMHandler} [domHandler]
* For internal testing: The class for creating an instance for handling events from the SAX parser.
* __**Warning: By configuring a faulty implementation,
* the specified behavior can completely be broken.**__
*
* For internal testing: The class for creating an instance for handling events from the SAX
* parser.
* *****Warning: By configuring a faulty implementation, the specified behavior can completely
* be broken.*****.
* @property {Function} [errorHandler]
* DEPRECATED! use `onError` instead.
* @property {function(level:ErrorLevel, message:string, context: DOMHandler):void} [onError]
* @property {function(level:ErrorLevel, message:string, context: DOMHandler):void}
* [onError]
* A function that is invoked for every error that occurs during parsing.

@@ -74,13 +76,11 @@ *

*
* Be aware that many `warning`s are considered an error
* that prevents further processing in most implementations.
*.
* Be aware that many `warning`s are considered an error that prevents further processing in
* most implementations.
* @property {boolean} [locator=true]
* Configures if the nodes created during parsing
* will have a `lineNumber` and a `columnNumber` attribute
* describing their location in the XML string.
* Configures if the nodes created during parsing will have a `lineNumber` and a `columnNumber`
* attribute describing their location in the XML string.
* Default is true.
* @property {(string) => string} [normalizeLineEndings]
* used to replace line endings before parsing, defaults to `normalizeLineEndings`
* @property {object} [xmlns]
* @property {Object} [xmlns]
* The XML namespaces that should be assumed when parsing.

@@ -91,16 +91,14 @@ * The default namespace can be provided by the key that is the empty string.

* will be overridden according to the specification.
*
* @see normalizeLineEndings
* @see {@link normalizeLineEndings}
*/
/**
* The DOMParser interface provides the ability to parse XML or HTML source code
* from a string into a DOM `Document`.
* The DOMParser interface provides the ability to parse XML or HTML source code from a string
* into a DOM `Document`.
*
* _xmldom is different from the spec in that it allows an `options` parameter,
* to control the behavior._
* ***xmldom is different from the spec in that it allows an `options` parameter,
* to control the behavior***.
*
* @class
* @param {DOMParserOptions} [options]
* @constructor
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser

@@ -113,9 +111,10 @@ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization

/**
* The method to use instead of `Object.assign` (defaults to or `conventions.assign`),
* which is used to copy values from the options before they are used for parsing.
* The method to use instead of `conventions.assign`, which is used to copy values from
* `options`
* before they are used for parsing.
*
* @type {function (target: object, source: object | null | undefined): object}
* @type {conventions.assign}
* @private
* @see {@link conventions.assign}
* @readonly
* @private
* @see conventions.assign
*/

@@ -125,8 +124,10 @@ this.assign = options.assign || conventions.assign;

/**
* For internal testing: The class for creating an instance for handling events from the SAX parser.
* __**Warning: By configuring a faulty implementation, the specified behavior can completely be broken.**__
* For internal testing: The class for creating an instance for handling events from the SAX
* parser.
* *****Warning: By configuring a faulty implementation, the specified behavior can completely
* be broken*****.
*
* @type {typeof DOMHandler}
* @private
* @readonly
* @private
*/

@@ -144,9 +145,8 @@ this.domHandler = options.domHandler || DOMHandler;

*
* Be aware that many `warning`s are considered an error
* that prevents further processing in most implementations.
* Be aware that many `warning`s are considered an error that prevents further processing in
* most implementations.
*
* @type {function(level:ErrorLevel, message:string, context: DOMHandler):void}
*
* @see onErrorStopParsing
* @see onWarningStopParsing
* @see {@link onErrorStopParsing}
* @see {@link onWarningStopParsing}
*/

@@ -169,6 +169,7 @@ this.onError = options.onError || options.errorHandler;

/**
* Configures if the nodes created during parsing
* will have a `lineNumber` and a `columnNumber` attribute
* describing their location in the XML string.
* Configures if the nodes created during parsing will have a `lineNumber` and a
* `columnNumber`
* attribute describing their location in the XML string.
* Default is true.
*
* @type {boolean}

@@ -184,3 +185,4 @@ * @readonly

* will be overridden according to the specification.
* @type {Readonly<object>}
*
* @type {Readonly<Object>}
* @readonly

@@ -193,24 +195,25 @@ */

* Parses `source` using the options in the way configured by the `DOMParserOptions` of `this`
* `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created, otherwise an XML
* `Document` is created.
* `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created,
* otherwise an XML `Document` is created.
*
* __It behaves different from the description in the living standard__:
* - Uses the `options` passed to the `DOMParser` constructor to modify the
* behavior.
* - Any unexpected input is reported to `onError` with either a `warning`, `error` or `fatalError` level.
* - Any `fatalError` throws a `ParseError` which prevents further processing.
* - Any error thrown by `onError` is converted to a `ParseError` which prevents further processing
* - If no `Document` was created during parsing it is reported as a `fatalError`.
* __**Warning: By configuring a faulty DOMHandler implementation,
* the specified behavior can completely be broken.**__
* - Uses the `options` passed to the `DOMParser` constructor to modify the behavior.
* - Any unexpected input is reported to `onError` with either a `warning`,
* `error` or `fatalError` level.
* - Any `fatalError` throws a `ParseError` which prevents further processing.
* - Any error thrown by `onError` is converted to a `ParseError` which prevents further
* processing - If no `Document` was created during parsing it is reported as a `fatalError`.
* *****Warning: By configuring a faulty DOMHandler implementation,
* the specified behavior can completely be broken*****.
*
* @param {string} source The XML mime type only allows string input!
* @param {string} source
* The XML mime type only allows string input!
* @param {string} [mimeType='application/xml']
* the mimeType or contentType of the document to be created
* determines the `type` of document created (XML or HTML)
*
* @throws ParseError for any `fatalError` or anything that is thrown by `onError`
* @throws TypeError for any invalid `mimeType`
* @returns the `Document` node
*
* the mimeType or contentType of the document to be created determines the `type` of document
* created (XML or HTML)
* @returns The `Document` node.
* @throws {ParseError}
* for any `fatalError` or anything that is thrown by `onError`
* @throws {TypeError}
* for any invalid `mimeType`
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString

@@ -262,6 +265,7 @@ * @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev

* @property {string} [mimeType=MIME_TYPE.XML_APPLICATION]
* @property {string|null} [defaultNamespace=null]
* @property {string | null} [defaultNamespace=null]
*/
/**
* The class that is used to handle events from the SAX parser to create the related DOM elements.
* The class that is used to handle events from the SAX parser to create the related DOM
* elements.
*

@@ -271,3 +275,3 @@ * Some methods are only implemented as an empty function,

*
* @constructor
* @class
* @param {DOMHandlerOptions} [options]

@@ -284,4 +288,4 @@ * @see http://www.saxproject.org/apidoc/org/xml/sax/ext/DefaultHandler2.html

* @type {string}
* @see {@link MIME_TYPE}
* @readonly
* @see MIME_TYPE
*/

@@ -294,11 +298,13 @@ this.mimeType = opt.mimeType || MIME_TYPE.XML_APPLICATION;

* - The SAX API for `startDocument` doesn't offer any way to pass a namespace,
* since at that point there is no way for the parser to know what the default namespace from the document will be.
* - When creating using `DOMImplementation.createDocument` it is required to pass a namespace,
* to determine the correct `Document.contentType`, which should match `this.mimeType`.
* since at that point there is no way for the parser to know what the default namespace from
* the document will be.
* - When creating using `DOMImplementation.createDocument` it is required to pass a
* namespace,
* to determine the correct `Document.contentType`, which should match `this.mimeType`.
* - When parsing an XML document with the `application/xhtml+xml` mimeType,
* the HTML namespace needs to be the default namespace.
* the HTML namespace needs to be the default namespace.
*
* @type {string|null}
* @type {string | null}
* @private
* @readonly
* @private
*/

@@ -308,4 +314,4 @@ this.defaultNamespace = opt.defaultNamespace || null;

/**
* @type {boolean}
* @private
* @type {boolean}
*/

@@ -336,4 +342,3 @@ this.cdata = false;

* The locator is stored as part of setDocumentLocator.
* It is controlled and mutated by the SAX parser
* to store the current parsing position.
* It is controlled and mutated by the SAX parser to store the current parsing position.
* It is used by DOMHandler to set `columnNumber` and `lineNumber`

@@ -343,4 +348,5 @@ * on the DOM nodes.

* @type {Readonly<Locator> | undefined}
* @readonly (the sax parser currently sometimes set's it)
* @private
* @readonly (the
* sax parser currently sometimes set's it)
*/

@@ -367,3 +373,3 @@ this.locator = undefined;

*
* @see http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
* @see http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
*/

@@ -485,5 +491,7 @@ startDocument: function () {

*
* @param {string} message - The message to be used for reporting and throwing the error.
* @param {string} message
* - The message to be used for reporting and throwing the error.
* @returns {never} This function always throws an error and never returns a value.
* @throws {ParseError} Always throws a ParseError with the provided message.
* @throws {ParseError}
* Always throws a ParseError with the provided message.
*/

@@ -567,4 +575,4 @@ fatalError: function (message) {

*
* @see DOMParserOptions.onError
* @see onWarningStopParsing
* @see {@link DOMParserOptions.onError}
* @see {@link onWarningStopParsing}
*/

@@ -578,4 +586,4 @@ function onErrorStopParsing(level) {

*
* @see DOMParserOptions.onError
* @see onErrorStopParsing
* @see {@link DOMParserOptions.onError}
* @see {@link onErrorStopParsing}
*/

@@ -582,0 +590,0 @@ function onWarningStopParsing() {

@@ -10,3 +10,4 @@ 'use strict';

* @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML Wikipedia
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML
* Wikipedia
*/

@@ -25,11 +26,14 @@ exports.XML_ENTITIES = freeze({

*
* @see XML_ENTITIES
* @see DOMParser.parseFromString
* @see DOMImplementation.prototype.createHTMLDocument
* @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5) Spec
* @see {@link XML_ENTITIES}
* @see {@link DOMParser.parseFromString}
* @see {@link DOMImplementation.prototype.createHTMLDocument}
* @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5)
* Spec
* @see https://html.spec.whatwg.org/entities.json JSON
* @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names
* @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML)
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML)
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML
* Wikipedia (HTML)
* @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML
* Wikpedia (XHTML)
*/

@@ -2165,5 +2169,6 @@ exports.HTML_ENTITIES = freeze({

/**
* @deprecated use `HTML_ENTITIES` instead
* @see HTML_ENTITIES
* @deprecated
* Use `HTML_ENTITIES` instead.
* @see {@link HTML_ENTITIES}
*/
exports.entityMap = exports.HTML_ENTITIES;

@@ -8,3 +8,4 @@ 'use strict';

*
* @param {typeof RegExp} [RegExpImpl=RegExp] for testing: the RegExp class
* @param {typeof RegExp} [RegExpImpl=RegExp]
* For testing: the RegExp class.
* @returns {boolean}

@@ -27,3 +28,4 @@ * @see https://node.green/#ES2015-syntax-RegExp--y--and--u--flags

/**
* Removes `[`, `]` and any trailing quantifiers from the source of a RegExp
* Removes `[`, `]` and any trailing quantifiers from the source of a RegExp.
*
* @param {RegExp} regexp

@@ -41,4 +43,6 @@ */

* by removing `search` from the source of `regexp`.
*
* @param {RegExp} regexp
* @param {string} search the character(s) to remove
* @param {string} search
* The character(s) to remove.
* @returns {RegExp}

@@ -64,2 +68,3 @@ */

* Combines and Regular expressions correctly by using `RegExp.source`.
*
* @param {...(RegExp | string)[]} args

@@ -87,2 +92,3 @@ * @returns {RegExp}

* Like `reg` but wraps the expression in `(?:`,`)` to create a non tracking group.
*
* @param {...(RegExp | string)[]} args

@@ -89,0 +95,0 @@ * @returns {RegExp}

@@ -218,4 +218,4 @@ 'use strict';

/**
* @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
* @return end of the elementStartPart(end of elementEndPart for selfClosed el)
* @returns end of the elementStartPart(end of elementEndPart for selfClosed el)
* @see {@link #appendElement}
*/

@@ -419,3 +419,3 @@ function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler, isHTML) {

/**
* @return true if has new namespace define
* @returns `true` if a new namespace has been defined.
*/

@@ -545,19 +545,24 @@ function appendElement(el, domBuilder, currentNSMap) {

* @typedef ParseUtils
* @property {function(relativeIndex: number?): string | undefined} char provides look ahead access
* to a singe character relative to the current index
* @property {function(): number} getIndex provides read-only access to the current index
* @property {function(reg: RegExp): string | null} getMatch applies the provided regular expression
* enforcing that it starts at the current index and returns the complete matching string,
* and moves the current index by the length of the matching string.
* @property {function(): string} getSource provides read-only access to the complete source
* @property {function(places: number?): void} skip moves the current index
* by places (defaults to 1)
* @property {function(): number} skipBlanks moves the current index by the amount of white space
* that directly follows the current index and returns the amount of whitespace chars skipped (0..n),
* or -1 if the end of the source was reached.
* @property {function(): string} substringFromIndex creates a substring from the current index to the end of `source`
* @property {function(compareWith: string): boolean} substringStartsWith checks if source contains `compareWith`,
* starting from the current index
*
* @see parseUtils
* @property {function(relativeIndex: number?): string | undefined} char
* Provides look ahead access to a singe character relative to the current index.
* @property {function(): number} getIndex
* Provides read-only access to the current index.
* @property {function(reg: RegExp): string | null} getMatch
* Applies the provided regular expression enforcing that it starts at the current index and
* returns the complete matching string,
* and moves the current index by the length of the matching string.
* @property {function(): string} getSource
* Provides read-only access to the complete source.
* @property {function(places: number?): void} skip
* moves the current index by places (defaults to 1)
* @property {function(): number} skipBlanks
* Moves the current index by the amount of white space that directly follows the current index
* and returns the amount of whitespace chars skipped (0..n),
* or -1 if the end of the source was reached.
* @property {function(): string} substringFromIndex
* creates a substring from the current index to the end of `source`
* @property {function(compareWith: string): boolean} substringStartsWith
* Checks if source contains `compareWith`,
* starting from the current index.
* @see {@link parseUtils}
*/

@@ -712,8 +717,12 @@

* Called when the parser encounters an element starting with '<!'.
* @param {string} source the xml
* @param {number} start the start index of the '<!'
*
* @param {string} source
* The xml.
* @param {number} start
* the start index of the '<!'
* @param {DOMHandler} domBuilder
* @param {DOMHandler} errorHandler
* @returns {number|never} the end index of the element
* @throws ParseError in case the element is not well-formed
* @returns {number | never} The end index of the element.
* @throws {ParseError}
* In case the element is not well-formed.
*/

@@ -720,0 +729,0 @@ function parseDoctypeCommentOrCData(source, start, domBuilder, errorHandler) {

{
"name": "@xmldom/xmldom",
"version": "0.9.0-beta.9",
"version": "0.9.0-beta.10",
"description": "A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.",

@@ -46,4 +46,5 @@ "keywords": [

"devDependencies": {
"@homer0/prettier-plugin-jsdoc": "6.0.5",
"auto-changelog": "2.4.0",
"eslint": "8.42.0",
"eslint": "8.44.0",
"eslint-config-prettier": "8.8.0",

@@ -56,3 +57,3 @@ "eslint-plugin-anti-trojan-source": "1.1.1",

"jest": "27.5.1",
"nodemon": "2.0.22",
"nodemon": "3.0.1",
"np": "7.7.0",

@@ -59,0 +60,0 @@ "prettier": "2.8.8",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc