more tidying up

pull/803/head
Rich Harris 7 years ago
parent 4603d7700f
commit 370327cccd

@ -75,14 +75,11 @@ const preprocessors = {
componentStack: Node[], componentStack: Node[],
stripWhitespace: boolean stripWhitespace: boolean
) => { ) => {
node._state = getChildState(state); if (!/\S/.test(node.data) && (state.namespace || elementsWithoutText.has(state.parentNodeName))) {
node.shouldSkip = true;
if (!/\S/.test(node.data)) { return;
if (state.namespace) return;
if (elementsWithoutText.has(state.parentNodeName)) return;
} }
node.shouldCreate = true;
node.var = block.getUniqueName(`text`); node.var = block.getUniqueName(`text`);
}, },

@ -10,7 +10,7 @@ export default function visitText(
state: State, state: State,
node: Node node: Node
) { ) {
if (!node.shouldCreate) return; if (node.shouldSkip) return;
block.addElement( block.addElement(
node.var, node.var,

@ -1,19 +0,0 @@
import { DomGenerator } from '../index';
import Block from '../Block';
import { State } from '../interfaces';
export default function visitYieldTag(
generator: DomGenerator,
block: Block,
state: State
) {
const parentNode = state.parentNode || '#target';
block.builders.mount.addLine(
`if ( #component._yield ) #component._yield.mount( ${parentNode}, null );`
);
block.builders.unmount.addLine(
`if ( #component._yield ) #component._yield.unmount();`
);
}

@ -4,7 +4,6 @@ import IfBlock from './IfBlock';
import MustacheTag from './MustacheTag'; import MustacheTag from './MustacheTag';
import RawMustacheTag from './RawMustacheTag'; import RawMustacheTag from './RawMustacheTag';
import Text from './Text'; import Text from './Text';
import YieldTag from './YieldTag';
import { Visitor } from '../interfaces'; import { Visitor } from '../interfaces';
const visitors: Record<string, Visitor> = { const visitors: Record<string, Visitor> = {
@ -13,8 +12,7 @@ const visitors: Record<string, Visitor> = {
IfBlock, IfBlock,
MustacheTag, MustacheTag,
RawMustacheTag, RawMustacheTag,
Text, Text
YieldTag,
}; };
export default visitors; export default visitors;
Loading…
Cancel
Save