set all node.var names in preprocess

pull/803/head
Rich Harris 7 years ago
parent 370327cccd
commit 6e9f9633b0

@ -3,13 +3,10 @@ import Block from './Block';
import { Node } from '../../interfaces';
export interface State {
name?: string;
namespace: string;
parentNode: string;
parentNodes: string;
isTopLevel: boolean;
parentNodeName?: string;
basename?: string;
inEachBlock?: boolean;
allUsedContexts?: string[];
usesComponent?: boolean;

@ -16,7 +16,7 @@ function getChildState(parent: State, child = {}) {
return assign(
{},
parent,
{ name: null, parentNode: null, parentNodes: 'nodes' },
{ parentNode: null, parentNodes: 'nodes' },
child || {}
);
}
@ -45,10 +45,10 @@ const preprocessors = {
componentStack: Node[],
stripWhitespace: boolean
) => {
node.var = block.getUniqueName('text');
const dependencies = block.findDependencies(node.expression);
block.addDependencies(dependencies);
node.var = block.getUniqueName('text');
},
RawMustacheTag: (
@ -60,10 +60,10 @@ const preprocessors = {
componentStack: Node[],
stripWhitespace: boolean
) => {
node.var = block.getUniqueName('raw');
const dependencies = block.findDependencies(node.expression);
block.addDependencies(dependencies);
node.var = block.getUniqueName('raw');
},
Text: (
@ -100,6 +100,8 @@ const preprocessors = {
let hasOutros = false;
function attachBlocks(node: Node) {
node.var = block.getUniqueName(`if_block`);
const dependencies = block.findDependencies(node.expression);
block.addDependencies(dependencies);
@ -171,6 +173,8 @@ const preprocessors = {
stripWhitespace: boolean,
nextSibling: Node
) => {
node.var = block.getUniqueName(`each_block`);
const dependencies = block.findDependencies(node.expression);
block.addDependencies(dependencies);

@ -14,7 +14,8 @@ export default function visitEachBlock(
elementStack: Node[],
componentStack: Node[]
) {
const each_block = generator.getUniqueName(`each_block`);
const each_block = node.var;
const create_each_block = node._block.name;
const each_block_value = node._block.listName;
const iterations = block.getUniqueName(`${each_block}_iterations`);

@ -78,7 +78,7 @@ export default function visitIfBlock(
elementStack: Node[],
componentStack: Node[]
) {
const name = generator.getUniqueName(`if_block`);
const name = node.var;
const needsAnchor = node.next ? !isDomNode(node.next) : !state.parentNode;
const anchor = needsAnchor

Loading…
Cancel
Save