fix binding groups

pull/1998/head
Richard Harris 7 years ago
parent b383976098
commit b8051aaff9

@ -274,6 +274,10 @@ export default function dom(
filtered_declarations.push(...arr.map(name => `$$slot_${sanitize(name)}`), '$$scope'); filtered_declarations.push(...arr.map(name => `$$slot_${sanitize(name)}`), '$$scope');
} }
if (renderer.bindingGroups.length > 0) {
filtered_declarations.push(`$$binding_groups`);
}
const has_definition = ( const has_definition = (
component.javascript || component.javascript ||
filtered_props.length > 0 || filtered_props.length > 0 ||
@ -313,6 +317,8 @@ export default function dom(
${renderer.slots.size && `let { ${[...renderer.slots].map(name => `$$slot_${sanitize(name)}`).join(', ')}, $$scope } = $$props;`} ${renderer.slots.size && `let { ${[...renderer.slots].map(name => `$$slot_${sanitize(name)}`).join(', ')}, $$scope } = $$props;`}
${renderer.bindingGroups.length > 0 && `const $$binding_groups = [${renderer.bindingGroups.map(_ => `[]`).join(', ')}];`}
${component.partly_hoisted.length > 0 && component.partly_hoisted.join('\n\n')} ${component.partly_hoisted.length > 0 && component.partly_hoisted.join('\n\n')}
${reactive_store_subscriptions} ${reactive_store_subscriptions}

@ -124,7 +124,7 @@ export default class BindingWrapper {
const bindingGroup = getBindingGroup(parent.renderer, this.node.expression.node); const bindingGroup = getBindingGroup(parent.renderer, this.node.expression.node);
block.builders.hydrate.addLine( block.builders.hydrate.addLine(
`(ctx.$$binding_groups[${bindingGroup}] || (ctx.$$binding_groups[${bindingGroup}] = [])).push(${parent.var});` `ctx.$$binding_groups[${bindingGroup}].push(${parent.var});`
); );
block.builders.destroy.addLine( block.builders.destroy.addLine(
@ -278,7 +278,7 @@ function getValueFromDom(
if (name === 'group') { if (name === 'group') {
const bindingGroup = getBindingGroup(renderer, binding.node.expression.node); const bindingGroup = getBindingGroup(renderer, binding.node.expression.node);
if (type === 'checkbox') { if (type === 'checkbox') {
return `@getBindingGroupValue($$self.ctx.$$binding_groups[${bindingGroup}])`; return `@getBindingGroupValue($$binding_groups[${bindingGroup}])`;
} }
return `this.__value`; return `this.__value`;

@ -98,8 +98,6 @@ export function init(component, options, instance, create_fragment, not_equal) {
}) })
: props; : props;
$$.ctx.$$binding_groups = []; // TODO this is awkward and usually unncessary
$$.update(); $$.update();
ready = true; ready = true;
run_all($$.before_render); run_all($$.before_render);

Loading…
Cancel
Save