@xmldom/xmldom
Advanced tools
Comparing version 0.9.6 to 0.9.7
@@ -7,2 +7,28 @@ # Changelog | ||
## [0.9.7](https://github.com/xmldom/xmldom/compare/0.9.6...0.9.7) | ||
### Added | ||
- Implementation of `hasAttributes` [`#804`](https://github.com/xmldom/xmldom/pull/804) | ||
### Fixed | ||
- locator is now true even when other options are being used for the DOMParser [`#802`](https://github.com/xmldom/xmldom/issues/802) / [`#803`](https://github.com/xmldom/xmldom/pull/803) | ||
- allow case-insensitive DOCTYPE in HTML [`#817`](https://github.com/xmldom/xmldom/issues/817) / [`#819`](https://github.com/xmldom/xmldom/pull/819) | ||
### Performance | ||
- simplify `DOM.compareDocumentPosition` [`#805`](https://github.com/xmldom/xmldom/pull/805) | ||
### Chore | ||
- updated devDependencies | ||
Thank you, | ||
[@zorkow](https://github.com/zorkow), | ||
[@Ponynjaa](https://github.com/Ponynjaa), | ||
[@WesselKroos](https://github.com/WesselKroos), | ||
for your contributions. | ||
## [0.9.6](https://github.com/xmldom/xmldom/compare/0.9.5...0.9.6) | ||
@@ -9,0 +35,0 @@ |
@@ -327,3 +327,3 @@ 'use strict'; | ||
/** | ||
* `text/html`, an alias for `application/xml`. | ||
* `text/xml`, an alias for `application/xml`. | ||
* | ||
@@ -330,0 +330,0 @@ * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303 |
@@ -104,3 +104,6 @@ 'use strict'; | ||
function DOMParser(options) { | ||
options = options || { locator: true }; | ||
options = options || {}; | ||
if (options.locator === undefined) { | ||
options.locator = true; | ||
} | ||
@@ -107,0 +110,0 @@ /** |
@@ -384,2 +384,5 @@ 'use strict'; | ||
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#about:legacy-compat | ||
var ABOUT_LEGACY_COMPAT = 'about:legacy-compat'; | ||
var ABOUT_LEGACY_COMPAT_SystemLiteral = regg('"' + ABOUT_LEGACY_COMPAT + '"', '|', "'" + ABOUT_LEGACY_COMPAT + "'"); | ||
var SYSTEM = 'SYSTEM'; | ||
@@ -498,2 +501,4 @@ var PUBLIC = 'PUBLIC'; | ||
exports.regg = regg; | ||
exports.ABOUT_LEGACY_COMPAT = ABOUT_LEGACY_COMPAT; | ||
exports.ABOUT_LEGACY_COMPAT_SystemLiteral = ABOUT_LEGACY_COMPAT_SystemLiteral; | ||
exports.AttlistDecl = AttlistDecl; | ||
@@ -500,0 +505,0 @@ exports.CDATA_START = CDATA_START; |
@@ -590,4 +590,6 @@ 'use strict'; | ||
* @property {function(compareWith: string): boolean} substringStartsWith | ||
* Checks if source contains `compareWith`, | ||
* starting from the current index. | ||
* Checks if `source` contains `compareWith`, starting from the current index. | ||
* @property {function(compareWith: string): boolean} substringStartsWithCaseInsensitive | ||
* Checks if `source` contains `compareWith`, starting from the current index, | ||
* comparing the upper case of both sides. | ||
* @see {@link parseUtils} | ||
@@ -638,2 +640,5 @@ */ | ||
} | ||
function substringStartsWithCaseInsensitive(text) { | ||
return source.substring(index, index + text.length).toUpperCase() === text.toUpperCase(); | ||
} | ||
@@ -662,2 +667,3 @@ function getMatch(args) { | ||
substringStartsWith: substringStartsWith, | ||
substringStartsWithCaseInsensitive: substringStartsWithCaseInsensitive, | ||
}; | ||
@@ -759,3 +765,3 @@ } | ||
switch (p.char(2)) { | ||
switch (isHTML ? p.char(2).toUpperCase() : p.char(2)) { | ||
case '-': | ||
@@ -789,3 +795,3 @@ // should be a comment | ||
} | ||
if (!p.substringStartsWith(g.DOCTYPE_DECL_START)) { | ||
if (isHTML ? !p.substringStartsWithCaseInsensitive(g.DOCTYPE_DECL_START) : !p.substringStartsWith(g.DOCTYPE_DECL_START)) { | ||
return errorHandler.fatalError('Expected ' + g.DOCTYPE_DECL_START + ' at position ' + p.getIndex()); | ||
@@ -808,2 +814,6 @@ } | ||
return errorHandler.fatalError('doctype name missing or contains unexpected characters at position ' + p.getIndex()); | ||
if (isHTML && doctype.name.toLowerCase() !== 'html') { | ||
errorHandler.warning('Unexpected DOCTYPE in HTML document at position ' + p.getIndex()); | ||
} | ||
p.skipBlanks(); | ||
@@ -824,7 +834,23 @@ | ||
p.skip(match[0].length); | ||
} else if (isHTML && p.substringStartsWithCaseInsensitive(g.SYSTEM)) { | ||
// https://html.spec.whatwg.org/multipage/syntax.html#doctype-legacy-string | ||
p.skip(g.SYSTEM.length); | ||
if (p.skipBlanks() < 1) { | ||
return errorHandler.fatalError('Expected whitespace after ' + g.SYSTEM + ' at position ' + p.getIndex()); | ||
} | ||
doctype.systemId = p.getMatch(g.ABOUT_LEGACY_COMPAT_SystemLiteral); | ||
if (!doctype.systemId) { | ||
return errorHandler.fatalError( | ||
'Expected ' + g.ABOUT_LEGACY_COMPAT + ' in single or double quotes after ' + g.SYSTEM + ' at position ' + p.getIndex() | ||
); | ||
} | ||
} | ||
if (isHTML && doctype.systemId && !g.ABOUT_LEGACY_COMPAT_SystemLiteral.test(doctype.systemId)) { | ||
errorHandler.warning('Unexpected doctype.systemId in HTML document at position ' + p.getIndex()); | ||
} | ||
if (!isHTML) { | ||
p.skipBlanks(); | ||
doctype.internalSubset = parseDoctypeInternalSubset(p, errorHandler); | ||
} | ||
p.skipBlanks(); | ||
doctype.internalSubset = parseDoctypeInternalSubset(p, errorHandler); | ||
p.skipBlanks(); | ||
if (p.char() !== '>') { | ||
@@ -831,0 +857,0 @@ return errorHandler.fatalError('doctype not terminated with > at position ' + p.getIndex()); |
{ | ||
"name": "@xmldom/xmldom", | ||
"version": "0.9.6", | ||
"version": "0.9.7", | ||
"description": "A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.", | ||
@@ -51,12 +51,12 @@ "keywords": [ | ||
"eslint": "8.57.1", | ||
"eslint-config-prettier": "9.1.0", | ||
"eslint-config-prettier": "10.0.1", | ||
"eslint-plugin-anti-trojan-source": "1.1.1", | ||
"eslint-plugin-es5": "1.5.0", | ||
"eslint-plugin-n": "17.14.0", | ||
"eslint-plugin-prettier": "5.2.1", | ||
"eslint-plugin-n": "17.15.1", | ||
"eslint-plugin-prettier": "5.2.2", | ||
"get-stream": "6.0.1", | ||
"jest": "29.7.0", | ||
"nodemon": "3.1.7", | ||
"nodemon": "3.1.9", | ||
"np": "8.0.4", | ||
"prettier": "3.4.1", | ||
"prettier": "3.4.2", | ||
"rxjs": "7.8.1", | ||
@@ -63,0 +63,0 @@ "xmltest": "2.0.3", |
Sorry, the diff of this file is too big to display
365466
9256