Skip to content

Commit

Permalink
Auto patch window if browser
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardocavazza committed Oct 2, 2023
1 parent f038fe0 commit 427dae8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-tools-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chialab/quantum': patch
---

Auto patch window if browser.
8 changes: 2 additions & 6 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"mode": "pre",
"tag": "latest",
"tag": "alpha",
"initialVersions": {
"@chialab/quantum": "0.0.1"
},
"changesets": [
"kind-buckets-drop",
"spicy-worms-double",
"three-trainers-design"
]
"changesets": ["kind-buckets-drop", "spicy-worms-double", "three-trainers-design"]
}
6 changes: 1 addition & 5 deletions src/Realm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { extend } from './extend.js';

/**
* @typedef {{ addedNodes: ChildNode[]; removedNodes: ChildNode[]; previousSibling: ChildNode | null; nextSibling: ChildNode | null }} MutationRecord
*/
Expand All @@ -14,11 +12,9 @@ const REALM_PARENT_SYMBOL = Symbol();
/**
* Create and attach a realm for a node.
* @param {HTMLElement & { [REALM_SYMBOL]?: Realm }} node The root node.
* @param {Window & typeof globalThis} [namespace] The namespace to use as DOM environment.
* @returns The realm instance.
*/
export function attachRealm(node, namespace = window) {
extend(namespace);
export function attachRealm(node) {
if (REALM_SYMBOL in node) {
throw new Error('Node already has a realm');
}
Expand Down
8 changes: 7 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
export { extend } from './extend.js';
import { extend } from './extend.js';

export { extend };
export { Realm, attachRealm, getRealm } from './Realm.js';

if (typeof window !== 'undefined') {
extend(window);
}

0 comments on commit 427dae8

Please sign in to comment.