Skip to content

Commit a93ec73

Browse files
caitptbosch
authored andcommitted
build(broccoli): store DiffResult for re-use only if DiffResult
One of the non-angular broccoli plugins returns a weird object. We can't assume that all trees meet the contract that we expect them to meet, so we do a typecheck before storing the result of the rebuild. Closes angular#2662
1 parent 9a290f0 commit a93ec73

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tools/broccoli/diffing-broccoli-plugin.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ class DiffingPluginWrapper implements BroccoliTree {
7474
// Otherwise, `this.diffResult` was produced from the output of the
7575
// inputTree's rebuild() method, and can be used without being checked.
7676
// Set `this.diffResult` to null and return the previously stored value.
77-
if (!tree.diffResult) {
78-
let differ = index === false ? this.treeDiffer : this.treeDiffers[index];
79-
return differ.diffTree();
80-
}
8177
let diffResult = tree.diffResult;
8278
tree.diffResult = null;
79+
if (!diffResult) {
80+
let differ = index === false ? this.treeDiffer : this.treeDiffers[index];
81+
diffResult = differ.diffTree();
82+
}
8383
return diffResult;
8484
};
8585

@@ -93,10 +93,11 @@ class DiffingPluginWrapper implements BroccoliTree {
9393
}
9494

9595
private maybeStoreDiffResult(value: (DiffResult | void)) {
96-
this.diffResult = value ? <DiffResult>(value) : null;
96+
if (!(value instanceof DiffResult)) value = null;
97+
this.diffResult = <DiffResult>(value);
9798
}
9899

99-
rebuild() {
100+
rebuild(): (Promise<any>| void) {
100101
try {
101102
let firstRun = !this.initialized;
102103
this.init();

0 commit comments

Comments
 (0)