Skip to content

Commit d201fc2

Browse files
alan-agius4atscott
authored andcommitted
fix(core): set style property value to empty string instead of an invalid value (#49460)
Currently when the value of a styling property that has a unit is empty string a invalid value is generated. Example: `[style.width.px] = ""` will generate a value of `"px"`, when instead it should be `""`. This causes browser to reset the value to an empty string. This is however not the case in Domino with changes in angular/domino@bfc9114. This commit fixes the issues and generate correct values. PR Close #49460
1 parent 6d6fc12 commit d201fc2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/core/src/render3/instructions/styling.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,11 @@ function isStylingValuePresent(value: any): boolean {
833833
* @param suffix
834834
*/
835835
function normalizeSuffix(value: any, suffix: string|undefined|null): string|null|undefined|boolean {
836-
if (value == null /** || value === undefined */) {
836+
if (value == null || value === '') {
837837
// do nothing
838+
// Do not add the suffix if the value is going to be empty.
839+
// As it produce invalid CSS, which the browsers will automatically omit but Domino will not.
840+
// Example: `"left": "px;"` instead of `"left": ""`.
838841
} else if (typeof suffix === 'string') {
839842
value = value + suffix;
840843
} else if (typeof value === 'object') {

0 commit comments

Comments
 (0)