mirror of https://github.com/sveltejs/svelte
fix: detect style shorthands as stateful variables in legacy mode (#11421)
Fixes #11417pull/11432/head
parent
0f4f3d7df0
commit
f64d16931d
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: detect style shorthands as stateful variables in legacy mode
|
@ -0,0 +1,33 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `
|
||||
<p style="color: red;"></p>
|
||||
<p style="color: red;"></p>
|
||||
<button></button>
|
||||
`,
|
||||
|
||||
async test({ assert, target, window }) {
|
||||
const [p1, p2] = target.querySelectorAll('p');
|
||||
|
||||
assert.equal(window.getComputedStyle(p1).color, 'red');
|
||||
assert.equal(window.getComputedStyle(p2).color, 'red');
|
||||
|
||||
const btn = target.querySelector('button');
|
||||
console.log(btn);
|
||||
btn?.click();
|
||||
await Promise.resolve();
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<p style="color: green;"></p>
|
||||
<p style="color: green;"></p>
|
||||
<button></button>
|
||||
`
|
||||
);
|
||||
|
||||
assert.equal(window.getComputedStyle(p1).color, 'green');
|
||||
assert.equal(window.getComputedStyle(p2).color, 'green');
|
||||
}
|
||||
});
|
@ -0,0 +1,15 @@
|
||||
<script>
|
||||
let color = "red";
|
||||
|
||||
function change(){
|
||||
color = "green";
|
||||
}
|
||||
</script>
|
||||
|
||||
<p style:color></p>
|
||||
|
||||
{#each [1] as _}
|
||||
<p style:color></p>
|
||||
{/each}
|
||||
|
||||
<button on:click={change}></button>
|
Loading…
Reference in new issue