Svelte: inline !important styles don't get added

Created on 2 Nov 2018  Â·  3Comments  Â·  Source: sveltejs/svelte

I'm using svelte 2.15.0

if my template has inline !important styles like

<div style="margin:10px !important"></div>

the compiler will create setStyle(node, 'margin', '10px !important')

which in the end executes node.style.setProperty('margin', '10px !important')

This fails silently and margin attribute doesn't get added, because setProperty expects !important attributes to be added with a flag like this: node.style.setProperty('margin', '10px', 'important')

bug

Most helpful comment

Finally fixed, in 3.9.1 — thanks

All 3 comments

Inline styles don't need !important, since they already override every other css definition for that specific element 🤔

True, apart from if you were trying to use !important to override !important. Probably a sign something's amiss though of you're doing that.

Finally fixed, in 3.9.1 — thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Rich-Harris picture Rich-Harris  Â·  3Comments

davidcallanan picture davidcallanan  Â·  3Comments

mmjmanders picture mmjmanders  Â·  3Comments

rob-balfre picture rob-balfre  Â·  3Comments

st-schneider picture st-schneider  Â·  3Comments