You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.
The syntax we're using is style:propery-name={propertyValue}. It is similar to what svelte provides for class toggle class:class-name={boolValue}. The value in class toggle syntax must be a boolean, whereas for svelte-style-directive it may be something other than a boolean.
The preprocessor de-sugars the the syntax using svelte's attribute value interpolation. Which gets expensive specifically when we interpolate style attribute (among others, like innerHtml). As it requires the browser to perform many steps from parsing the CSS to re-rendering the element, every time we interpolate the inline CSS. On contrary, the class toggle syntax svelte provides, uses cheaper Element.classList.toggle (or in newer versions of svelte, add and remove, thanks to IE11) method calls.
I concur that the preprocessor has no runtime performance impact, as stated, it just provides a syntactic sugar. But users might be unaware of how the underlying implementation, i.e. style attribute value interpolation, may have performance impact (*when used incorrectly). It'd be great if we can document this. Or you can correct me if I am wrong somewhere.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The syntax we're using is
style:propery-name={propertyValue}
. It is similar to what svelte provides for class toggleclass:class-name={boolValue}
. Thevalue
in class toggle syntax must be aboolean
, whereas forsvelte-style-directive
it may be something other than a boolean.The preprocessor de-sugars the the syntax using svelte's attribute value interpolation. Which gets expensive specifically when we interpolate
style
attribute (among others, likeinnerHtml
). As it requires the browser to perform many steps from parsing the CSS to re-rendering the element, every time we interpolate the inline CSS. On contrary, the class toggle syntax svelte provides, uses cheaperElement.classList.toggle
(or in newer versions of svelte,add
andremove
, thanks to IE11) method calls.I concur that the preprocessor has no runtime performance impact, as stated, it just provides a syntactic sugar. But users might be unaware of how the underlying implementation, i.e.
style
attribute value interpolation, may have performance impact (*when used incorrectly). It'd be great if we can document this. Or you can correct me if I am wrong somewhere.The text was updated successfully, but these errors were encountered: