Fix wrong internal caching of absolute attributes. fix #843

This commit is contained in:
Anton Lavrenov
2020-02-10 08:22:07 -05:00
parent 2634bbbf89
commit 86f847a702
6 changed files with 70 additions and 15 deletions

View File

@@ -123,13 +123,14 @@ export abstract class Container<ChildType extends Node> extends Node<
}
return this;
}
var child = arguments[0];
var child = children[0];
if (child.getParent()) {
child.moveTo(this);
return this;
}
var _children = this.children;
this._validateAdd(child);
child._clearCaches();
child.index = _children.length;
child.parent = this;
_children.push(child);

View File

@@ -843,14 +843,19 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
this._remove();
return this;
}
_clearCaches() {
this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);
this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);
this._clearSelfAndDescendantCache(ABSOLUTE_SCALE);
this._clearSelfAndDescendantCache(STAGE);
this._clearSelfAndDescendantCache(VISIBLE);
this._clearSelfAndDescendantCache(LISTENING);
}
_remove() {
// every cached attr that is calculated via node tree
// traversal must be cleared when removing a node
this._clearSelfAndDescendantCache(STAGE);
this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);
this._clearSelfAndDescendantCache(VISIBLE);
this._clearSelfAndDescendantCache(LISTENING);
this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);
this._clearCaches();
var parent = this.getParent();
if (parent && parent.children) {