File tree 1 file changed +13
-6
lines changed
1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -143,13 +143,20 @@ function matchingLabels(el) {
143
143
// as the mouseCancellor code will handle ancstor labels
144
144
if ( ! labels . length ) {
145
145
labels = [ ] ;
146
- let root = el . getRootNode ( ) ;
147
- // if there is an id on `el`, check for all labels with a matching `for` attribute
148
- if ( el . id ) {
149
- let matching = root . querySelectorAll ( `label[for = ${ el . id } ]` ) ;
150
- for ( let i = 0 ; i < matching . length ; i ++ ) {
151
- labels . push ( /** @type {!HTMLLabelElement } */ ( matching [ i ] ) ) ;
146
+ try {
147
+ let root = el . getRootNode ( ) ;
148
+ // if there is an id on `el`, check for all labels with a matching `for` attribute
149
+ if ( el . id ) {
150
+ let matching = root . querySelectorAll ( `label[for = ${ el . id } ]` ) ;
151
+ for ( let i = 0 ; i < matching . length ; i ++ ) {
152
+ labels . push ( /** @type {!HTMLLabelElement } */ ( matching [ i ] ) ) ;
153
+ }
152
154
}
155
+ } catch ( e ) {
156
+ // Either:
157
+ // 1. el.getRootNode() failed.
158
+ // 2. el.id cannot be used in `querySelectorAll`
159
+ // In both cases, do nothing.
153
160
}
154
161
}
155
162
return labels ;
You can’t perform that action at this time.
0 commit comments