MCPcopy
hub / github.com/philc/vimium / bubbleEvent

Method bubbleEvent

lib/handler_stack.js:49–94  ·  view source on GitHub ↗
(type, event)

Source from the content-addressed store, hash-verified

47 // returning @suppressPropagation or
48 // @passEventToPage.
49 bubbleEvent(type, event) {
50 this.eventNumber += 1;
51 const eventNumber = this.eventNumber;
52 for (const handler of this.stack.slice().reverse()) {
53 // A handler might have been removed (handler.id == null), so check; or there might just be no
54 // handler for this type of event.
55 if (!(handler != null ? handler.id : undefined) || !handler[type]) {
56 if (this.debug) {
57 this.logResult(eventNumber, type, event, handler, `skip [${(handler[type] != null)}]`);
58 }
59 } else {
60 this.currentId = handler.id;
61 const result = handler[type].call(this, event);
62 if (this.debug) this.logResult(eventNumber, type, event, handler, result);
63 if (result === this.passEventToPage) {
64 return true;
65 } else if (result === this.suppressPropagation) {
66 if (type === "keydown") {
67 DomUtils.consumeKeyup(event, null, true);
68 } else {
69 DomUtils.suppressPropagation(event);
70 }
71 return false;
72 } else if (result === this.restartBubbling) {
73 return this.bubbleEvent(type, event);
74 } else if (
75 (result === this.continueBubbling) || (result && (result !== this.suppressEvent))
76 ) {
77 true; // Do nothing, but continue bubbling.
78 } else {
79 // result is @suppressEvent or falsy.
80 if (this.isChromeEvent(event)) {
81 if (type === "keydown") {
82 DomUtils.consumeKeyup(event);
83 } else {
84 DomUtils.suppressEvent(event);
85 }
86 }
87 return false;
88 }
89 }
90 }
91
92 // None of our handlers care about this event, so pass it to the page.
93 return true;
94 }
95
96 remove(id) {
97 if (id == null) id = this.currentId;

Callers 8

simulateSelectFunction · 0.80
setIndicatorMethod · 0.80
replayKeydownEventsMethod · 0.80
activateLinkMethod · 0.80
vimium_frontend.jsFile · 0.80
sendKeyboardEventFunction · 0.80
dom_tests.jsFile · 0.80

Calls 3

logResultMethod · 0.95
isChromeEventMethod · 0.95
suppressEventMethod · 0.80

Tested by

no test coverage detected