Skip to content

Commit 10c670f

Browse files
committed
fix(inspector): callFunctionOn and clear maps when document update.
Otherwise new event's nodeId might refer to old node.
1 parent 9531611 commit 10c670f

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

packages/@devtoolcss-inspector/src/DOMWrappers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ export class NodeWrapper {
2121
}
2222
protected async callFunctionOn(args: any[], functionDeclaration: string) {
2323
// always do live check first
24-
const nodeId = this.inspector.getCdpNode(this);
25-
if (!nodeId) {
24+
const cdpNode = this.inspector.getCdpNode(this);
25+
if (!cdpNode) {
2626
throw new Error("Node is not tracked in the inspector");
2727
}
2828

2929
if (!this.objectId) {
3030
// Get the remote object ID for this node
3131
const { object } = await this.inspector.sendCommand("DOM.resolveNode", {
32-
nodeId,
32+
nodeId: cdpNode.nodeId,
3333
});
3434
this.objectId = object.objectId;
3535
}

packages/@devtoolcss-inspector/src/Inspector.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ export class Inspector extends EventEmitter {
405405
}
406406

407407
private async initDOM(): Promise<void> {
408+
this.idToNodes.clear();
409+
this.nodeToId.clear();
408410
const { root } = await this.sendCommand("DOM.getDocument", {
409411
depth: 0,
410412
});

0 commit comments

Comments
 (0)