chore: minor tidy up (#12889)

pull/12887/head
Rich Harris 4 months ago committed by GitHub
parent 19a35c62e1
commit cb75b5c966
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -36,24 +36,23 @@ export function process_children(nodes, expression, is_element, { visit, state }
} }
} }
const text_id = get_node_id(expression(true), state, 'text'); const id = get_node_id(expression(true), state, 'text');
state.template.push(' '); state.template.push(' ');
const { has_state, has_call, value } = build_template_literal(sequence, visit, state); const { has_state, has_call, value } = build_template_literal(sequence, visit, state);
const update = b.stmt(b.call('$.set_text', text_id, value)); const update = b.stmt(b.call('$.set_text', id, value));
if (has_call && !within_bound_contenteditable) { if (has_call && !within_bound_contenteditable) {
state.init.push(build_update(update)); state.init.push(build_update(update));
} else if (has_state && !within_bound_contenteditable) { } else if (has_state && !within_bound_contenteditable) {
state.update.push(update); state.update.push(update);
} else { } else {
state.init.push(b.stmt(b.assignment('=', b.member(text_id, b.id('nodeValue')), value))); state.init.push(b.stmt(b.assignment('=', b.member(id, b.id('nodeValue')), value)));
} }
expression = (is_text) => expression = (is_text) => b.call('$.sibling', id, is_text && b.true);
is_text ? b.call('$.sibling', text_id, b.true) : b.call('$.sibling', text_id);
} }
for (let i = 0; i < nodes.length; i += 1) { for (let i = 0; i < nodes.length; i += 1) {
@ -87,8 +86,7 @@ export function process_children(nodes, expression, is_element, { visit, state }
node.type === 'RegularElement' ? node.name : 'node' node.type === 'RegularElement' ? node.name : 'node'
); );
expression = (is_text) => expression = (is_text) => b.call('$.sibling', id, is_text && b.true);
is_text ? b.call('$.sibling', id, b.true) : b.call('$.sibling', id);
visit(node, { visit(node, {
...state, ...state,

Loading…
Cancel
Save