Skip to content

Commit

Permalink
fix(cm): call addChild before decorate to prevent goog.ui.Component's…
Browse files Browse the repository at this point in the history
… repositioning

fixes #3
  • Loading branch information
Benjamin Strauß committed Feb 10, 2017
1 parent 7cd166c commit 97d49e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/cm/ComponentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ clulib.cm.ComponentNode = function (manager, element) {
clulib.cm.ComponentNode.prototype.addChild = function (node) {
node.parent_ = this;
this.children_.set(node.getId(), node);
this.component_.addChild(node.component_);
this.component_.addChild(node.component_, false);
node.setDepth(this.depth_ + 1);
};

Expand Down Expand Up @@ -137,7 +137,9 @@ clulib.cm.ComponentNode.prototype.instantiate = function (constructor) {
this.component_.manager = this.manager_;
if (this.config_ != null)
this.component_.setModel(JSON.parse(goog.crypt.base64.decodeString(this.config_)));
};

clulib.cm.ComponentNode.prototype.decorate = function () {
this.component_.decorate(this.element_);
};

Expand Down
5 changes: 5 additions & 0 deletions lib/cm/NodeTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ clulib.cm.NodeTree.prototype.createTree = function (rootElement) {
parentNode.addChild(node);
});

// Decorate components
unsolved.forEach(node => {
node.decorate();
});

// Initialize asynchronously in tree order, bottom up. We create two arrays here to prevent holes.
/**
* @type {Array<Array<clulib.cm.ComponentNode>>}
Expand Down

0 comments on commit 97d49e9

Please sign in to comment.