Skip to content

Commit

Permalink
fix(if): set elseFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
fkleuver committed Mar 29, 2019
1 parent b71b0e9 commit f01af55
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/runtime/src/resources/custom-attributes/if.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,13 @@ export class Else<T extends INode = INode> {
container.register(Registration.transient('custom-attribute:else', this));
}

public link(ifBehavior: If<T>): void {
ifBehavior.elseFactory = this.factory;
public link(ifBehavior: If<T> | IController<T>): void {
if (ifBehavior instanceof If) {
ifBehavior.elseFactory = this.factory;
} else if (ifBehavior.viewModel instanceof If) {
ifBehavior.viewModel.elseFactory = this.factory;
} else {
throw new Error(`Unsupported IfBehavior`); // TODO: create error code
}
}
}

0 comments on commit f01af55

Please sign in to comment.