|
|
@ -197,27 +197,16 @@ export function build_component(node, component_name, context) {
|
|
|
|
push_prop(b.init(attribute.name, value));
|
|
|
|
push_prop(b.init(attribute.name, value));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (attribute.type === 'BindDirective') {
|
|
|
|
} else if (attribute.type === 'BindDirective') {
|
|
|
|
if (attribute.metadata.spread_binding) {
|
|
|
|
|
|
|
|
const { get, set } = init_spread_bindings(attribute.expression, context);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (attribute.name === 'this') {
|
|
|
|
|
|
|
|
bind_this = {
|
|
|
|
|
|
|
|
type: 'SpreadElement',
|
|
|
|
|
|
|
|
argument: attribute.expression
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
push_prop(b.get(attribute.name, [b.return(b.call(get))]), true);
|
|
|
|
|
|
|
|
push_prop(b.set(attribute.name, [b.stmt(b.call(set, b.id('$$value')))]), true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const expression = /** @type {Expression} */ (context.visit(attribute.expression));
|
|
|
|
const expression = /** @type {Expression} */ (context.visit(attribute.expression));
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
dev &&
|
|
|
|
dev &&
|
|
|
|
attribute.name !== 'this' &&
|
|
|
|
attribute.name !== 'this' &&
|
|
|
|
!is_ignored(node, 'ownership_invalid_binding') &&
|
|
|
|
!is_ignored(node, 'ownership_invalid_binding') &&
|
|
|
|
// bind:x={() => x.y, y => x.y = y} will be handled by the assignment expression binding validation
|
|
|
|
// bind:x={() => x.y, y => x.y = y} and bind:x={...[() => x.y, y => x.y = y]}
|
|
|
|
attribute.expression.type !== 'SequenceExpression'
|
|
|
|
// will be handled by the assignment expression binding validation
|
|
|
|
|
|
|
|
attribute.expression.type !== 'SequenceExpression' &&
|
|
|
|
|
|
|
|
!attribute.metadata.spread_binding
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
const left = object(attribute.expression);
|
|
|
|
const left = object(attribute.expression);
|
|
|
|
const binding = left && context.state.scope.get(left.name);
|
|
|
|
const binding = left && context.state.scope.get(left.name);
|
|
|
@ -237,7 +226,19 @@ export function build_component(node, component_name, context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (expression.type === 'SequenceExpression') {
|
|
|
|
if (attribute.metadata.spread_binding) {
|
|
|
|
|
|
|
|
const { get, set } = init_spread_bindings(attribute.expression, context);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (attribute.name === 'this') {
|
|
|
|
|
|
|
|
bind_this = {
|
|
|
|
|
|
|
|
type: 'SpreadElement',
|
|
|
|
|
|
|
|
argument: attribute.expression
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
push_prop(b.get(attribute.name, [b.return(b.call(get))]), true);
|
|
|
|
|
|
|
|
push_prop(b.set(attribute.name, [b.stmt(b.call(set, b.id('$$value')))]), true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (expression.type === 'SequenceExpression') {
|
|
|
|
if (attribute.name === 'this') {
|
|
|
|
if (attribute.name === 'this') {
|
|
|
|
bind_this = attribute.expression;
|
|
|
|
bind_this = attribute.expression;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -271,10 +272,7 @@ export function build_component(node, component_name, context) {
|
|
|
|
// Delay prop pushes so bindings come at the end, to avoid spreads overwriting them
|
|
|
|
// Delay prop pushes so bindings come at the end, to avoid spreads overwriting them
|
|
|
|
if (is_store_sub) {
|
|
|
|
if (is_store_sub) {
|
|
|
|
push_prop(
|
|
|
|
push_prop(
|
|
|
|
b.get(attribute.name, [
|
|
|
|
b.get(attribute.name, [b.stmt(b.call('$.mark_store_binding')), b.return(expression)]),
|
|
|
|
b.stmt(b.call('$.mark_store_binding')),
|
|
|
|
|
|
|
|
b.return(expression)
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
true
|
|
|
|
true
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -288,14 +286,11 @@ export function build_component(node, component_name, context) {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
push_prop(
|
|
|
|
push_prop(
|
|
|
|
b.set(attribute.name, [
|
|
|
|
b.set(attribute.name, [b.stmt(/** @type {Expression} */ (context.visit(assignment)))]),
|
|
|
|
b.stmt(/** @type {Expression} */ (context.visit(assignment)))
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
true
|
|
|
|
true
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (attribute.type === 'AttachTag') {
|
|
|
|
} else if (attribute.type === 'AttachTag') {
|
|
|
|
const evaluated = context.state.scope.evaluate(attribute.expression);
|
|
|
|
const evaluated = context.state.scope.evaluate(attribute.expression);
|
|
|
|
|
|
|
|
|
|
|
|