implement getPath for any type. types now initialize _parent. fix some cases where observeDeep is not fired
This commit is contained in:
parent
edf47d3491
commit
361d4a48e1
25
src/Utils.js
25
src/Utils.js
@ -31,9 +31,13 @@ module.exports = function (Y /* : any*/) {
|
|||||||
event.path = []
|
event.path = []
|
||||||
while (type != null && type._deepEventHandler != null) {
|
while (type != null && type._deepEventHandler != null) {
|
||||||
type._deepEventHandler.callEventListeners(event)
|
type._deepEventHandler.callEventListeners(event)
|
||||||
if (type._parent != null && type._parentSub != null) {
|
var parent = null
|
||||||
event.path = [type._parentSub].concat(event.path)
|
if (type._parent != null) {
|
||||||
type = type.os.getType(type._parent)
|
parent = type.os.getType(type._parent)
|
||||||
|
}
|
||||||
|
if (parent != null && parent._getPathToChild != null) {
|
||||||
|
event.path = [parent._getPathToChild(type._model)].concat(event.path)
|
||||||
|
type = parent
|
||||||
} else {
|
} else {
|
||||||
type = null
|
type = null
|
||||||
}
|
}
|
||||||
@ -478,7 +482,20 @@ module.exports = function (Y /* : any*/) {
|
|||||||
Default class of custom types!
|
Default class of custom types!
|
||||||
*/
|
*/
|
||||||
class CustomType {
|
class CustomType {
|
||||||
|
getPath () {
|
||||||
|
var parent = null
|
||||||
|
if (this._parent != null) {
|
||||||
|
parent = this.os.getType(this._parent)
|
||||||
|
}
|
||||||
|
if (parent != null && parent._getPathToChild != null) {
|
||||||
|
var firstKey = parent._getPathToChild(this._model)
|
||||||
|
var parentKeys = parent.getPath()
|
||||||
|
parentKeys.push(firstKey)
|
||||||
|
return parentKeys
|
||||||
|
} else {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Y.utils.CustomType = CustomType
|
Y.utils.CustomType = CustomType
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user