diff --git a/cjs/interface/document.js b/cjs/interface/document.js index 9c689cfa..1a92fb28 100644 --- a/cjs/interface/document.js +++ b/cjs/interface/document.js @@ -1,6 +1,4 @@ 'use strict'; -const {performance} = require('../../commonjs/perf_hooks.cjs'); - const {DOCUMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, SVG_NAMESPACE} = require('../shared/constants.js'); const { @@ -120,7 +118,7 @@ class Document extends NonElementParentNode { this[CUSTOM_ELEMENTS] = new CustomElementRegistry(this); return this[CUSTOM_ELEMENTS]; case 'performance': - return performance; + return globalThis.performance; case 'DOMParser': return this[DOM_PARSER]; case 'Image': diff --git a/commonjs/perf_hooks.cjs b/commonjs/perf_hooks.cjs deleted file mode 100644 index d574aefc..00000000 --- a/commonjs/perf_hooks.cjs +++ /dev/null @@ -1,9 +0,0 @@ -/* c8 ignore start */ -try { - const {performance} = require('perf_hooks'); - exports.performance = performance; -} -catch (fallback) { - exports.performance = {now() { return +new Date; }}; -} -/* c8 ignore stop */ diff --git a/esm/interface/document.js b/esm/interface/document.js index a253e656..d68c9eb5 100644 --- a/esm/interface/document.js +++ b/esm/interface/document.js @@ -1,5 +1,3 @@ -import {performance} from '../../commonjs/perf_hooks.cjs'; - import {DOCUMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, SVG_NAMESPACE} from '../shared/constants.js'; import { @@ -120,7 +118,7 @@ export class Document extends NonElementParentNode { this[CUSTOM_ELEMENTS] = new CustomElementRegistry(this); return this[CUSTOM_ELEMENTS]; case 'performance': - return performance; + return globalThis.performance; case 'DOMParser': return this[DOM_PARSER]; case 'Image': diff --git a/package.json b/package.json index d7d86b64..5c6ac64e 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,9 @@ "htmlparser2": "^10.0.0", "uhyphen": "^0.2.0" }, + "engines": { + "node": ">=16" + }, "repository": { "type": "git", "url": "git+https://github.com/WebReflection/linkedom.git" diff --git a/rollup/es.config.js b/rollup/es.config.js index a8fa09b3..a43ca4b4 100644 --- a/rollup/es.config.js +++ b/rollup/es.config.js @@ -19,20 +19,12 @@ export default { function shims() { return { resolveId(specifier) { - if(specifier.endsWith('perf_hooks.cjs')) { - return 'shim:perf_hooks'; - } if(specifier.endsWith('canvas.cjs')) { return 'shim:canvas'; } }, load(id) { switch(id) { - case 'shim:perf_hooks': { - return ` - export const performance = globalThis.performance; - `; - } case 'shim:canvas': { return ` class Canvas { diff --git a/worker.js b/worker.js index d7720bdd..21ed3f9c 100644 --- a/worker.js +++ b/worker.js @@ -4229,8 +4229,6 @@ const registerHTMLClass = (names, Class) => { } }; -const performance = globalThis.performance; - const loopSegment = ({[NEXT]: next, [END]: end}, json) => { while (next !== end) { switch (next.nodeType) { @@ -12322,7 +12320,7 @@ let Document$1 = class Document extends NonElementParentNode { this[CUSTOM_ELEMENTS] = new CustomElementRegistry(this); return this[CUSTOM_ELEMENTS]; case 'performance': - return performance; + return globalThis.performance; case 'DOMParser': return this[DOM_PARSER]; case 'Image':