mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: make webContents.id work even after destroy (#27070)
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
This commit is contained in:
@@ -528,6 +528,13 @@ WebContents.prototype._init = function () {
|
||||
this.goToOffset = navigationController.goToOffset.bind(navigationController);
|
||||
this.getActiveIndex = navigationController.getActiveIndex.bind(navigationController);
|
||||
this.length = navigationController.length.bind(navigationController);
|
||||
// Read off the ID at construction time, so that it's accessible even after
|
||||
// the underlying C++ WebContents is destroyed.
|
||||
const id = this.id;
|
||||
Object.defineProperty(this, 'id', {
|
||||
value: id,
|
||||
writable: false
|
||||
});
|
||||
|
||||
this._windowOpenHandler = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user