more tidying up

pull/1367/head
Rich Harris 7 years ago
parent d10072f6b7
commit 11d396f769

@ -15,7 +15,6 @@ import annotateWithScopes, { Scope } from '../utils/annotateWithScopes';
import getName from '../utils/getName';
import Stylesheet from '../css/Stylesheet';
import { test } from '../config';
import nodes from './nodes/index';
import Fragment from './nodes/Fragment';
import { Node, GenerateOptions, ShorthandImport, Ast, CompileOptions, CustomElementOptions } from '../interfaces';

@ -41,13 +41,9 @@ export default class AwaitBlock extends Node {
this.var = block.getUniqueName('await_block');
block.addDependencies(this.expression.dependencies);
let dynamic = false;
let isDynamic = false;
[
['pending', null],
['then', this.value],
['catch', this.error]
].forEach(([status, arg]) => {
['pending', 'then', 'catch'].forEach(status => {
const child = this[status];
child.block = block.child({
@ -59,14 +55,14 @@ export default class AwaitBlock extends Node {
this.compiler.blocks.push(child.block);
if (child.block.dependencies.size > 0) {
dynamic = true;
isDynamic = true;
block.addDependencies(child.block.dependencies);
}
});
this.pending.block.hasUpdateMethod = dynamic;
this.then.block.hasUpdateMethod = dynamic;
this.catch.block.hasUpdateMethod = dynamic;
this.pending.block.hasUpdateMethod = isDynamic;
this.then.block.hasUpdateMethod = isDynamic;
this.catch.block.hasUpdateMethod = isDynamic;
}
build(

@ -11,7 +11,6 @@ import Block from '../dom/Block';
import Attribute from './Attribute';
import Binding from './Binding';
import EventHandler from './EventHandler';
import Ref from './Ref';
import Transition from './Transition';
import Action from './Action';
import Text from './Text';
@ -177,10 +176,12 @@ export default class Element extends Node {
});
if (this.intro) {
this.parent.cannotUseInnerHTML();
this.compiler.hasIntroTransitions = block.hasIntroMethod = true;
}
if (this.outro) {
this.parent.cannotUseInnerHTML();
this.compiler.hasOutroTransitions = block.hasOutroMethod = true;
block.outros += 1;
}

@ -3,12 +3,6 @@ import Tag from './shared/Tag';
import Block from '../dom/Block';
export default class MustacheTag extends Tag {
init(block: Block) {
this.cannotUseInnerHTML();
this.var = block.getUniqueName('text');
block.addDependencies(this.expression.dependencies);
}
build(
block: Block,
parentNode: string,

@ -4,12 +4,6 @@ import Tag from './shared/Tag';
import Block from '../dom/Block';
export default class RawMustacheTag extends Tag {
init(block: Block) {
this.cannotUseInnerHTML();
this.var = block.getUniqueName('raw');
block.addDependencies(this.expression.dependencies);
}
build(
block: Block,
parentNode: string,

@ -1,7 +0,0 @@
import Node from './shared/Node';
export default class Ref extends Node {
name: string;
value: Node[]
expression: Node
}

@ -1,54 +0,0 @@
import Node from './shared/Node';
import Attribute from './Attribute';
import AwaitBlock from './AwaitBlock';
import Action from './Action';
import Binding from './Binding';
import CatchBlock from './CatchBlock';
import Comment from './Comment';
import Component from './Component';
import EachBlock from './EachBlock';
import Element from './Element';
import ElseBlock from './ElseBlock';
import EventHandler from './EventHandler';
import Fragment from './Fragment';
import Head from './Head';
import IfBlock from './IfBlock';
import MustacheTag from './MustacheTag';
import PendingBlock from './PendingBlock';
import RawMustacheTag from './RawMustacheTag';
import Ref from './Ref';
import Slot from './Slot';
import Text from './Text';
import ThenBlock from './ThenBlock';
import Title from './Title';
import Transition from './Transition';
import Window from './Window';
const nodes: Record<string, any> = {
Attribute,
AwaitBlock,
Action,
Binding,
CatchBlock,
Comment,
Component,
EachBlock,
Element,
ElseBlock,
EventHandler,
Fragment,
Head,
IfBlock,
MustacheTag,
PendingBlock,
RawMustacheTag,
Ref,
Slot,
Text,
ThenBlock,
Title,
Transition,
Window
};
export default nodes;

@ -16,6 +16,12 @@ export default class Tag extends Node {
);
}
init(block: Block) {
this.cannotUseInnerHTML();
this.var = block.getUniqueName(this.type === 'MustacheTag' ? 'text' : 'raw');
block.addDependencies(this.expression.dependencies);
}
renameThisMethod(
block: Block,
update: ((value: string) => string)

Loading…
Cancel
Save