Skip to content

Commit 94cedea

Browse files
committed
fix: init $0 xpath in fromChromeDebugger, rename external API to $0
1 parent 7e50edb commit 94cedea

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/Inspector.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type CDPClient = {
3333
export type InspectorOptions = {
3434
documentImpl?: DOMImplementation;
3535
eventTimeout?: number;
36-
selectedNodeXPath?: string;
36+
$0XPath?: string;
3737
sync$0Enabled?: boolean;
3838
};
3939

@@ -72,7 +72,7 @@ export class Inspector extends EventEmitter {
7272
return undefined;
7373
}
7474

75-
setSelectedNodeByXPath(xpath: string): void {
75+
set$0ByXPath(xpath: string): void {
7676
this.selectedNode = this.queryXPath(xpath) || undefined;
7777
}
7878

@@ -182,8 +182,8 @@ export class Inspector extends EventEmitter {
182182
const inspector = new Inspector(sendCommand, onCDP, offCDP, options);
183183
await inspector.init();
184184
await inspector.initDOM();
185-
if (options.selectedNodeXPath) {
186-
inspector.setSelectedNodeByXPath(options.selectedNodeXPath);
185+
if (options.$0XPath) {
186+
inspector.set$0ByXPath(options.$0XPath);
187187
}
188188
return inspector;
189189
}
@@ -219,6 +219,9 @@ export class Inspector extends EventEmitter {
219219
const inspector = new Inspector(sendCommand, onCDP, offCDP, options);
220220
await inspector.init();
221221
await inspector.initDOM();
222+
if (options.$0XPath) {
223+
inspector.set$0ByXPath(options.$0XPath);
224+
}
222225
return inspector;
223226
}
224227

@@ -477,7 +480,7 @@ export class Inspector extends EventEmitter {
477480
this.onCDP(
478481
"Runtime.bindingCalled",
479482
(params: { name: string; payload: string }) => {
480-
if (this.sync$0Enabled) this.setSelectedNodeByXPath(params.payload);
483+
if (this.sync$0Enabled) this.set$0ByXPath(params.payload);
481484
},
482485
);
483486
}

0 commit comments

Comments
 (0)