fix(core): correctly concatenate static and dynamic binding to class
when shadowed (#35350)
Given: ``` <div class="s1" [class]="null" [ngClass]="exp"> ``` Notice that `[class]` binding is not a `string`. As a result the existing logic would not concatenate `[class]` with `class="s1"`. The resulting falsy value would than be sent to `ngClass` which would promptly clear all styles on the `<div>` The new logic correctly handles falsy values for `[class]` bindings. Fix #35335 PR Close #35350
This commit is contained in:

committed by
Alex Rickabaugh

parent
be5e75c804
commit
8c75f2155d
@ -261,8 +261,9 @@ export function checkStylingMap(
|
||||
ngDevMode && isClassBased === false && staticPrefix !== null &&
|
||||
assertEqual(
|
||||
staticPrefix.endsWith(';'), true, 'Expecting static portion to end with \';\'');
|
||||
if (typeof value === 'string') {
|
||||
value = concatStringsWithSpace(staticPrefix, value as string);
|
||||
if (staticPrefix !== null) {
|
||||
// We want to make sure that falsy values of `value` become empty strings.
|
||||
value = concatStringsWithSpace(staticPrefix, value ? value : '');
|
||||
}
|
||||
// Given `<div [style] my-dir>` such that `my-dir` has `@Input('style')`.
|
||||
// This takes over the `[style]` binding. (Same for `[class]`)
|
||||
|
Reference in New Issue
Block a user