happy-dom 14.5.0 → 14.5.1
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.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/cjs/index.cjs +33 -6
- package/cjs/index.cjs.map +1 -1
- package/cjs/index.d.ts +4 -2
- package/cjs/index.d.ts.map +1 -1
- package/cjs/window/BrowserWindow.cjs +31 -31
- package/cjs/window/BrowserWindow.cjs.map +1 -1
- package/cjs/window/BrowserWindow.d.ts.map +1 -1
- package/lib/index.d.ts +4 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/window/BrowserWindow.d.ts.map +1 -1
- package/lib/window/BrowserWindow.js +33 -32
- package/lib/window/BrowserWindow.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +5 -1
- package/src/window/BrowserWindow.ts +36 -28
@@ -531,34 +531,6 @@ export default class BrowserWindow extends EventTarget implements INodeJSGlobal
|
|
531
531
|
|
532
532
|
WindowBrowserSettingsReader.setSettings(this, this.#browserFrame.page.context.browser.settings);
|
533
533
|
|
534
|
-
// Binds getts and setters, so that they will appear as an "own" property when using Object.getOwnPropertyNames().
|
535
|
-
// This is needed for Vitest to work as it relies on Object.getOwnPropertyNames() to get the list of properties.
|
536
|
-
// @see https://github.com/capricorn86/happy-dom/issues/1339
|
537
|
-
// Binds all methods to "this", so that it will use the correct context when called globally.
|
538
|
-
const propertyDescriptors = Object.assign(
|
539
|
-
Object.getOwnPropertyDescriptors(EventTarget.prototype),
|
540
|
-
Object.getOwnPropertyDescriptors(BrowserWindow.prototype)
|
541
|
-
);
|
542
|
-
for (const key of Object.keys(propertyDescriptors)) {
|
543
|
-
const descriptor = propertyDescriptors[key];
|
544
|
-
if (descriptor.get || descriptor.set) {
|
545
|
-
Object.defineProperty(this, key, {
|
546
|
-
configurable: true,
|
547
|
-
enumerable: true,
|
548
|
-
get: descriptor.get?.bind(this),
|
549
|
-
set: descriptor.set?.bind(this)
|
550
|
-
});
|
551
|
-
} else if (
|
552
|
-
key !== 'constructor' &&
|
553
|
-
key[0] !== '_' &&
|
554
|
-
key[0] === key[0].toLowerCase() &&
|
555
|
-
typeof this[key] === 'function' &&
|
556
|
-
!this[key].toString().startsWith('class ')
|
557
|
-
) {
|
558
|
-
this[key] = this[key].bind(this);
|
559
|
-
}
|
560
|
-
}
|
561
|
-
|
562
534
|
const window = this;
|
563
535
|
const asyncTaskManager = this.#browserFrame[PropertySymbol.asyncTaskManager];
|
564
536
|
|
@@ -686,6 +658,8 @@ export default class BrowserWindow extends EventTarget implements INodeJSGlobal
|
|
686
658
|
this.document.dispatchEvent(new Event('readystatechange'));
|
687
659
|
this.document.dispatchEvent(new Event('load', { bubbles: true }));
|
688
660
|
});
|
661
|
+
|
662
|
+
this.#bindToThisScope();
|
689
663
|
}
|
690
664
|
|
691
665
|
/**
|
@@ -1349,4 +1323,38 @@ export default class BrowserWindow extends EventTarget implements INodeJSGlobal
|
|
1349
1323
|
|
1350
1324
|
WindowBrowserSettingsReader.removeSettings(this);
|
1351
1325
|
}
|
1326
|
+
|
1327
|
+
/**
|
1328
|
+
* Binds methods, getters and setters to a scope.
|
1329
|
+
*
|
1330
|
+
* Getters and setters need to be bound to show up in Object.getOwnPropertyNames(), which is something Vitest relies on.
|
1331
|
+
*
|
1332
|
+
* @see https://github.com/capricorn86/happy-dom/issues/1339
|
1333
|
+
*/
|
1334
|
+
#bindToThisScope(): void {
|
1335
|
+
const propertyDescriptors = Object.assign(
|
1336
|
+
Object.getOwnPropertyDescriptors(EventTarget.prototype),
|
1337
|
+
Object.getOwnPropertyDescriptors(BrowserWindow.prototype)
|
1338
|
+
);
|
1339
|
+
|
1340
|
+
for (const key of Object.keys(propertyDescriptors)) {
|
1341
|
+
const descriptor = propertyDescriptors[key];
|
1342
|
+
if (descriptor.get || descriptor.set) {
|
1343
|
+
Object.defineProperty(this, key, {
|
1344
|
+
configurable: true,
|
1345
|
+
enumerable: true,
|
1346
|
+
get: descriptor.get?.bind(this),
|
1347
|
+
set: descriptor.set?.bind(this)
|
1348
|
+
});
|
1349
|
+
} else if (
|
1350
|
+
key !== 'constructor' &&
|
1351
|
+
key[0] !== '_' &&
|
1352
|
+
key[0] === key[0].toLowerCase() &&
|
1353
|
+
typeof this[key] === 'function' &&
|
1354
|
+
!this[key].toString().startsWith('class ')
|
1355
|
+
) {
|
1356
|
+
this[key] = this[key].bind(this);
|
1357
|
+
}
|
1358
|
+
}
|
1359
|
+
}
|
1352
1360
|
}
|