bit more golfing

pull/9601/head
Rich Harris 3 years ago
parent a5da886248
commit 90ba82114b

@ -1037,15 +1037,17 @@ function create_block(parent, name, nodes, context) {
const template = state.template[0]; const template = state.template[0];
if (state.template.length === 1 && (template === ' ' || template === '<!>')) { if (state.template.length === 1 && (template === ' ' || template === '<!>')) {
const callee = b.id(template === ' ' ? '$.space' : '$.comment'); if (template === ' ') {
body.push(b.var(node_id, b.call('$.space', b.id('$$anchor'))), ...state.init);
close = b.stmt(b.call('$.close', b.id('$$anchor'), node_id));
} else {
body.push( body.push(
b.var(id, b.call(callee, b.id('$$anchor'))), b.var(id, b.call('$.comment', b.id('$$anchor'))),
b.var(node_id, b.call('$.child_frag', id)), b.var(node_id, b.call('$.child_frag', id)),
...state.init ...state.init
); );
close = b.stmt(b.call('$.close_frag', b.id('$$anchor'), id)); close = b.stmt(b.call('$.close_frag', b.id('$$anchor'), id));
}
} else { } else {
const callee = namespace === 'svg' ? '$.svg_template' : '$.template'; const callee = namespace === 'svg' ? '$.svg_template' : '$.template';

@ -176,7 +176,7 @@ export function open_frag(anchor, use_clone_node, template_element_fn) {
return open_template(true, use_clone_node, anchor, template_element_fn); return open_template(true, use_clone_node, anchor, template_element_fn);
} }
const space_template = template(' ', true); const space_template = template(' ', false);
const comment_template = template('<!>', true); const comment_template = template('<!>', true);
/** /**
@ -184,7 +184,7 @@ const comment_template = template('<!>', true);
*/ */
/*#__NO_SIDE_EFFECTS__*/ /*#__NO_SIDE_EFFECTS__*/
export function space(anchor) { export function space(anchor) {
return open_frag(anchor, true, space_template); return open(anchor, true, space_template);
} }
/** /**

@ -21,12 +21,11 @@ export default function Function_prop_no_getter($$anchor, $$props) {
onmouseup, onmouseup,
children: ($$anchor, $$slotProps) => { children: ($$anchor, $$slotProps) => {
/* Init */ /* Init */
var fragment_1 = $.space($$anchor); var node_1 = $.space($$anchor);
var node_1 = $.child_frag(fragment_1);
/* Update */ /* Update */
$.text_effect(node_1, () => `clicks: ${$.stringify($.get(count))}`); $.text_effect(node_1, () => `clicks: ${$.stringify($.get(count))}`);
$.close_frag($$anchor, fragment_1); $.close($$anchor, node_1);
} }
}); });

Loading…
Cancel
Save