@@ -124,6 +124,22 @@ LinkHints =
124
124
125
125
marker
126
126
127
+ #
128
+ # Find children elements that have delegated onclick event listener assigned,
129
+ # and mark them with `vimium-has-delegated-onclick-listener` attribute.
130
+ # This will make sure those elements are discovered during `getVisibleClickableElements` call.
131
+ #
132
+ markChildrenThatHaveDelegatedOnClickListener : (element ) ->
133
+ return unless element .hasAttribute " vimium-jquery-delegated-events-selectors"
134
+
135
+ selectorsStr = element .getAttribute " vimium-jquery-delegated-events-selectors"
136
+ selectors = selectorsStr .split (" |" ).filter (x) -> !! x
137
+
138
+ for selector in selectors
139
+ for child in element .querySelectorAll (selector)
140
+ unless child .hasAttribute " vimium-has-delegated-onclick-listener"
141
+ child .setAttribute " vimium-has-delegated-onclick-listener" , " "
142
+
127
143
#
128
144
# Determine whether the element is visible and clickable. If it is, find the rect bounding the element in
129
145
# the viewport. There may be more than one part of element which is clickable (for example, if it's an
@@ -156,9 +172,13 @@ LinkHints =
156
172
if (element .hasAttribute (" onclick" ) or
157
173
element .getAttribute (" role" )? .toLowerCase () in [" button" , " link" ] or
158
174
element .getAttribute (" contentEditable" )? .toLowerCase () in [" " , " contentEditable" , " true" ] or
159
- element .hasAttribute (" vimium-has-onclick-listener" ))
175
+ element .hasAttribute (" vimium-has-onclick-listener" ) or
176
+ element .hasAttribute (" vimium-has-delegated-onclick-listener" ))
160
177
isClickable = true
161
178
179
+ # Dispose the attribute so next time it is not included, in case listener has been removed
180
+ element .removeAttribute " vimium-has-delegated-onclick-listener"
181
+
162
182
# Check for jsaction event listeners on the element.
163
183
if element .hasAttribute " jsaction"
164
184
jsactionRules = element .getAttribute (" jsaction" ).split (" ;" )
@@ -198,6 +218,8 @@ LinkHints =
198
218
if clientRect != null
199
219
visibleElements .push {element : element, rect : clientRect, secondClassCitizen : onlyHasTabIndex}
200
220
221
+ @ markChildrenThatHaveDelegatedOnClickListener element
222
+
201
223
visibleElements
202
224
203
225
#
@@ -208,6 +230,7 @@ LinkHints =
208
230
# element.
209
231
#
210
232
getVisibleClickableElements : ->
233
+ @ markChildrenThatHaveDelegatedOnClickListener document .documentElement
211
234
elements = document .documentElement .getElementsByTagName " *"
212
235
visibleElements = []
213
236
0 commit comments