Skip to content

Commit f636aa6

Browse files
committed
parse text node for Hints across JS world with event target
1 parent 02716b7 commit f636aa6

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/content_scripts/common/hints.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,10 @@ div.hint-scrollable {
437437
}
438438
} else {
439439
if (elm.constructor.name === "Array") {
440+
const target = elm[0];
440441
// remove Text Node from elm as it cannot be transitted across JS scope
441-
elm[0] = null;
442-
dispatchSKEvent('user', ["onHintClicked", elm]);
442+
elm[0] = "__EVENT_TARGET__";
443+
dispatchSKEvent('user', ["onHintClicked", elm], target);
443444
} else {
444445
dispatchSKEvent('user', ["onHintClicked"], elm);
445446
}

src/content_scripts/common/utils.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,12 @@ function initSKFunctionListener(name, interfaces, capture) {
291291
let args = evt.detail;
292292
const fk = args.shift();
293293
if (capture) {
294-
args.push(evt.target);
294+
if (args[0].constructor.name === "Array" && args[0][0] === "__EVENT_TARGET__") {
295+
// restore args from evt.target, see src/content_scripts/common/hints.js:442
296+
args[0][0] = evt.target;
297+
} else {
298+
args.push(evt.target);
299+
}
295300
}
296301

297302
if (callbacks.hasOwnProperty(fk)) {

0 commit comments

Comments
 (0)