Skip to content

Empty style tag when one or more components don't have styles #31191

Closed

Description

@borjapazr

Empty style tag when one or more components don't have styles

Affected Package

The issue is caused by package @angular/angular

Is this a regression?

This happens in all versions of Angular

Description

When several components are added to a template and one or more of them do not have defined styles, an empty style tag appears in the header.
The desired result would be that this empty label was not added.

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-jpfxql
https://angular-jpfxql.stackblitz.io

In the second URL, if we inspect the page we can see an empty style tag in the header corresponding to app.component.css

🌍 Your Environment

Angular Version:
Angular CLI: 8.0.3
Node: 10.15.0
OS: win32 x64
Angular:
...

Package Version

@angular-devkit/architect 0.800.3
@angular-devkit/core 8.0.3
@angular-devkit/schematics 8.0.3
@schematics/angular 8.0.3
@schematics/update 0.800.3
rxjs 6.4.0

Activity

  1. added
    area: core
    on Jun 21, 2019
  2. added this to the needsTriage milestone on Jun 21, 2019
  3. modified the milestones: needsTriage, Backlog on Jul 2, 2019
  4. modified the milestones: Backlog, needsTriage on Jul 2, 2019
  5. modified the milestones: needsTriage, Backlog on Jul 2, 2019
  6. MrNocTV commented on May 12, 2020

    @MrNocTV

    I'm having problem with this, please fix it. Our project using CSP to prevent inline style so having an empty <style> tag in <head> will cause browser to spit out annoying CSP error logs. I also have one question for this on stackoverflow in hope for getting a workaround but it seems to be impossible for the moment.

    However, I've managed to upgrade to Angular 9 and I'm not sure if this is fixed in Angular 9 or not (it seems to be) but the empty <style> tags are gone.

  7. 14 remaining items

  8. angular-automatic-lock-bot commented on Jun 3, 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.

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

Metadata

Metadata

Assignees

Labels

P4area: corecore: stylesheetscross-cutting: CSPfreq1: lowstate: has PRtype: bug/fix

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions