2019-09-26 06:40:58 +02:00
|
|
|
// https://github.com/kaisermann/svelte-css-vars
|
|
|
|
|
|
|
|
export default (node, props) => {
|
2020-02-03 10:24:25 +01:00
|
|
|
Object.entries(props).forEach(([key, value]) => {
|
|
|
|
node.style.setProperty(`--${key}`, value)
|
|
|
|
})
|
|
|
|
|
|
|
|
return {
|
|
|
|
update(new_props) {
|
|
|
|
Object.entries(new_props).forEach(([key, value]) => {
|
|
|
|
node.style.setProperty(`--${key}`, value)
|
|
|
|
delete props[key]
|
|
|
|
})
|
|
|
|
|
|
|
|
Object.keys(props).forEach(name => node.style.removeProperty(`--${name}`))
|
|
|
|
props = new_props
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|