angular-cn/packages/core/test/acceptance
JoostK 9514fd9080 fix(compiler): evaluate safe navigation expressions in correct binding order (#37911)
When using the safe navigation operator in a binding expression, a temporary
variable may be used for storing the result of a side-effectful call.
For example, the following template uses a pipe and a safe property access:

```html
<app-person-view [enabled]="enabled" [firstName]="(person$ | async)?.name"></app-person-view>
```

The result of the pipe evaluation is stored in a temporary to be able to check
whether it is present. The temporary variable needs to be declared in a separate
statement and this would also cause the full expression itself to be pulled out
into a separate statement. This would compile into the following
pseudo-code instructions:

```js
var temp = null;
var firstName = (temp = pipe('async', ctx.person$)) == null ? null : temp.name;
property('enabled', ctx.enabled)('firstName', firstName);
```

Notice that the pipe evaluation happens before evaluating the `enabled` binding,
such that the runtime's internal binding index would correspond with `enabled`,
not `firstName`. This introduces a problem when the pipe uses `WrappedValue` to
force a change to be detected, as the runtime would then mark the binding slot
corresponding with `enabled` as dirty, instead of `firstName`. This results
in the `enabled` binding to be updated, triggering setters and affecting how
`OnChanges` is called.

In the pseudo-code above, the intermediate `firstName` variable is not strictly
necessary---it only improved readability a bit---and emitting it inline with
the binding itself avoids the out-of-order execution of the pipe:

```js
var temp = null;
property('enabled', ctx.enabled)
  ('firstName', (temp = pipe('async', ctx.person$)) == null ? null : temp.name);
```

This commit introduces a new `BindingForm` that results in the above code to be
generated and adds compiler and acceptance tests to verify the proper behavior.

Fixes #37194

PR Close #37911
2020-08-11 09:51:10 -07:00
..
BUILD.bazel refactor(core): add debug ranges to `LViewDebug` with matchers (#38359) 2020-08-06 16:58:11 -07:00
attributes_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
bootstrap_spec.ts fix(core): cleanup DOM elements when root view is removed (#37600) 2020-06-25 14:34:35 -07:00
change_detection_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
change_detection_transplanted_view_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
common_integration_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
component_spec.ts refactor(core): throw more descriptive error message in case of invalid host element (#35916) 2020-06-26 11:10:14 -07:00
content_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
copy_definition_feature_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
debug_spec.ts refactor(core): add debug ranges to `LViewDebug` with matchers (#38359) 2020-08-06 16:58:11 -07:00
di_spec.ts test: fix test failure in saucelabs ivy ie10 (#37892) 2020-07-08 16:03:33 -07:00
directive_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
discover_utils_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
embedded_views_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
exports_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
host_binding_spec.ts refactor(core): assert TNode is not a container when setting attribute on element (#37111) 2020-06-08 11:21:05 -07:00
i18n_spec.ts fix(core): Store the currently selected ICU in `LView` (#38345) 2020-08-10 12:41:17 -07:00
inherit_definition_feature_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
integration_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
lifecycle_spec.ts fix(core): Allow modification of lifecycle hooks any time before bootstrap (#35464) 2020-07-15 16:22:46 -07:00
listener_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
ng_module_spec.ts fix(core): incorrectly validating properties on ng-content and ng-container (#37773) 2020-07-15 12:39:39 -07:00
ngdevmode_debug_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
ngmodule_scope_spec.ts fix(core): prevent NgModule scope being overwritten in JIT compiler (#37795) 2020-08-11 09:50:27 -07:00
outputs_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
pipe_spec.ts fix(compiler): evaluate safe navigation expressions in correct binding order (#37911) 2020-08-11 09:51:10 -07:00
property_binding_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
property_interpolation_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
providers_spec.ts feat(core): update reference and doc to change `async` to `waitAsync`. (#37583) 2020-08-03 12:54:13 -07:00
pure_function_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
query_spec.ts fix(core): queries not matching string injection tokens (#38321) 2020-08-10 15:27:24 -07:00
renderer_factory_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
router_integration_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
styling_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
template_ref_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
text_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
view_container_ref_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
view_insertion_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
view_ref_spec.ts fix(core): error when invoking callbacks registered via ViewRef.onDestroy (#37543) 2020-06-26 15:02:41 -07:00