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

Use classes instead of attributes for scoping #1118

Closed
Rich-Harris opened this issue Jan 19, 2018 · 3 comments
Closed

Use classes instead of attributes for scoping #1118

Rich-Harris opened this issue Jan 19, 2018 · 3 comments
Labels

Comments

@Rich-Harris
Copy link
Member

Classes are always faster than attributes. We should consider using them:

<!-- this... -->
<div class='svelte-xyz123'>...</div>
<div class='svelte-xyz123 foo'>...</div>

<!-- ...instead of this: -->
<div svelte-xyz123>...</div>
<div svelte-xyz123 class='foo'>...</div>

It will complicate <div class='{{whatever}}'> slightly, because we'd now need to include the scoping string in the className that it gets updated with.

@constgen
Copy link

Attributes are main reason why I don't use scoped styles in Svelte. Classes really should be used for this.

@PaulBGD
Copy link
Member

PaulBGD commented Jan 22, 2018

If we did something like #890 and deprecated passing a string (maybe allowing passing an array?) we could in a non-backwards compatibility way have no issue with making this change.

Rich-Harris added a commit that referenced this issue Mar 8, 2018
Rich-Harris added a commit that referenced this issue Mar 8, 2018
Rich-Harris added a commit that referenced this issue Mar 8, 2018
Use classes for style encapsulation, rather than attributes
@Rich-Harris
Copy link
Member Author

This is implemented in 1.57

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

No branches or pull requests

4 participants