Skip to content

Commit 0d42ff8

Browse files
committed
fix tests, finish renaming stuff
1 parent e238c65 commit 0d42ff8

File tree

10 files changed

+29
-29
lines changed

10 files changed

+29
-29
lines changed

src/generators/dom/visitors/Component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,20 +205,20 @@ export default function visitComponent(
205205
}
206206
}
207207

208-
const isSwitch = node.name === ':Component';
208+
const isDynamicComponent = node.name === ':Component';
209209

210-
const switch_vars = isSwitch && {
210+
const switch_vars = isDynamicComponent && {
211211
value: block.getUniqueName('switch_value'),
212212
props: block.getUniqueName('switch_props')
213213
};
214214

215215
const expression = (
216216
node.name === ':Self' ? generator.name :
217-
isSwitch ? switch_vars.value :
217+
isDynamicComponent ? switch_vars.value :
218218
`%components-${node.name}`
219219
);
220220

221-
if (isSwitch) {
221+
if (isDynamicComponent) {
222222
block.contextualise(node.expression);
223223
const { dependencies, snippet } = node.metadata;
224224

src/generators/server-side-rendering/visitors/Component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ export default function visitComponent(
7171
)
7272
.join(', ');
7373

74-
const isSwitch = node.name === ':Component';
75-
if (isSwitch) block.contextualise(node.expression);
74+
const isDynamicComponent = node.name === ':Component';
75+
if (isDynamicComponent) block.contextualise(node.expression);
7676

7777
const expression = (
7878
node.name === ':Self' ? generator.name :
79-
isSwitch ? `((${node.metadata.snippet}) || __missingComponent)` :
79+
isDynamicComponent ? `((${node.metadata.snippet}) || __missingComponent)` :
8080
`%components-${node.name}`
8181
);
8282

src/parse/state/tag.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Node } from '../../interfaces';
1515
const validTagName = /^\!?[a-zA-Z]{1,}:?[a-zA-Z0-9\-]*/;
1616

1717
const SELF = ':Self';
18-
const SWITCH = ':Component';
18+
const COMPONENT = ':Component';
1919

2020
const metaTags = {
2121
':Window': true
@@ -166,7 +166,7 @@ export default function tag(parser: Parser) {
166166
}
167167
}
168168

169-
if (name === SWITCH) {
169+
if (name === COMPONENT) {
170170
parser.eat('{', true);
171171
element.expression = readExpression(parser);
172172
parser.allowWhitespace();
@@ -248,7 +248,7 @@ function readTagName(parser: Parser) {
248248
return SELF;
249249
}
250250

251-
if (parser.eat(SWITCH)) return SWITCH;
251+
if (parser.eat(COMPONENT)) return COMPONENT;
252252

253253
const name = parser.readUntil(/(\s|\/|>)/);
254254

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<:Switch {foo ? Foo : Bar}></:Switch>
1+
<:Component {foo ? Foo : Bar}></:Component>

test/parser/samples/component-dynamic/output.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
{
2-
"hash": 755548012,
2+
"hash": 410218696,
33
"html": {
44
"start": 0,
5-
"end": 37,
5+
"end": 43,
66
"type": "Fragment",
77
"children": [
88
{
99
"start": 0,
10-
"end": 37,
10+
"end": 43,
1111
"type": "Element",
12-
"name": ":Switch",
12+
"name": ":Component",
1313
"attributes": [],
1414
"children": [],
1515
"expression": {
1616
"type": "ConditionalExpression",
17-
"start": 10,
18-
"end": 25,
17+
"start": 13,
18+
"end": 28,
1919
"test": {
2020
"type": "Identifier",
21-
"start": 10,
22-
"end": 13,
21+
"start": 13,
22+
"end": 16,
2323
"name": "foo"
2424
},
2525
"consequent": {
2626
"type": "Identifier",
27-
"start": 16,
28-
"end": 19,
27+
"start": 19,
28+
"end": 22,
2929
"name": "Foo"
3030
},
3131
"alternate": {
3232
"type": "Identifier",
33-
"start": 22,
34-
"end": 25,
33+
"start": 25,
34+
"end": 28,
3535
"name": "Bar"
3636
}
3737
}

test/runtime/samples/dynamic-component-bindings/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<:Switch { x ? Foo : Bar } bind:y bind:z/>
1+
<:Component { x ? Foo : Bar } bind:y bind:z/>
22

33
<script>
44
import Foo from './Foo.html';

test/runtime/samples/dynamic-component-events/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<:Switch { x ? Foo : Bar } on:select='set({ selected: event.id })'/>
1+
<:Component { x ? Foo : Bar } on:select='set({ selected: event.id })'/>
22

33
<script>
44
import Foo from './Foo.html';

test/runtime/samples/dynamic-component-slot/main.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<:Switch { x ? Foo : Bar } x='{{x}}'>
1+
<:Component { x ? Foo : Bar } x='{{x}}'>
22
<p>element</p>
33

44
{{tag}}
@@ -20,7 +20,7 @@
2020
<Baz/>
2121

2222
<div slot='other'>what goes up must come down</div>
23-
</:Switch>
23+
</:Component>
2424

2525
<script>
2626
import Foo from './Foo.html';

test/runtime/samples/dynamic-component-update-existing-instance/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<:Switch { x ? Foo : Bar } x='{{x}}'/>
1+
<:Component { x ? Foo : Bar } x='{{x}}'/>
22

33
<script>
44
import Foo from './Foo.html';

test/runtime/samples/dynamic-component/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<:Switch { x ? Foo : Bar } x='{{x}}'/>
1+
<:Component { x ? Foo : Bar } x='{{x}}'/>
22

33
<script>
44
import Foo from './Foo.html';

0 commit comments

Comments
 (0)