refactor: tidy up compile/render_dom

pull/8077/head
Simon He 4 years ago
parent e44762aa2d
commit 3bf08f4296

@ -221,10 +221,8 @@ export default class ElementWrapper extends Wrapper {
this.event_handlers = this.node.handlers.map(event_handler => new EventHandler(event_handler, this)); this.event_handlers = this.node.handlers.map(event_handler => new EventHandler(event_handler, this));
if (node.intro || node.outro) { if (node.intro) block.add_intro(node.intro.is_local);
if (node.intro) block.add_intro(node.intro.is_local); if (node.outro) block.add_outro(node.outro.is_local);
if (node.outro) block.add_outro(node.outro.is_local);
}
if (node.animation) { if (node.animation) {
block.add_animation(); block.add_animation();
@ -326,20 +324,19 @@ export default class ElementWrapper extends Wrapper {
${this.var}.p(#ctx, #dirty); ${this.var}.p(#ctx, #dirty);
} }
} else if (${previous_tag}) { } else if (${previous_tag}) {
${ ${has_transitions
has_transitions ? b`
? b`
@group_outros(); @group_outros();
@transition_out(${this.var}, 1, 1, () => { @transition_out(${this.var}, 1, 1, () => {
${this.var} = null; ${this.var} = null;
}); });
@check_outros(); @check_outros();
` `
: b` : b`
${this.var}.d(1); ${this.var}.d(1);
${this.var} = null; ${this.var} = null;
` `
} }
} }
${previous_tag} = ${tag}; ${previous_tag} = ${tag};
`); `);
@ -681,9 +678,9 @@ export default class ElementWrapper extends Wrapper {
function ${handler}(${params}) { function ${handler}(${params}) {
${binding_group.bindings.map(b => b.handler.mutation)} ${binding_group.bindings.map(b => b.handler.mutation)}
${Array.from(dependencies) ${Array.from(dependencies)
.filter(dep => dep[0] !== '$') .filter(dep => dep[0] !== '$')
.filter(dep => !contextual_dependencies.has(dep)) .filter(dep => !contextual_dependencies.has(dep))
.map(dep => b`${this.renderer.invalidate(dep)};`)} .map(dep => b`${this.renderer.invalidate(dep)};`)}
} }
`); `);

@ -2,11 +2,8 @@ import { Var } from '../../../../interfaces';
import { is_reserved_keyword } from '../../../utils/reserved_keywords'; import { is_reserved_keyword } from '../../../utils/reserved_keywords';
export default function is_dynamic(variable: Var) { export default function is_dynamic(variable: Var) {
if (variable) { if (!variable) return false;
if (variable.mutated || variable.reassigned) return true; // dynamic internal state if (variable.mutated || variable.reassigned) return true; // dynamic internal state
if (!variable.module && variable.writable && variable.export_name) return true; // writable props if (!variable.module && variable.writable && variable.export_name) return true; // writable props
if (is_reserved_keyword(variable.name)) return true; if (is_reserved_keyword(variable.name)) return true;
}
return false;
} }

Loading…
Cancel
Save