Skip to content

Fix handling of style scoping and class: with spread scopes #3792

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

Merged
merged 4 commits into from
Oct 25, 2019

Conversation

Conduitry
Copy link
Member

Fixed #3790 (which also fixes #2721 in a better way than I mentioned on that ticket).

In DOM mode for elements that need the scoping class and have spread attributes, this adds toggle_class(node, "svelte-xyz", true); calls to the hydrate and update blocks, rather than trying to add or update a class= attribute in the element's AST. This prevents the scoping class and the spread class from clobbering one another.

In SSR mode for elements that need the scoping class and/or have class: directives and have spread attributes, this combines the scoping class and/or the class: directives into a string of classes that need to be added to the element after all of the spreading. This string is passed as a new second argument to spread(), which uses it to update or set the class attribute it's been given. This prevents multiple class= attributes from being emitted by the code.

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

Successfully merging this pull request may close these issues.

Spread and scoping class problems Style scoping breaks spread with "class" attribute
1 participant