Skip to content

Switching between multiple templates leaks css #2793

@joan-sf

Description

@joan-sf

Description

When having multiple templates with different css and switching between them, the latest one to apply is the one that ends up winning. Switching back to the first template keeps the css of the previous one.

Steps to Reproduce

  1. Generate a new project with
$ npm init lwr
$ npm install
$ npm run start
  1. Create a component with two templates, as described on the docs
  2. Add the respective route to lwr.config.json
  3. Enter the component and switch templates

Expected Results

Css is scoped to the respective html template

Actual Results

Css from different template is being applied

Browsers Affected

Chrome 100.0, Safari 15.4, Firefox 98.0.2

Version

  • LWC: 2.5.8
  • LWR: 0.6.4

Additional context/Screenshots
This happens if you select either Typescript or Javascript project template
It also happens when using the Recipes App
The only place where I couldn't reproduce the issue is on webcomponent.dev

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions