rename addConditionalLine to addConditional

pull/769/head
Rich Harris 7 years ago
parent 6222198017
commit 9053e95460

@ -95,7 +95,7 @@ export default function dom(
.map(dep => `state.${dep}`) .map(dep => `state.${dep}`)
.join(', ')} ) ), oldState.${key} ) ) changed.${key} = true;`; .join(', ')} ) ), oldState.${key} ) ) changed.${key} = true;`;
computationBuilder.addConditionalLine(condition, statement); computationBuilder.addConditional(condition, statement);
}); });
} }

@ -166,16 +166,10 @@ export default function visitAttribute(
( dependencies.length ? `( ${changedCheck} ) && ${updateCachedValue}` : updateCachedValue ) : ( dependencies.length ? `( ${changedCheck} ) && ${updateCachedValue}` : updateCachedValue ) :
changedCheck; changedCheck;
// block.builders.update.addConditionalLine( block.builders.update.addConditional(
// condition, condition,
// updater updater
// ); );
block.builders.update.addBlock(deindent`
if ( ${condition} ) {
${updater}
}
`);
} }
} else { } else {
const value = attribute.value === true const value = attribute.value === true

@ -39,7 +39,7 @@ export default function visitTag(
( dependencies.length ? `( ${changedCheck} ) && ${updateCachedValue}` : updateCachedValue ) : ( dependencies.length ? `( ${changedCheck} ) && ${updateCachedValue}` : updateCachedValue ) :
changedCheck; changedCheck;
block.builders.update.addConditionalLine( block.builders.update.addConditional(
condition, condition,
update(shouldCache ? value : snippet) update(shouldCache ? value : snippet)
); );

@ -21,7 +21,7 @@ export default class CodeBuilder {
this.lastCondition = null; this.lastCondition = null;
} }
addConditionalLine(condition: string, body: string) { addConditional(condition: string, body: string) {
body = body.replace(/^/gm, '\t'); body = body.replace(/^/gm, '\t');
if (condition === this.lastCondition) { if (condition === this.lastCondition) {

Loading…
Cancel
Save