pull/9801/head
Rich Harris 3 years ago
parent 9f1d1e73ba
commit 22811ac64b

@ -2777,8 +2777,8 @@ export const template_visitors = {
} }
}, },
LetDirective(node, { state }) { LetDirective(node, { state }) {
// let:x --> const x = $.derived(() => $.unwrap($$slotProps).x); // let:x --> const x = $.derived(() => $$slotProps.x);
// let:x={{y, z}} --> const derived_x = $.derived(() => { const { y, z } = $.unwrap($$slotProps).x; return { y, z })); // let:x={{y, z}} --> const derived_x = $.derived(() => { const { y, z } = $$slotProps.x; return { y, z }));
if (node.expression && node.expression.type !== 'Identifier') { if (node.expression && node.expression.type !== 'Identifier') {
const name = state.scope.generate(node.name); const name = state.scope.generate(node.name);
const bindings = state.scope.get_bindings(node); const bindings = state.scope.get_bindings(node);
@ -2800,7 +2800,7 @@ export const template_visitors = {
b.object_pattern(node.expression.properties) b.object_pattern(node.expression.properties)
: // @ts-expect-error types don't match, but it can't contain spread elements and the structure is otherwise fine : // @ts-expect-error types don't match, but it can't contain spread elements and the structure is otherwise fine
b.array_pattern(node.expression.elements), b.array_pattern(node.expression.elements),
b.member(b.call('$.unwrap', b.id('$$slotProps')), b.id(node.name)) b.member(b.id('$$slotProps'), b.id(node.name))
), ),
b.return(b.object(bindings.map((binding) => b.init(binding.node.name, binding.node)))) b.return(b.object(bindings.map((binding) => b.init(binding.node.name, binding.node))))
]) ])
@ -2811,10 +2811,7 @@ export const template_visitors = {
const name = node.expression === null ? node.name : node.expression.name; const name = node.expression === null ? node.name : node.expression.name;
return b.const( return b.const(
name, name,
b.call( b.call('$.derived', b.thunk(b.member(b.id('$$slotProps'), b.id(node.name))))
'$.derived',
b.thunk(b.member(b.call('$.unwrap', b.id('$$slotProps')), b.id(node.name)))
)
); );
} }
}, },

@ -29,7 +29,6 @@ import {
push_destroy_fn, push_destroy_fn,
execute_effect, execute_effect,
UNINITIALIZED, UNINITIALIZED,
derived,
untrack, untrack,
effect, effect,
flushSync, flushSync,
@ -38,8 +37,7 @@ import {
managed_effect, managed_effect,
push, push,
current_component_context, current_component_context,
pop, pop
unwrap
} from './runtime.js'; } from './runtime.js';
import { import {
current_hydration_fragment, current_hydration_fragment,
@ -58,7 +56,7 @@ import {
} from './utils.js'; } from './utils.js';
import { is_promise } from '../common.js'; import { is_promise } from '../common.js';
import { bind_transition, trigger_transitions } from './transitions.js'; import { bind_transition, trigger_transitions } from './transitions.js';
import { observe, proxy } from './proxy/proxy.js'; import { proxy } from './proxy/proxy.js';
/** @type {Set<string>} */ /** @type {Set<string>} */
const all_registerd_events = new Set(); const all_registerd_events = new Set();

Loading…
Cancel
Save