fix tests, finish renaming stuff

pull/971/head
Rich Harris 8 years ago
parent e238c65a15
commit 0d42ff84db

@ -205,20 +205,20 @@ export default function visitComponent(
}
}
const isSwitch = node.name === ':Component';
const isDynamicComponent = node.name === ':Component';
const switch_vars = isSwitch && {
const switch_vars = isDynamicComponent && {
value: block.getUniqueName('switch_value'),
props: block.getUniqueName('switch_props')
};
const expression = (
node.name === ':Self' ? generator.name :
isSwitch ? switch_vars.value :
isDynamicComponent ? switch_vars.value :
`%components-${node.name}`
);
if (isSwitch) {
if (isDynamicComponent) {
block.contextualise(node.expression);
const { dependencies, snippet } = node.metadata;

@ -71,12 +71,12 @@ export default function visitComponent(
)
.join(', ');
const isSwitch = node.name === ':Component';
if (isSwitch) block.contextualise(node.expression);
const isDynamicComponent = node.name === ':Component';
if (isDynamicComponent) block.contextualise(node.expression);
const expression = (
node.name === ':Self' ? generator.name :
isSwitch ? `((${node.metadata.snippet}) || __missingComponent)` :
isDynamicComponent ? `((${node.metadata.snippet}) || __missingComponent)` :
`%components-${node.name}`
);

@ -15,7 +15,7 @@ import { Node } from '../../interfaces';
const validTagName = /^\!?[a-zA-Z]{1,}:?[a-zA-Z0-9\-]*/;
const SELF = ':Self';
const SWITCH = ':Component';
const COMPONENT = ':Component';
const metaTags = {
':Window': true
@ -166,7 +166,7 @@ export default function tag(parser: Parser) {
}
}
if (name === SWITCH) {
if (name === COMPONENT) {
parser.eat('{', true);
element.expression = readExpression(parser);
parser.allowWhitespace();
@ -248,7 +248,7 @@ function readTagName(parser: Parser) {
return SELF;
}
if (parser.eat(SWITCH)) return SWITCH;
if (parser.eat(COMPONENT)) return COMPONENT;
const name = parser.readUntil(/(\s|\/|>)/);

@ -1 +1 @@
<:Switch {foo ? Foo : Bar}></:Switch>
<:Component {foo ? Foo : Bar}></:Component>

@ -1,37 +1,37 @@
{
"hash": 755548012,
"hash": 410218696,
"html": {
"start": 0,
"end": 37,
"end": 43,
"type": "Fragment",
"children": [
{
"start": 0,
"end": 37,
"end": 43,
"type": "Element",
"name": ":Switch",
"name": ":Component",
"attributes": [],
"children": [],
"expression": {
"type": "ConditionalExpression",
"start": 10,
"end": 25,
"start": 13,
"end": 28,
"test": {
"type": "Identifier",
"start": 10,
"end": 13,
"start": 13,
"end": 16,
"name": "foo"
},
"consequent": {
"type": "Identifier",
"start": 16,
"end": 19,
"start": 19,
"end": 22,
"name": "Foo"
},
"alternate": {
"type": "Identifier",
"start": 22,
"end": 25,
"start": 25,
"end": 28,
"name": "Bar"
}
}

@ -1,4 +1,4 @@
<:Switch { x ? Foo : Bar } bind:y bind:z/>
<:Component { x ? Foo : Bar } bind:y bind:z/>
<script>
import Foo from './Foo.html';

@ -1,4 +1,4 @@
<:Switch { x ? Foo : Bar } on:select='set({ selected: event.id })'/>
<:Component { x ? Foo : Bar } on:select='set({ selected: event.id })'/>
<script>
import Foo from './Foo.html';

@ -1,4 +1,4 @@
<:Switch { x ? Foo : Bar } x='{{x}}'>
<:Component { x ? Foo : Bar } x='{{x}}'>
<p>element</p>
{{tag}}
@ -20,7 +20,7 @@
<Baz/>
<div slot='other'>what goes up must come down</div>
</:Switch>
</:Component>
<script>
import Foo from './Foo.html';

@ -1,4 +1,4 @@
<:Switch { x ? Foo : Bar } x='{{x}}'/>
<:Component { x ? Foo : Bar } x='{{x}}'/>
<script>
import Foo from './Foo.html';

@ -1,4 +1,4 @@
<:Switch { x ? Foo : Bar } x='{{x}}'/>
<:Component { x ? Foo : Bar } x='{{x}}'/>
<script>
import Foo from './Foo.html';

Loading…
Cancel
Save