diff --git a/src/Util/YEvent.js b/src/Util/YEvent.js new file mode 100644 index 00000000..3e0b1eee --- /dev/null +++ b/src/Util/YEvent.js @@ -0,0 +1,27 @@ + +export default class YEvent { + constructor (target) { + this.target = target + } + get path () { + const path = [] + let type = this.target + const y = type._y + while (type._parent !== y) { + let parent = type._parent + if (type._parentSub !== null) { + path.push(type._parentSub) + } else { + // parent is array-ish + for (let [i, child] of parent) { + if (child === type) { + path.push(i) + break + } + } + } + type = parent + } + return path + } +}