Skip to content

Commit

Permalink
Export extend methods
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardocavazza committed Oct 3, 2023
1 parent 1c9ca71 commit 2a8158b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-swans-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chialab/quantum': patch
---

Export extend methods.
13 changes: 3 additions & 10 deletions src/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@ import { extendElement } from './Element.js';
import { extendNode } from './Node.js';
import { extendTreeWalker } from './TreeWalker.js';

/**
* Whether the DOM environment is extended.
*/
let extended = false;

/**
* Extend constructors in the given window namespace.
* @param {Window & typeof globalThis} window The window namespace to extend.
*/
export function extend(window) {
if (extended) {
return;
}
extendNode(window.Node);
extendElement(window.Element);
extendTreeWalker(window.TreeWalker, window.NodeFilter);
extended = true;
if (typeof window.TreeWalker !== 'undefined') {
extendTreeWalker(window.TreeWalker, window.NodeFilter);
}
}
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { extend } from './extend.js';

export { extend };
export { extendNode } from './Node.js';
export { extendElement } from './Element.js';
export { extendTreeWalker } from './TreeWalker.js';
export { Realm, attachRealm, getRealm } from './Realm.js';

if (typeof window !== 'undefined') {
Expand Down

0 comments on commit 2a8158b

Please sign in to comment.