Skip to content

Binding a null value to a style property results in parsing errors only with Universal #35735

@chris13524

Description

@chris13524

🐞 bug report

Affected Package

I assume either @angular/platform-server or Universal.

Is this a regression?

idk

Description

When using [style.color]="null", normal Angular will render that properly. That is, it will result in no style value at all. However, when using server-side rendering, it will result in style="color:;" which results in parsing errors.

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-issue-repro2-xtqjfk

Create a new Angular app. Add Universal to it. In a template, add this: <div [style.color]="null">text</div>. Start the Universal server (npm run dev:ssr). Run curl localhost:4200, see that the result is this: <div style="color:;">text</div>. However, if you run it in the browser the result will be just <div>text</div>.

The second (no style attribute) is the correct behavior and the server-side rendered version should mirror that. Not serve an empty color:; value.

🔥 Exception or Error


Error in parsing value for ‘color’.  Declaration dropped.

🌍 Your Environment

Angular Version:


Angular CLI: 9.0.3
Node: 12.3.1
OS: linux x64

Angular: 9.0.4
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.3
@angular-devkit/build-angular     0.900.3
@angular-devkit/build-optimizer   0.900.3
@angular-devkit/build-webpack     0.900.3
@angular-devkit/core              9.0.3
@angular-devkit/schematics        9.0.3
@angular/cli                      9.0.3
@ngtools/webpack                  9.0.3
@nguniversal/builders             9.0.1
@nguniversal/common               9.0.1
@nguniversal/express-engine       9.0.1
@schematics/angular               9.0.3
@schematics/update                0.900.3
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: serverIssues related to server-side rendering

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions