Skip to content
This repository was archived by the owner on Sep 16, 2022. It is now read-only.

Commit e487913

Browse files
committed
refactor(Compiler): Always emit a check for throwOnChanges, removed in Dart2JS.
After this CL there is _no_ diff in the compiled code for `hacker_news_pwa`. PiperOrigin-RevId: 200445780
1 parent d332d6f commit e487913

12 files changed

+105
-90
lines changed

_goldens/test/_files/core_directives.template_release.golden

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ class ViewTestFooComponent0 extends AppView<import1.TestFooComponent> {
7070
(_NgFor_1_9.ngForOf = _ctx.bars);
7171
}
7272
}
73-
_NgFor_1_9.ngDoCheck();
73+
if (!import8.AppViewUtils.throwOnChanges) {
74+
_NgFor_1_9.ngDoCheck();
75+
}
7476
_appEl_1.detectChangesInNestedViews();
7577
}
7678

_goldens/test/_files/directives/generics.template_release.golden

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,9 @@ class ViewNestedParentComp0 extends AppView<import1.NestedParentComp> {
12361236
_NgFor_2_9.ngForOf = currVal_2;
12371237
_expr_2 = currVal_2;
12381238
}
1239-
_NgFor_2_9.ngDoCheck();
1239+
if (!import6.AppViewUtils.throwOnChanges) {
1240+
_NgFor_2_9.ngDoCheck();
1241+
}
12401242
_appEl_2.detectChangesInNestedViews();
12411243
_compView_0.detectChanges();
12421244
_compView_1.detectChanges();

_goldens/test/_files/directives/nested_ng_for.template_release.golden

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ class ViewNestedNgForComponent0 extends AppView<import1.NestedNgForComponent> {
5454
_NgFor_0_9.ngForOf = currVal_0;
5555
_expr_0 = currVal_0;
5656
}
57-
_NgFor_0_9.ngDoCheck();
57+
if (!import8.AppViewUtils.throwOnChanges) {
58+
_NgFor_0_9.ngDoCheck();
59+
}
5860
_appEl_0.detectChangesInNestedViews();
5961
}
6062

@@ -97,7 +99,9 @@ class _ViewNestedNgForComponent1 extends AppView<import1.NestedNgForComponent> {
9799
_NgFor_1_9.ngForOf = currVal_0;
98100
_expr_0 = currVal_0;
99101
}
100-
_NgFor_1_9.ngDoCheck();
102+
if (!import8.AppViewUtils.throwOnChanges) {
103+
_NgFor_1_9.ngDoCheck();
104+
}
101105
_appEl_1.detectChangesInNestedViews();
102106
}
103107

_goldens/test/_files/inherited_lifecycle_hooks.template_debug.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class _ViewLifecycleHooksComponentHost0 extends AppView<dynamic> {
5858
@override
5959
void detectChangesInternal() {
6060
bool firstCheck = (this.cdState == 0);
61-
if ((firstCheck && !import6.AppViewUtils.throwOnChanges)) {
61+
if ((!import6.AppViewUtils.throwOnChanges && firstCheck)) {
6262
_LifecycleHooksComponent_0_5.ngOnInit();
6363
}
6464
if (!import6.AppViewUtils.throwOnChanges) {

_goldens/test/_files/inherited_lifecycle_hooks.template_release.golden

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,25 @@ class _ViewLifecycleHooksComponentHost0 extends AppView<dynamic> {
5858
@override
5959
void detectChangesInternal() {
6060
bool firstCheck = (this.cdState == 0);
61-
if (firstCheck) {
61+
if ((!import6.AppViewUtils.throwOnChanges && firstCheck)) {
6262
_LifecycleHooksComponent_0_5.ngOnInit();
6363
}
64-
_LifecycleHooksComponent_0_5.ngDoCheck();
65-
if (firstCheck) {
66-
_LifecycleHooksComponent_0_5.ngAfterContentInit();
64+
if (!import6.AppViewUtils.throwOnChanges) {
65+
_LifecycleHooksComponent_0_5.ngDoCheck();
66+
}
67+
if (!import6.AppViewUtils.throwOnChanges) {
68+
if (firstCheck) {
69+
_LifecycleHooksComponent_0_5.ngAfterContentInit();
70+
}
71+
_LifecycleHooksComponent_0_5.ngAfterContentChecked();
6772
}
68-
_LifecycleHooksComponent_0_5.ngAfterContentChecked();
6973
_compView_0.detectChanges();
70-
if (firstCheck) {
71-
_LifecycleHooksComponent_0_5.ngAfterViewInit();
74+
if (!import6.AppViewUtils.throwOnChanges) {
75+
if (firstCheck) {
76+
_LifecycleHooksComponent_0_5.ngAfterViewInit();
77+
}
78+
_LifecycleHooksComponent_0_5.ngAfterViewChecked();
7279
}
73-
_LifecycleHooksComponent_0_5.ngAfterViewChecked();
7480
}
7581

7682
@override

_goldens/test/_files/lifecycle_hooks.template_debug.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class _ViewLifecycleHooksComponentHost0 extends AppView<dynamic> {
5858
@override
5959
void detectChangesInternal() {
6060
bool firstCheck = (this.cdState == 0);
61-
if ((firstCheck && !import6.AppViewUtils.throwOnChanges)) {
61+
if ((!import6.AppViewUtils.throwOnChanges && firstCheck)) {
6262
_LifecycleHooksComponent_0_5.ngOnInit();
6363
}
6464
if (!import6.AppViewUtils.throwOnChanges) {

_goldens/test/_files/lifecycle_hooks.template_release.golden

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,25 @@ class _ViewLifecycleHooksComponentHost0 extends AppView<dynamic> {
5858
@override
5959
void detectChangesInternal() {
6060
bool firstCheck = (this.cdState == 0);
61-
if (firstCheck) {
61+
if ((!import6.AppViewUtils.throwOnChanges && firstCheck)) {
6262
_LifecycleHooksComponent_0_5.ngOnInit();
6363
}
64-
_LifecycleHooksComponent_0_5.ngDoCheck();
65-
if (firstCheck) {
66-
_LifecycleHooksComponent_0_5.ngAfterContentInit();
64+
if (!import6.AppViewUtils.throwOnChanges) {
65+
_LifecycleHooksComponent_0_5.ngDoCheck();
66+
}
67+
if (!import6.AppViewUtils.throwOnChanges) {
68+
if (firstCheck) {
69+
_LifecycleHooksComponent_0_5.ngAfterContentInit();
70+
}
71+
_LifecycleHooksComponent_0_5.ngAfterContentChecked();
6772
}
68-
_LifecycleHooksComponent_0_5.ngAfterContentChecked();
6973
_compView_0.detectChanges();
70-
if (firstCheck) {
71-
_LifecycleHooksComponent_0_5.ngAfterViewInit();
74+
if (!import6.AppViewUtils.throwOnChanges) {
75+
if (firstCheck) {
76+
_LifecycleHooksComponent_0_5.ngAfterViewInit();
77+
}
78+
_LifecycleHooksComponent_0_5.ngAfterViewChecked();
7279
}
73-
_LifecycleHooksComponent_0_5.ngAfterViewChecked();
7480
}
7581

7682
@override

_goldens/test/_files/queries.template_release.golden

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,17 @@ class ViewQueriesComponent0 extends AppView<import1.QueriesComponent> {
7373
final import1.QueriesComponent _ctx = ctx;
7474
_NgIf_2_9.ngIf = _ctx.someValue;
7575
_appEl_2.detectChangesInNestedViews();
76-
if (_query_AnotherDirective_1_5_isDirty) {
77-
ctx.usingTypeFromField = import8.flattenNodes([
78-
[_AnotherDirective_0_5],
79-
[_AnotherDirective_1_5],
80-
_appEl_2.mapNestedViews((_ViewQueriesComponent1 nestedView) {
81-
return [nestedView._AnotherDirective_0_5];
82-
})
83-
]);
84-
_query_AnotherDirective_1_5_isDirty = false;
76+
if (!import8.AppViewUtils.throwOnChanges) {
77+
if (_query_AnotherDirective_1_5_isDirty) {
78+
ctx.usingTypeFromField = import8.flattenNodes([
79+
[_AnotherDirective_0_5],
80+
[_AnotherDirective_1_5],
81+
_appEl_2.mapNestedViews((_ViewQueriesComponent1 nestedView) {
82+
return [nestedView._AnotherDirective_0_5];
83+
})
84+
]);
85+
_query_AnotherDirective_1_5_isDirty = false;
86+
}
8587
}
8688
}
8789

@@ -190,17 +192,19 @@ class ViewEmbeddedQueries0 extends AppView<import1.EmbeddedQueries> {
190192

191193
@override
192194
void detectChangesInternal() {
193-
if (_query_AnotherDirective_1_0_isDirty) {
194-
ctx.viewChildren = import8.flattenNodes([
195-
[_AnotherDirective_0_5],
196-
_appEl_1.mapNestedViews((_ViewEmbeddedQueries1 nestedView) {
197-
return [nestedView._AnotherDirective_0_5];
198-
}),
199-
_appEl_2.mapNestedViews((_ViewEmbeddedQueries2 nestedView) {
200-
return [nestedView._AnotherDirective_0_5];
201-
})
202-
]);
203-
_query_AnotherDirective_1_0_isDirty = false;
195+
if (!import8.AppViewUtils.throwOnChanges) {
196+
if (_query_AnotherDirective_1_0_isDirty) {
197+
ctx.viewChildren = import8.flattenNodes([
198+
[_AnotherDirective_0_5],
199+
_appEl_1.mapNestedViews((_ViewEmbeddedQueries1 nestedView) {
200+
return [nestedView._AnotherDirective_0_5];
201+
}),
202+
_appEl_2.mapNestedViews((_ViewEmbeddedQueries2 nestedView) {
203+
return [nestedView._AnotherDirective_0_5];
204+
})
205+
]);
206+
_query_AnotherDirective_1_0_isDirty = false;
207+
}
204208
}
205209
}
206210
}
@@ -326,17 +330,19 @@ class ViewEmbeddedQueriesList0 extends AppView<import1.EmbeddedQueriesList> {
326330

327331
@override
328332
void detectChangesInternal() {
329-
if (_query_AnotherDirective_1_0_isDirty) {
330-
ctx.viewChildren = import8.flattenNodes([
331-
[_AnotherDirective_0_5],
332-
_appEl_1.mapNestedViews((_ViewEmbeddedQueriesList1 nestedView) {
333-
return [nestedView._AnotherDirective_0_5];
334-
}),
335-
_appEl_2.mapNestedViews((_ViewEmbeddedQueriesList2 nestedView) {
336-
return [nestedView._AnotherDirective_0_5];
337-
})
338-
]);
339-
_query_AnotherDirective_1_0_isDirty = false;
333+
if (!import8.AppViewUtils.throwOnChanges) {
334+
if (_query_AnotherDirective_1_0_isDirty) {
335+
ctx.viewChildren = import8.flattenNodes([
336+
[_AnotherDirective_0_5],
337+
_appEl_1.mapNestedViews((_ViewEmbeddedQueriesList1 nestedView) {
338+
return [nestedView._AnotherDirective_0_5];
339+
}),
340+
_appEl_2.mapNestedViews((_ViewEmbeddedQueriesList2 nestedView) {
341+
return [nestedView._AnotherDirective_0_5];
342+
})
343+
]);
344+
_query_AnotherDirective_1_0_isDirty = false;
345+
}
340346
}
341347
}
342348
}
@@ -457,15 +463,17 @@ class ViewNestedNgForQueriesList0 extends AppView<import1.NestedNgForQueriesList
457463
final import1.NestedNgForQueriesList _ctx = ctx;
458464
_NgIf_0_9.ngIf = _ctx.conditionA;
459465
_appEl_0.detectChangesInNestedViews();
460-
if (_query_taggedItem_1_0_isDirty) {
461-
ctx.taggedItems = _appEl_0.mapNestedViews((_ViewNestedNgForQueriesList1 nestedView) {
462-
return nestedView._appEl_1.mapNestedViews((_ViewNestedNgForQueriesList2 nestedView) {
463-
return nestedView._appEl_1.mapNestedViews((_ViewNestedNgForQueriesList3 nestedView) {
464-
return [new ElementRef(nestedView._el_0)];
466+
if (!import8.AppViewUtils.throwOnChanges) {
467+
if (_query_taggedItem_1_0_isDirty) {
468+
ctx.taggedItems = _appEl_0.mapNestedViews((_ViewNestedNgForQueriesList1 nestedView) {
469+
return nestedView._appEl_1.mapNestedViews((_ViewNestedNgForQueriesList2 nestedView) {
470+
return nestedView._appEl_1.mapNestedViews((_ViewNestedNgForQueriesList3 nestedView) {
471+
return [new ElementRef(nestedView._el_0)];
472+
});
465473
});
466474
});
467-
});
468-
_query_taggedItem_1_0_isDirty = false;
475+
_query_taggedItem_1_0_isDirty = false;
476+
}
469477
}
470478
}
471479

@@ -545,7 +553,9 @@ class _ViewNestedNgForQueriesList2 extends AppView<import1.NestedNgForQueriesLis
545553
(_NgFor_1_9.ngForOf = _ctx.items);
546554
}
547555
}
548-
_NgFor_1_9.ngDoCheck();
556+
if (!import8.AppViewUtils.throwOnChanges) {
557+
_NgFor_1_9.ngDoCheck();
558+
}
549559
_appEl_1.detectChangesInNestedViews();
550560
}
551561

angular/lib/src/compiler/identifiers.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ final ngIfUrl = "asset:angular/lib/src/common/directives/ng_if.dart";
1212
final ngForUrl = "asset:angular/lib/src/common/directives/ng_for.dart";
1313
final profileRuntimeModuleUrl =
1414
"asset:angular/lib/src/debug/profile_runtime.dart";
15+
final runtimeUtilsModuleUrl = "asset:angular/lib/src/runtime.dart";
1516

1617
class Identifiers {
1718
static final appViewUtils = new CompileIdentifierMetadata<dynamic>(
@@ -101,6 +102,8 @@ class Identifiers {
101102
/// (most common case).
102103
static final throwOnChanges = new CompileIdentifierMetadata<dynamic>(
103104
name: "AppViewUtils.throwOnChanges", moduleUrl: appViewUtilsModuleUrl);
105+
static final isDevMode = new CompileIdentifierMetadata<dynamic>(
106+
name: "isDevMode", moduleUrl: runtimeUtilsModuleUrl);
104107
static final interpolate = <CompileIdentifierMetadata>[
105108
new CompileIdentifierMetadata<dynamic>(
106109
name: "interpolate0", moduleUrl: appViewUtilsModuleUrl),

angular/lib/src/compiler/view_compiler/compile_view.dart

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,13 +1224,7 @@ class CompileView implements AppViewBuilder {
12241224
new List.from(_updateContentQueriesMethod.finish())
12251225
..addAll(afterContentLifecycleCallbacksMethod.finish());
12261226
if (afterContentStmts.isNotEmpty) {
1227-
if (genConfig.genDebugInfo) {
1228-
// Prevent query list updates when we run change detection for
1229-
// second time to check if values are stabilized.
1230-
statements.add(new o.IfStmt(notThrowOnChanges, afterContentStmts));
1231-
} else {
1232-
statements.addAll(afterContentStmts);
1233-
}
1227+
statements.add(new o.IfStmt(notThrowOnChanges, afterContentStmts));
12341228
}
12351229

12361230
// Add render properties change detectors.
@@ -1245,11 +1239,7 @@ class CompileView implements AppViewBuilder {
12451239
new List.from(_updateViewQueriesMethod.finish())
12461240
..addAll(afterViewLifecycleCallbacksMethod.finish());
12471241
if (afterViewStmts.isNotEmpty) {
1248-
if (genConfig.genDebugInfo) {
1249-
statements.add(new o.IfStmt(notThrowOnChanges, afterViewStmts));
1250-
} else {
1251-
statements.addAll(afterViewStmts);
1252-
}
1242+
statements.add(new o.IfStmt(notThrowOnChanges, afterViewStmts));
12531243
}
12541244
var varStmts = [];
12551245
var readVars = o.findReadVarNames(statements);

0 commit comments

Comments
 (0)