Skip to content

SSR style property binding with null or undefined results invalid/empty style property #46385

Closed

Description

@ruvkr

Which @angular/* package(s) are the source of the bug?

platform-server

Is this a regression?

No

Description

Style property bindings with null or undefined are skiped in Angular but not when using ssr.

Template

<h1 [style.color]="null" [style.--bg-color]="undefined">{{ title }}</h1>

Result: Angular

<h1 _ngcontent-serverapp-c16="">ssr-style-binding-test</h1>

Result: SSR

<h1 _ngcontent-sc16="" style="color:;--bg-color:;">ssr-style-binding-test</h1>

Empty style properties are invalid and custom properties are overriding default values.

Please provide a link to a minimal reproduction of the bug

https://github.com/ruvkr/ssr-style-binding-test.git

  1. ng new ssr-style-binding-test (router:Yes, style:SCSS)
  2. ng add @nguniversal/express-engine
  3. Add <h1 [style.color]="null" [style.--bg-color]="undefined">{{ title }}</h1> to app.component.html
  4. Add h1 { --bg-color: skyblue; color: red; background-color: var(--bg-color); } to app.component.scss
  5. npm run dev:ssr

Please provide the exception or error you saw

No exceptions

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 14.0.2
Node: 16.15.1
Package Manager: npm 8.12.2 
OS: linux x64

Angular: 14.0.2
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1400.2
@angular-devkit/build-angular   14.0.2
@angular-devkit/core            14.0.2
@angular-devkit/schematics      14.0.2
@nguniversal/builders           14.0.1
@nguniversal/express-engine     14.0.1
@schematics/angular             14.0.2
rxjs                            7.5.5
typescript                      4.7.3

Anything else?

I saw #35735 (comment). But it was closed.

Activity

  1. added
    area: server
    on Jun 16, 2022
  2. added this to the needsTriage milestone on Jun 16, 2022
  3. self-assigned this
    on Jun 20, 2022
  4. added a commit that references this issue on Jun 20, 2022
    a1e294c
  5. added a commit that references this issue on Jun 21, 2022
    6ad7b40
  6. angular-automatic-lock-bot commented on Jul 22, 2022

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  7. locked and limited conversation to collaborators on Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: serverstate: has PR

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions