Comparing version 0.13.7 to 0.14.0
'use strict'; | ||
const {DOM_PARSER} = require('../shared/symbols.js'); | ||
const {DOM_PARSER, GLOBALS} = require('../shared/symbols.js'); | ||
const {parseFromString} = require('../shared/parse-from-string.js'); | ||
@@ -21,3 +21,3 @@ | ||
*/ | ||
parseFromString(markupLanguage, mimeType) { | ||
parseFromString(markupLanguage, mimeType, globals = null) { | ||
let isHTML = false, document; | ||
@@ -33,2 +33,4 @@ if (mimeType === 'text/html') { | ||
document[DOM_PARSER] = DOMParser; | ||
if (globals) | ||
document[GLOBALS] = globals; | ||
return markupLanguage ? | ||
@@ -35,0 +37,0 @@ parseFromString(document, isHTML, markupLanguage) : |
@@ -35,4 +35,4 @@ 'use strict'; | ||
const parseHTML = html => (new DOMParser).parseFromString( | ||
html, 'text/html' | ||
const parseHTML = (html, globals = null) => (new DOMParser).parseFromString( | ||
html, 'text/html', globals | ||
).defaultView; | ||
@@ -39,0 +39,0 @@ exports.parseHTML = parseHTML; |
@@ -7,3 +7,3 @@ 'use strict'; | ||
const { | ||
CUSTOM_ELEMENTS, DOM_PARSER, IMAGE, MUTATION_OBSERVER, DOCTYPE, END, NEXT, MIME, EVENT_TARGET, UPGRADE | ||
CUSTOM_ELEMENTS, DOM_PARSER, GLOBALS, IMAGE, MUTATION_OBSERVER, DOCTYPE, END, NEXT, MIME, EVENT_TARGET, UPGRADE | ||
} = require('../shared/symbols.js'); | ||
@@ -72,2 +72,3 @@ | ||
this[DOM_PARSER] = null; | ||
this[GLOBALS] = null; | ||
this[IMAGE] = null; | ||
@@ -135,3 +136,5 @@ this[UPGRADE] = null; | ||
} | ||
return globalExports[name] || globalThis[name]; | ||
return (this[GLOBALS] && this[GLOBALS][name]) || | ||
globalExports[name] || | ||
globalThis[name]; | ||
} | ||
@@ -138,0 +141,0 @@ })); |
@@ -38,2 +38,6 @@ 'use strict'; | ||
// used to augment a created document defaultView | ||
const GLOBALS = Symbol('globals'); | ||
exports.GLOBALS = GLOBALS; | ||
// used in both Canvas and Document to provide images | ||
@@ -40,0 +44,0 @@ const IMAGE = Symbol('image'); |
@@ -1,2 +0,2 @@ | ||
import {DOM_PARSER} from '../shared/symbols.js'; | ||
import {DOM_PARSER, GLOBALS} from '../shared/symbols.js'; | ||
import {parseFromString} from '../shared/parse-from-string.js'; | ||
@@ -20,3 +20,3 @@ | ||
*/ | ||
parseFromString(markupLanguage, mimeType) { | ||
parseFromString(markupLanguage, mimeType, globals = null) { | ||
let isHTML = false, document; | ||
@@ -32,2 +32,4 @@ if (mimeType === 'text/html') { | ||
document[DOM_PARSER] = DOMParser; | ||
if (globals) | ||
document[GLOBALS] = globals; | ||
return markupLanguage ? | ||
@@ -34,0 +36,0 @@ parseFromString(document, isHTML, markupLanguage) : |
@@ -19,4 +19,4 @@ import {DOMParser} from './dom/parser.js'; | ||
export const parseHTML = html => (new DOMParser).parseFromString( | ||
html, 'text/html' | ||
export const parseHTML = (html, globals = null) => (new DOMParser).parseFromString( | ||
html, 'text/html', globals | ||
).defaultView; | ||
@@ -23,0 +23,0 @@ |
@@ -6,3 +6,3 @@ import {performance} from '../../commonjs/perf_hooks.cjs'; | ||
import { | ||
CUSTOM_ELEMENTS, DOM_PARSER, IMAGE, MUTATION_OBSERVER, | ||
CUSTOM_ELEMENTS, DOM_PARSER, GLOBALS, IMAGE, MUTATION_OBSERVER, | ||
DOCTYPE, END, NEXT, MIME, EVENT_TARGET, UPGRADE | ||
@@ -72,2 +72,3 @@ } from '../shared/symbols.js'; | ||
this[DOM_PARSER] = null; | ||
this[GLOBALS] = null; | ||
this[IMAGE] = null; | ||
@@ -135,3 +136,5 @@ this[UPGRADE] = null; | ||
} | ||
return globalExports[name] || globalThis[name]; | ||
return (this[GLOBALS] && this[GLOBALS][name]) || | ||
globalExports[name] || | ||
globalThis[name]; | ||
} | ||
@@ -138,0 +141,0 @@ })); |
@@ -28,2 +28,5 @@ // used in Attr to signal changes | ||
// used to augment a created document defaultView | ||
export const GLOBALS = Symbol('globals'); | ||
// used in both Canvas and Document to provide images | ||
@@ -30,0 +33,0 @@ export const IMAGE = Symbol('image'); |
{ | ||
"name": "linkedom", | ||
"version": "0.13.7", | ||
"version": "0.14.0", | ||
"description": "A triple-linked lists based DOM implementation", | ||
@@ -5,0 +5,0 @@ "main": "./cjs/index.js", |
@@ -16,3 +16,3 @@ /** | ||
"text/xml": XMLDocument; | ||
}>(markupLanguage: string, mimeType: MIME): { | ||
}>(markupLanguage: string, mimeType: MIME, globals?: any): { | ||
"text/html": HTMLDocument; | ||
@@ -19,0 +19,0 @@ "image/svg+xml": SVGDocument; |
@@ -10,4 +10,4 @@ export function Document(): void; | ||
export { NodeList } from "./interface/node-list.js"; | ||
export function parseHTML(html: any): Window & typeof globalThis; | ||
export function parseHTML(html: any, globals?: any): Window & typeof globalThis; | ||
import { DOMParser } from "./dom/parser.js"; | ||
export { parseJSON, toJSON } from "./shared/parse-json.js"; |
@@ -39,2 +39,3 @@ /** | ||
[DOM_PARSER]: any; | ||
[GLOBALS]: any; | ||
[IMAGE]: any; | ||
@@ -60,2 +61,3 @@ [UPGRADE]: any; | ||
import { DOM_PARSER } from "../shared/symbols.js"; | ||
import { GLOBALS } from "../shared/symbols.js"; | ||
import { IMAGE } from "../shared/symbols.js"; | ||
@@ -62,0 +64,0 @@ import { UPGRADE } from "../shared/symbols.js"; |
@@ -9,5 +9,5 @@ export function isConnected({ ownerDocument, parentNode }: { | ||
export function previousSibling({ [PREV]: prev }: { | ||
"__@PREV@38345": any; | ||
"__@PREV@38346": any; | ||
}): any; | ||
export function nextSibling(node: any): any; | ||
import { PREV } from "./symbols.js"; |
@@ -10,2 +10,3 @@ export const CHANGED: unique symbol; | ||
export const EVENT_TARGET: unique symbol; | ||
export const GLOBALS: unique symbol; | ||
export const IMAGE: unique symbol; | ||
@@ -12,0 +13,0 @@ export const MIME: unique symbol; |
Sorry, the diff of this file is too big to display
1026754
29843