add test of multiple styles; remove null styles;

pull/5923/head
pmurray73 6 years ago committed by Tan Li Hau
parent 3c1591cace
commit 4969b6c6a4

@ -430,7 +430,11 @@ export function set_input_type(input, type) {
}
export function set_style(node, key, value, important) {
node.style.setProperty(key, value, important ? 'important' : '');
if (value === null) {
node.style.removeProperty(key);
} else {
node.style.setProperty(key, value, important ? 'important' : '');
}
}
export function select_option(select, value) {

@ -0,0 +1,16 @@
export default {
html: `
<p style="color: red; width: 65px; font-weight: 700;"></p>
`,
test({ assert, component, target, window }) {
const p = target.querySelector('p');
const styles = window.getComputedStyle(p);
assert.equal(styles.color, 'red');
},
skip_if_ssr: true
// SSR renders "null" string for null values:
// <p style="color: red; width: 65px; position: null; font-weight: 700;"></p>
};

@ -0,0 +1,13 @@
<script>
export let myColor = "red";
export let width = "65px";
export let absolute = false;
export let bold = true;
</script>
<p
style:color={myColor}
style:width
style:position={absolute ? "absolute" : null}
style:font-weight={bold ? 700 : 100}
/>
Loading…
Cancel
Save