Skip to content

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

Closed

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

Activity

  1. added
    area: server
    on Feb 28, 2020
  2. added this to the needsTriage milestone on Feb 28, 2020
  3. petebacondarwin commented on Oct 19, 2020

    @petebacondarwin
    Contributor

    I cannot reproduce this with an app created from the latest Angular...

    Angular CLI: 10.1.7
    Node: 12.13.0
    OS: darwin x64
    
    Angular: 10.1.6
    ... animations, common, compiler, compiler-cli, core, forms
    ... platform-browser, platform-browser-dynamic, platform-server
    ... router
    Ivy Workspace: Yes
    
    Package                         Version
    ---------------------------------------------------------
    @angular-devkit/architect       0.1001.7
    @angular-devkit/build-angular   0.1001.7
    @angular-devkit/core            10.1.7
    @angular-devkit/schematics      10.1.7
    @angular/cli                    10.1.7
    @nguniversal/builders           10.1.0
    @nguniversal/express-engine     10.1.0
    @schematics/angular             10.1.7
    @schematics/update              0.1001.7
    rxjs                            6.6.3
    typescript                      4.0.3
    

    When I set the value to null then no style is attached to the <div>:

    <app-root _nghost-sc11="" ng-version="10.1.6" _nghost-serverapp-c11="">
      <div _ngcontent-serverapp-c11="">text</div>
    </app-root>
  4. petebacondarwin commented on Oct 19, 2020

    @petebacondarwin
    Contributor

    I believe it was fixed by this change: 9bd9590#diff-fe6768f58e32d9fdc70a4aedceefdc19d4d7394ac3a6996e32b9590c508fe6c7R279 which first appears in 9.1.0.

  5. angular-automatic-lock-bot commented on Nov 19, 2020

    @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.

  6. locked and limited conversation to collaborators on Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: server

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions