less duplicate code

This commit is contained in:
Kevin Jahns
2018-03-23 05:22:45 +01:00
parent ba97bfdd9e
commit 61149b458a
3 changed files with 36 additions and 68 deletions

View File

@@ -31,24 +31,6 @@ export default class YEvent {
* type === event.target // => true
*/
get path () {
const path = []
let type = this.target
const y = type._y
while (type !== this.currentTarget && type !== y) {
let parent = type._parent
if (type._parentSub !== null) {
path.unshift(type._parentSub)
} else {
// parent is array-ish
for (let [i, child] of parent) {
if (child === type) {
path.unshift(i)
break
}
}
}
type = parent
}
return path
return this.currentTarget.getPathTo(this.target)
}
}