pull/4923/head
pushkine 5 years ago
parent 2b6e4dc963
commit c2a701fece

@ -77,10 +77,8 @@ export default function dom(
const props = component.vars.filter(variable => !variable.module && variable.export_name); const props = component.vars.filter(variable => !variable.module && variable.export_name);
const writable_props = props.filter(variable => variable.writable); const writable_props = props.filter(variable => variable.writable);
const omit_props_names = component.get_unique_name('omit_props_names');
const rest = uses_rest ? b` const rest = uses_rest ? b`
const ${omit_props_names.name} = [${props.map(prop => `"${prop.export_name}"`)}]; const #keys = new Set([${props.map(prop => `"${prop.export_name}"`).join()}]);
const $$restProps = {}; const $$restProps = {};
for (#k in $$props) { for (#k in $$props) {
if (!#keys.has(#k) && #k[0] !== '$') { if (!#keys.has(#k) && #k[0] !== '$') {
@ -405,9 +403,8 @@ export default function dom(
const i = renderer.context_lookup.get($name).index; const i = renderer.context_lookup.get($name).index;
return b` return b`
let ${$name}, let ${$name}, ${unsubscribe} = @noop;
${unsubscribe} = @noop, const ${subscribe} = () => {
${subscribe} = () => {
${unsubscribe}(); ${unsubscribe}();
${unsubscribe} = @subscribe(${name}, (#value) => { $$invalidate(${i}, (${$name} = #value)); }); ${unsubscribe} = @subscribe(${name}, (#value) => { $$invalidate(${i}, (${$name} = #value)); });
return ${name}; return ${name};

@ -36,7 +36,7 @@ export default function ssr(
const rest = uses_rest const rest = uses_rest
? b` ? b`
let #k; let #k;
const #keys = new Set([${props.map(prop => `"${prop.export_name}"`)}]); const #keys = new Set([${props.map(prop => `"${prop.export_name}"`).join()}]);
let $$restProps = {}; let $$restProps = {};
for (#k in $$props){ if (!#keys.has(#k) && #k[0] !== '$'){ $$restProps[#k] = $$props[#k];}}` for (#k in $$props){ if (!#keys.has(#k) && #k[0] !== '$'){ $$restProps[#k] = $$props[#k];}}`
: null; : null;
@ -59,7 +59,7 @@ export default function ssr(
component.rewrite_props( component.rewrite_props(
({ name }) => ({ name }) =>
b` b`
${component.compile_options.dev && b`@validate_store_dev(${name}, '${name}');`} ${component.compile_options.dev && b`@validate_store(${name}, '${name}');`}
@subscribe(${name}, (#v) => { ${`$${name}`} = #v; })();` @subscribe(${name}, (#v) => { ${`$${name}`} = #v; })();`
); );

Loading…
Cancel
Save