pull/3945/head
Rich Harris 6 years ago
parent 0f7a42d92a
commit ec2704412a

@ -34,6 +34,11 @@ export default class Renderer {
.filter(v => ((v.referenced || v.export_name) && !v.hoistable))
.forEach(v => this.add_to_context(v.name));
// ensure store values are included in context
component.vars
.filter(v => v.subscribable)
.forEach(v => this.add_to_context(`$${v.name}`));
if (component.var_lookup.has('$$props')) {
this.add_to_context('$$props');
}
@ -145,11 +150,11 @@ export default class Renderer {
}, 0);
}
changed(names, needs_update = false) {
changed(names, is_reactive_declaration = false) {
const bitmask = this.get_bitmask(names);
return needs_update
? x`(#changed = $$self.$$.dirty) & ${bitmask}`
return is_reactive_declaration
? x`$$self.$$.dirty & ${bitmask}`
: x`#changed & ${bitmask}`;
}

@ -391,7 +391,7 @@ export default function dom(
${injected.map(name => b`let ${name};`)}
${reactive_declarations.length > 0 && b`
$$self.$$.update = #changed => {
$$self.$$.update = () => {
${reactive_declarations}
};
`}
@ -406,7 +406,7 @@ export default function dom(
}
const prop_indexes = x`{
${props.map(v => p`${v.export_name}: ${renderer.context_lookup.get(v.name)}`)}
${props.filter(v => !v.hoistable).map(v => p`${v.export_name}: ${renderer.context_lookup.get(v.name)}`)}
}` as ObjectExpression;
if (options.customElement) {

@ -24,7 +24,7 @@ interface T$$ {
dirty: number;
ctx: null|any;
bound: any;
update: (n: number) => number;
update: () => void;
callbacks: any;
after_update: any[];
props: Record<string, 0 | string>;
@ -108,7 +108,7 @@ export function init(component, options, instance, create_fragment, not_equal, p
// state
props,
update: (noop as unknown as (n: number) => number),
update: noop,
not_equal,
bound: blank_object(),
@ -136,7 +136,7 @@ export function init(component, options, instance, create_fragment, not_equal, p
})
: prop_values;
$$.update(-1);
$$.update();
ready = true;
run_all($$.before_update);

@ -71,7 +71,7 @@ export function flush() {
function update($$) {
if ($$.fragment !== null) {
$$.update($$.dirty);
$$.update();
run_all($$.before_update);
$$.fragment && $$.fragment.p($$.ctx, $$.dirty);
$$.dirty = -1;

Loading…
Cancel
Save