@stencil/mock-doc 5.0.0-beta.2 → 5.0.0-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -567,7 +567,7 @@ declare class MockTokenList {
567
567
  add(...tokens: string[]): void;
568
568
  remove(...tokens: string[]): void;
569
569
  contains(token: string): boolean;
570
- toggle(token: string): void;
570
+ toggle(token: string, force?: boolean): boolean;
571
571
  get length(): number;
572
572
  item(index: number): string;
573
573
  toString(): string;
package/dist/index.mjs CHANGED
@@ -1323,10 +1323,12 @@ var MockTokenList = class {
1323
1323
  token = String(token);
1324
1324
  return getItems(this.elm, this.attr).includes(token);
1325
1325
  }
1326
- toggle(token) {
1326
+ toggle(token, force) {
1327
1327
  token = String(token);
1328
- if (this.contains(token) === true) this.remove(token);
1329
- else this.add(token);
1328
+ const shouldAdd = force === void 0 ? !this.contains(token) : !!force;
1329
+ if (shouldAdd) this.add(token);
1330
+ else this.remove(token);
1331
+ return shouldAdd;
1330
1332
  }
1331
1333
  get length() {
1332
1334
  return getItems(this.elm, this.attr).length;
@@ -5286,11 +5288,14 @@ function resetWindow(win) {
5286
5288
  if (win.document != null) try {
5287
5289
  win.document.defaultView = win;
5288
5290
  } catch {}
5289
- win.fetch = null;
5290
- win.Headers = null;
5291
- win.Request = null;
5292
- win.Response = null;
5293
- win.FetchError = null;
5291
+ const windowDestroyed = () => {
5292
+ throw new Error("MockWindow was already destroyed");
5293
+ };
5294
+ win.fetch = windowDestroyed;
5295
+ win.Headers = windowDestroyed;
5296
+ win.Request = windowDestroyed;
5297
+ win.Response = windowDestroyed;
5298
+ win.FetchError = windowDestroyed;
5294
5299
  }
5295
5300
  }
5296
5301
  function resetWindowDimensions(win) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/mock-doc",
3
- "version": "5.0.0-beta.2",
3
+ "version": "5.0.0-beta.20",
4
4
  "description": "A minimal mock DOM implementation for SSR and testing",
5
5
  "keywords": [
6
6
  "dom",
@@ -41,6 +41,9 @@
41
41
  "typescript": ">5.0.0 <7.0.0",
42
42
  "vitest": "^4.1.10"
43
43
  },
44
+ "engines": {
45
+ "node": ">=22.0.0"
46
+ },
44
47
  "volta": {
45
48
  "extends": "../../package.json"
46
49
  },