pull/15045/head
Rich Harris 9 months ago
parent b29e1e3a6f
commit 2329284d92

@ -74,7 +74,8 @@ export function visit_component(node, context) {
attribute.type !== 'SpreadAttribute' &&
attribute.type !== 'LetDirective' &&
attribute.type !== 'OnDirective' &&
attribute.type !== 'BindDirective'
attribute.type !== 'BindDirective' &&
attribute.type !== 'UseTag'
) {
e.component_invalid_directive(attribute);
}

@ -252,6 +252,15 @@ export function build_component(node, component_name, context, anchor = context.
);
}
}
} else if (attribute.type === 'UseTag') {
push_prop(
b.prop(
'init',
b.call('Symbol', b.literal('@use')),
b.thunk(/** @type {Expression} */ (context.visit(attribute.expression))),
true
)
);
}
}

@ -13,6 +13,7 @@ import {
set_active_effect,
set_active_reaction
} from '../../runtime.js';
import { attach } from './attachments.js';
/**
* The value/checked attribute in the template actually corresponds to the defaultValue property, so we need
@ -407,6 +408,10 @@ export function set_attributes(
}
}
for (let symbol of Object.getOwnPropertySymbols(next)) {
attach(element, next[symbol]);
}
return current;
}

@ -0,0 +1,5 @@
<script>
let props = $props();
</script>
<div {...props}></div>

@ -0,0 +1,6 @@
import { test } from '../../test';
export default test({
ssrHtml: `<div></div>`,
html: `<div>set from component</div>`
});

@ -0,0 +1,5 @@
<script>
import Child from './Child.svelte';
</script>
<Child {@use (node) => node.textContent = 'set from component'} />

@ -0,0 +1,14 @@
import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
ssrHtml: `<div></div><button>increment</button>`,
html: `<div>1</div><button>increment</button>`,
test: ({ assert, target }) => {
const btn = target.querySelector('button');
flushSync(() => btn?.click());
assert.htmlEqual(target.innerHTML, `<div>2</div><button>increment</button>`);
}
});

@ -0,0 +1,6 @@
<script>
let value = $state(1);
</script>
<div {@use (node) => node.textContent = value}></div>
<button onclick={() => value += 1}>increment</button>

@ -0,0 +1,6 @@
import { test } from '../../test';
export default test({
ssrHtml: `<div></div>`,
html: `<div>DIV</div>`
});

@ -0,0 +1 @@
<svelte:element this={'div'} {@use (node) => node.textContent = node.nodeName}></svelte:element>
Loading…
Cancel
Save