-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): generate proper code for nullish coalescing in styling…
… host bindings (#53305) This commit fixes an issue where having an expression with nullish coalescing in styling host bindings leads to JS errors due to the fact that a declaration for a temporary variable was not included into the generated code. Resolves #53295. PR Close #53305
- Loading branch information
1 parent
13ade13
commit a2e5f48
Showing
8 changed files
with
165 additions
and
11 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
...liance/test_cases/r3_view_compiler/nullish_coalescing/nullish_coalescing_host_bindings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
hostBindings: function MyApp_HostBindings(rf, ctx) { | ||
if (rf & 1) { | ||
i0.ɵɵlistener("click", function MyApp_click_HostBindingHandler() { | ||
let $tmp$; | ||
return ctx.logLastName(($tmp$ = ($tmp$ = ctx.lastName) !== null && $tmp$ !== undefined ? $tmp$ : ctx.lastNameFallback) !== null && $tmp$ !== undefined ? $tmp$ : "unknown"); | ||
let $tmp_0$; | ||
return ctx.logLastName(($tmp_0$ = ($tmp_0$ = ctx.lastName) !== null && $tmp_0$ !== undefined ? $tmp_0$ : ctx.lastNameFallback) !== null && $tmp_0$ !== undefined ? $tmp_0$ : "unknown"); | ||
}); | ||
} | ||
if (rf & 2) { | ||
let $tmp$; | ||
i0.ɵɵattribute("first-name", "Hello, " + (($tmp$ = ctx.firstName) !== null && $tmp$ !== undefined ? $tmp$ : "Frodo") + "!"); | ||
let $tmp_1$; | ||
i0.ɵɵattribute("first-name", "Hello, " + (($tmp_1$ = ctx.firstName) !== null && $tmp_1$ !== undefined ? $tmp_1$ : "Frodo") + "!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...est_cases/r3_view_compiler_bindings/host_bindings/host_class_bindings_with_temporaries.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
hostBindings: function HostBindingDir_HostBindings(rf, ctx) { | ||
if (rf & 2) { | ||
let $tmp_0$; | ||
let $tmp_1$; | ||
$r3$.ɵɵclassProp("a", ($tmp_0$ = ctx.value) !== null && $tmp_0$ !== undefined ? $tmp_0$ : "class-a") | ||
("b", ($tmp_1$ = ctx.value) !== null && $tmp_1$ !== undefined ? $tmp_1$ : "class-b"); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...est_cases/r3_view_compiler_bindings/host_bindings/host_class_bindings_with_temporaries.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {Directive} from '@angular/core'; | ||
|
||
@Directive({ | ||
standalone: true, | ||
selector: '[hostBindingDir]', | ||
host: { | ||
'[class.a]': 'value ?? "class-a"', | ||
'[class.b]': 'value ?? "class-b"', | ||
}, | ||
}) | ||
export class HostBindingDir { | ||
value: number|null = null; | ||
} |
8 changes: 8 additions & 0 deletions
8
...est_cases/r3_view_compiler_bindings/host_bindings/host_style_bindings_with_temporaries.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
hostBindings: function HostBindingDir_HostBindings(rf, ctx) { | ||
if (rf & 2) { | ||
let $tmp_0$; | ||
let $tmp_1$; | ||
$r3$.ɵɵstyleProp("font-size", ($tmp_0$ = ctx.value) !== null && $tmp_0$ !== undefined ? $tmp_0$ : "15px") | ||
("font-weight", ($tmp_1$ = ctx.value) !== null && $tmp_1$ !== undefined ? $tmp_1$ : "bold"); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...est_cases/r3_view_compiler_bindings/host_bindings/host_style_bindings_with_temporaries.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {Directive} from '@angular/core'; | ||
|
||
@Directive({ | ||
standalone: true, | ||
selector: '[hostBindingDir]', | ||
host: { | ||
'[style.fontSize]': 'value ?? "15px"', | ||
'[style.fontWeight]': 'value ?? "bold"', | ||
}, | ||
}) | ||
export class HostBindingDir { | ||
value: number|null = null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters