mirror of https://github.com/sveltejs/svelte
fix: ensure StyleDirective and ClassDirective are marked as dynamic (#13205)
If we don't, the corresponding runtime code would never be created if in a static sub tree. Fixes #13193pull/13217/head
parent
0b25e2be0e
commit
a7a477804e
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: ensure StyleDirective and ClassDirective are marked as dynamic
|
@ -1,10 +1,13 @@
|
|||||||
/** @import { AST } from '#compiler' */
|
/** @import { AST } from '#compiler' */
|
||||||
/** @import { Context } from '../types' */
|
/** @import { Context } from '../types' */
|
||||||
|
|
||||||
|
import { mark_subtree_dynamic } from './shared/fragment.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {AST.ClassDirective} node
|
* @param {AST.ClassDirective} node
|
||||||
* @param {Context} context
|
* @param {Context} context
|
||||||
*/
|
*/
|
||||||
export function ClassDirective(node, context) {
|
export function ClassDirective(node, context) {
|
||||||
|
mark_subtree_dynamic(context.path);
|
||||||
context.next({ ...context.state, expression: node.metadata.expression });
|
context.next({ ...context.state, expression: node.metadata.expression });
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `<div><p class="foo" style="color: red;">This text should be red with a class of foo</p></div>`,
|
||||||
|
|
||||||
|
async test({ assert, target }) {
|
||||||
|
const p = target.querySelector('p');
|
||||||
|
|
||||||
|
assert.equal(p?.className, `foo`);
|
||||||
|
assert.equal(p?.style.color, `red`);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,3 @@
|
|||||||
|
<div>
|
||||||
|
<p style:color="red" class:foo={true}>This text should be red with a class of foo</p>
|
||||||
|
</div>
|
Loading…
Reference in new issue