Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in style transform #4

Open
macdonst opened this issue Nov 2, 2023 · 3 comments
Open

Bug in style transform #4

macdonst opened this issue Nov 2, 2023 · 3 comments
Assignees

Comments

@macdonst
Copy link
Contributor

macdonst commented Nov 2, 2023

I found a bug in the style transform. If you do:

          todo-app {

it becomes:

          todo-app todo-app {

When it should skip adding the custom element name if it already exists.

@macdonst macdonst self-assigned this Nov 2, 2023
@ryanbethel
Copy link
Contributor

I don't think this is a bug. The SSR behavior is the same. If you want to style the element itself you can use the :host selector. Every rule gets the element name prepended unless it starts with :host.

@macdonst
Copy link
Contributor Author

macdonst commented Nov 3, 2023

@ryanbethel is right, this is the expected behaviour for style transform but the question now is, should we fix it?

@kristoferjoseph
Copy link
Contributor

kristoferjoseph commented May 16, 2024

I ran into this when I was working on the other versions of the shady styles transform.
My opinion is we should fix this since it is a way to shortcut the need of a :host transform.
We could inform users to use scope=global when wanting to use the hardcoded custom element tag selector in their styles.
Currently using the custom element tag name instead of :host in your styles is an anti-pattern as you could specify any custom element tag name when you register the class in customElements.define or the Enhance element call of enhance('my-element', {...})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants