Skip to content

Commit 6895d88

Browse files
committed
use style.cssText + adapt test
1 parent d43d14a commit 6895d88

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

packages/svelte/src/internal/client/dom/elements/style.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ export function set_style(dom, value, prev_styles, next_styles) {
3535
if (next_style_attr == null) {
3636
dom.removeAttribute('style');
3737
} else {
38-
// TODO : dom.style.cssText = next_style_attr;
39-
dom.setAttribute('style', next_style_attr);
38+
dom.style.cssText = next_style_attr;
4039
}
4140
}
4241
// @ts-expect-error

packages/svelte/tests/runtime-legacy/samples/inline-style-optimisation-bailout/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ok, test } from '../../test';
22

33
export default test({
44
html: `
5-
<p style="opacity: 0.5; color: red">color: red</p>
5+
<p style="opacity: 0.5; color: red;">color: red;</p>
66
`,
77

88
test({ assert, component, target, window }) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
export let styles = `color: red`;
2+
export let styles = `color: red;`;
33
</script>
44

55
<p style="opacity: 0.5; {styles}">{styles}</p>

packages/svelte/tests/runtime-runes/samples/dynamic-style-attr/_config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { test } from '../../test';
22
import { flushSync } from 'svelte';
33

44
export default test({
5-
html: `<div style="background-color: red">Hello world</div><button>Make blue</button`,
5+
html: `<div style="background-color: red;">Hello world</div><button>Make blue</button`,
66

77
async test({ assert, target, component }) {
88
const [b1] = target.querySelectorAll('button');
@@ -11,7 +11,7 @@ export default test({
1111
});
1212
assert.htmlEqual(
1313
target.innerHTML,
14-
`<div style="background-color: blue">Hello world</div><button>Make blue</button`
14+
`<div style="background-color: blue;">Hello world</div><button>Make blue</button`
1515
);
1616
}
1717
});

packages/svelte/tests/runtime-runes/samples/dynamic-style-attr/main.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
const getColor = () => color;
55
</script>
66

7-
<div style="background-color: {getColor()}">Hello world</div>
7+
<div style="background-color: {getColor()};">Hello world</div>
88

99
<button onclick={() => color = 'blue'}>Make blue</button>

0 commit comments

Comments
 (0)