diff --git a/cjs/dom/parser.js b/cjs/dom/parser.js index ecb31781..a1fe1087 100644 --- a/cjs/dom/parser.js +++ b/cjs/dom/parser.js @@ -27,7 +27,7 @@ class DOMParser { else if (mimeType === 'image/svg+xml') document = new SVGDocument; else - document = new XMLDocument; + document = new XMLDocument(mimeType); document[DOM_PARSER] = DOMParser; if (globals) document[GLOBALS] = globals; diff --git a/cjs/interface/element.js b/cjs/interface/element.js index 34cb95ba..0e201afa 100644 --- a/cjs/interface/element.js +++ b/cjs/interface/element.js @@ -459,7 +459,7 @@ class Element extends ParentNode { const start = next[START]; if (isOpened) { if ('ownerSVGElement' in start) - out.push(' />'); + out.push('/>'); else if (isVoid(start)) out.push(ignoreCase(start) ? '>' : ' />'); else diff --git a/cjs/shared/mime.js b/cjs/shared/mime.js index 1bb849d1..c0eb3678 100644 --- a/cjs/shared/mime.js +++ b/cjs/shared/mime.js @@ -27,7 +27,7 @@ const Mime = { 'application/xhtml+xml': { docType: '', ignoreCase: false, - voidElements + voidElements: /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/ } }; exports.Mime = Mime; diff --git a/cjs/xml/document.js b/cjs/xml/document.js index 0dda3439..e108d2d2 100644 --- a/cjs/xml/document.js +++ b/cjs/xml/document.js @@ -6,7 +6,7 @@ const {Document} = require('../interface/document.js'); * @implements globalThis.XMLDocument */ class XMLDocument extends Document { - constructor() { super('text/xml'); } + constructor(mimeType = 'text/xml') { super(mimeType); } toString() { return this[MIME].docType + super.toString(); } diff --git a/esm/dom/parser.js b/esm/dom/parser.js index 1ca423d0..f67780c8 100644 --- a/esm/dom/parser.js +++ b/esm/dom/parser.js @@ -26,7 +26,7 @@ export class DOMParser { else if (mimeType === 'image/svg+xml') document = new SVGDocument; else - document = new XMLDocument; + document = new XMLDocument(mimeType); document[DOM_PARSER] = DOMParser; if (globals) document[GLOBALS] = globals; diff --git a/esm/interface/element.js b/esm/interface/element.js index e7f927e1..10d53003 100644 --- a/esm/interface/element.js +++ b/esm/interface/element.js @@ -461,7 +461,7 @@ export class Element extends ParentNode { const start = next[START]; if (isOpened) { if ('ownerSVGElement' in start) - out.push(' />'); + out.push('/>'); else if (isVoid(start)) out.push(ignoreCase(start) ? '>' : ' />'); else diff --git a/esm/shared/mime.js b/esm/shared/mime.js index 4390efe8..9f51857c 100644 --- a/esm/shared/mime.js +++ b/esm/shared/mime.js @@ -26,6 +26,6 @@ export const Mime = { 'application/xhtml+xml': { docType: '', ignoreCase: false, - voidElements + voidElements: /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/ } }; diff --git a/esm/xml/document.js b/esm/xml/document.js index 65c59ada..829002e2 100644 --- a/esm/xml/document.js +++ b/esm/xml/document.js @@ -5,7 +5,7 @@ import {Document} from '../interface/document.js'; * @implements globalThis.XMLDocument */ export class XMLDocument extends Document { - constructor() { super('text/xml'); } + constructor(mimeType = 'text/xml') { super(mimeType); } toString() { return this[MIME].docType + super.toString(); } diff --git a/test/shared/parse-json.js b/test/shared/parse-json.js index 1e15c991..b612b46b 100644 --- a/test/shared/parse-json.js +++ b/test/shared/parse-json.js @@ -35,7 +35,7 @@ let div = parseJSON('[1,"div",1,"svg",1,"rect",-2,1,"c-e",-2]'); assert(JSON.stringify(toJSON(div)), '[1,"div",1,"svg",1,"rect",-2,1,"c-e",-2]'); -assert(div.toString(), '
'); +assert(div.toString(), '
'); assert(div.querySelector('c-e').constructed, void 0, 'not constructed'); diff --git a/test/svg/element.js b/test/svg/element.js index 4f5259ca..125f5915 100644 --- a/test/svg/element.js +++ b/test/svg/element.js @@ -16,8 +16,8 @@ assert(svg instanceof SVGElement, true, ' is an instance of a facade'); assert('ownerSVGElement' in svg, true, ' ownerSVGElement'); assert(svg.ownerSVGElement, null, ' ownerSVGElement is null'); assert(svg.firstChild.ownerSVGElement, svg, ' has an ownerSVGElement'); -assert(document.toString(), '
', 'svg nodes are OK'); -assert(document.documentElement.cloneNode(true).outerHTML, '
', 'svg cloned'); +assert(document.toString(), '
', 'svg nodes are OK'); +assert(document.documentElement.cloneNode(true).outerHTML, '
', 'svg cloned'); assert(JSON.stringify(document), '[9,1,"div",1,"svg",1,"rect",-4]'); assert(JSON.stringify(svg), '[1,"svg",1,"rect",-2]'); @@ -39,11 +39,11 @@ assert(svg.className.what, 'ever', '.className'); svg.setAttribute('test', 123); svg.setAttribute('style', 'width:100px'); -assert(svg.toString(), ''); +assert(svg.toString(), ''); svg.className = 'a b c'; assert(svg.getAttribute('class'), 'a b c'); svg.setAttribute('class', 'd e'); assert(svg.getAttribute('class'), 'd e'); -assert(svg.namespaceURI, 'http://www.w3.org/2000/svg'); \ No newline at end of file +assert(svg.namespaceURI, 'http://www.w3.org/2000/svg'); diff --git a/test/worker.js b/test/worker.js index f1a2c8d8..1fdea818 100644 --- a/test/worker.js +++ b/test/worker.js @@ -3,6 +3,6 @@ import createAssert from './assert-es.js'; const assert = createAssert.for('Web Worker'); -let {document} = parseHTML('
'); +let {document} = parseHTML('
'); -assert(document.querySelector('div').firstChild.localName, 'svg', 'Should be an svg element in the div'); \ No newline at end of file +assert(document.querySelector('div').firstChild.localName, 'svg', 'Should be an svg element in the div'); diff --git a/types/esm/shared/mime.d.ts b/types/esm/shared/mime.d.ts index fa7d537f..1dd49c15 100644 --- a/types/esm/shared/mime.d.ts +++ b/types/esm/shared/mime.d.ts @@ -28,8 +28,6 @@ export const Mime: { 'application/xhtml+xml': { docType: string; ignoreCase: boolean; - voidElements: { - test: () => boolean; - }; + voidElements: RegExp; }; }; diff --git a/types/esm/xml/document.d.ts b/types/esm/xml/document.d.ts index 6b152c1a..97466b1e 100644 --- a/types/esm/xml/document.d.ts +++ b/types/esm/xml/document.d.ts @@ -2,6 +2,6 @@ * @implements globalThis.XMLDocument */ export class XMLDocument extends Document implements globalThis.XMLDocument { - constructor(); + constructor(mimeType?: string); } import { Document } from '../interface/document.js'; diff --git a/worker.js b/worker.js index 858ae068..5dbe0ed0 100644 --- a/worker.js +++ b/worker.js @@ -8046,7 +8046,7 @@ let Element$1 = class Element extends ParentNode { const start = next[START]; if (isOpened) { if ('ownerSVGElement' in start) - out.push(' />'); + out.push('/>'); else if (isVoid(start)) out.push(ignoreCase(start) ? '>' : ' />'); else @@ -11992,7 +11992,7 @@ const Mime = { 'application/xhtml+xml': { docType: '', ignoreCase: false, - voidElements + voidElements: /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/ } }; @@ -12578,7 +12578,7 @@ class SVGDocument extends Document$1 { * @implements globalThis.XMLDocument */ class XMLDocument extends Document$1 { - constructor() { super('text/xml'); } + constructor(mimeType = 'text/xml') { super(mimeType); } toString() { return this[MIME].docType + super.toString(); } @@ -12605,7 +12605,7 @@ class DOMParser { else if (mimeType === 'image/svg+xml') document = new SVGDocument; else - document = new XMLDocument; + document = new XMLDocument(mimeType); document[DOM_PARSER] = DOMParser; if (globals) document[GLOBALS] = globals;