observeDeep receives array of events

This commit is contained in:
Kevin Jahns
2017-11-07 22:44:43 -08:00
parent c453593ee7
commit e5f289506f
6 changed files with 126 additions and 91 deletions

View File

@@ -2,26 +2,32 @@
export default class YEvent {
constructor (target) {
this.target = target
this._path = null
}
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
if (this._path !== null) {
return this._path
} else {
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
}
type = parent
this._path = path
return path
}
return path
}
}