Skip to content

Commit

Permalink
fix: make webContents.id work even after destroy (#27070)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
  • Loading branch information
trop[bot] and nornagon committed Jan 5, 2021
1 parent cfd848c commit 0113155
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/browser/api/web-contents.ts
Expand Up @@ -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;

Expand Down

0 comments on commit 0113155

Please sign in to comment.