Skip to content

Commit

Permalink
fix reverse: component as component root
Browse files Browse the repository at this point in the history
  • Loading branch information
errorrik committed Jun 1, 2020
1 parent 66bb084 commit 108c761
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/view/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,26 @@ function Component(options) { // eslint-disable-line
this._toPhase('inited');

// #[begin] reverse
var hasRootNode = this.aNode.hotspot.hasRootNode
|| (this.getComponentType
? this.getComponentType(this.aNode, this.data)
: this.components[this.aNode.tagName]
);
var reverseWalker = options.reverseWalker;

if (this.el || reverseWalker) {
if (hasRootNode) {
reverseWalker = reverseWalker || new DOMChildrenWalker(this.el);
var RootComponentType = this.getComponentType
? this.getComponentType(this.aNode, this.data)
: this.components[this.aNode.tagName];

if (reverseWalker && (this.aNode.hotspot.hasRootNode || RootComponentType)) {
this._rootNode = createReverseNode(this.aNode, this, this.data, this, reverseWalker);
this._rootNode._getElAsRootNode && (this.el = this._rootNode._getElAsRootNode());
}
else if (this.el && RootComponentType) {
this._rootNode = new RootComponentType({
source: this.aNode,
owner: this,
scope: this.data,
parent: this,
subTag: this.aNode.tagName,
el: this.el
});
}
else {
if (reverseWalker) {
var currentNode = reverseWalker.current;
Expand Down

0 comments on commit 108c761

Please sign in to comment.