more tidying up

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

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

@ -10,7 +10,7 @@ export default function visitText(
state: State,
node: Node
) {
if (!node.shouldCreate) return;
if (node.shouldSkip) return;
block.addElement(
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 RawMustacheTag from './RawMustacheTag';
import Text from './Text';
import YieldTag from './YieldTag';
import { Visitor } from '../interfaces';
const visitors: Record<string, Visitor> = {
@ -13,8 +12,7 @@ const visitors: Record<string, Visitor> = {
IfBlock,
MustacheTag,
RawMustacheTag,
Text,
YieldTag,
Text
};
export default visitors;
Loading…
Cancel
Save