test: add runtime-browser regression test for style directive trailing semicolon

pull/18200/head
OfirHaf 4 months ago
parent 5d8fa9df7a
commit 41550a5115

@ -0,0 +1,21 @@
import { assert_ok, test } from '../../assert';
export default test({
html: `<div style="color: red;"></div>`,
test({ assert, target, window, component }) {
const div = target.querySelector('div');
assert_ok(div);
// Initial value with trailing semicolon — should produce valid CSS
assert.equal(window.getComputedStyle(div).color, 'rgb(255, 0, 0)');
// Update to a new value that also has a trailing semicolon
component.color = 'blue;';
assert.equal(window.getComputedStyle(div).color, 'rgb(0, 0, 255)');
// Update to a value without trailing semicolon — should still work
component.color = 'green';
assert.equal(window.getComputedStyle(div).color, 'rgb(0, 128, 0)');
}
});

@ -0,0 +1,5 @@
<script lang="ts">
export let color = 'red;';
</script>
<div style:color={color}></div>
Loading…
Cancel
Save