mirror of https://github.com/sveltejs/svelte
fix: prevent spread attribute from overriding class directive (#13763)
parent
de609ec34c
commit
b6a67e85b4
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: prevent spread attribute from overriding class directive
|
@ -0,0 +1,25 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test, ok } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ target, logs, assert }) {
|
||||
const input = target.querySelector('input');
|
||||
|
||||
ok(input);
|
||||
|
||||
assert.deepEqual(logs, ['get_rest']);
|
||||
|
||||
assert.ok(input.classList.contains('dark'));
|
||||
assert.equal(input.dataset.rest, 'true');
|
||||
|
||||
flushSync(() => {
|
||||
input.focus();
|
||||
});
|
||||
|
||||
assert.ok(input.classList.contains('dark'));
|
||||
assert.ok(input.classList.contains('focused'));
|
||||
assert.equal(input.dataset.rest, 'true');
|
||||
|
||||
assert.deepEqual(logs, ['get_rest']);
|
||||
}
|
||||
});
|
@ -0,0 +1,19 @@
|
||||
<script>
|
||||
let focused = $state(false)
|
||||
|
||||
function get_rest() {
|
||||
console.log("get_rest");
|
||||
return {
|
||||
"data-rest": "true"
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<input
|
||||
onfocus={() => focused = true}
|
||||
onblur={() => focused = false}
|
||||
class:dark={true}
|
||||
class={`${focused ? 'focused' : ''}`}
|
||||
{...get_rest()}
|
||||
>
|
Loading…
Reference in new issue