Skip to content

Commit d5a51f9

Browse files
committed
improve delegation check algorithm
1 parent 4e6ad72 commit d5a51f9

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/directives/on.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
var utils = require('../utils')
22

3-
function delegateCheck (current, top, identifier) {
4-
if (current[identifier]) {
5-
return current
6-
} else if (current === top || !current.parentNode) {
7-
return false
8-
} else {
9-
return delegateCheck(current.parentNode, top, identifier)
3+
function delegateCheck (el, root, identifier) {
4+
while (el && el !== root) {
5+
if (el[identifier]) return el
6+
el = el.parentNode
107
}
118
}
129

0 commit comments

Comments
 (0)