rename :Switch -> :Component

pull/971/head
Rich Harris 7 years ago
parent e6ef5af6ba
commit e238c65a15

@ -764,7 +764,7 @@ export default class Generator {
this.skip();
}
if (node.type === 'Element' && node.name === ':Switch') {
if (node.type === 'Element' && node.name === ':Component') {
node.metadata = contextualise(node.expression, contextDependencies, indexes);
}
},

@ -437,7 +437,7 @@ const preprocessors = {
}
const isComponent =
generator.components.has(node.name) || node.name === ':Self' || node.name === ':Switch';
generator.components.has(node.name) || node.name === ':Self' || node.name === ':Component';
if (isComponent) {
cannotUseInnerHTML(node);
@ -445,7 +445,7 @@ const preprocessors = {
node.var = block.getUniqueName(
(
node.name === ':Self' ? generator.name :
node.name === ':Switch' ? 'switch_instance' :
node.name === ':Component' ? 'switch_instance' :
node.name
).toLowerCase()
);

@ -205,7 +205,7 @@ export default function visitComponent(
}
}
const isSwitch = node.name === ':Switch';
const isSwitch = node.name === ':Component';
const switch_vars = isSwitch && {
value: block.getUniqueName('switch_value'),
@ -563,7 +563,7 @@ function remount(generator: DomGenerator, node: Node, name: string) {
// TODO make this a method of the nodes
if (node.type === 'Element') {
if (node.name === ':Self' || node.name === ':Switch' || generator.components.has(node.name)) {
if (node.name === ':Self' || node.name === ':Component' || generator.components.has(node.name)) {
return `${node.var}._mount(${name}._slotted.default, null);`;
}

@ -43,7 +43,7 @@ export default function visitElement(
}
}
if (generator.components.has(node.name) || node.name === ':Self' || node.name === ':Switch') {
if (generator.components.has(node.name) || node.name === ':Self' || node.name === ':Component') {
return visitComponent(generator, block, state, node, elementStack, componentStack);
}

@ -71,7 +71,7 @@ export default function visitComponent(
)
.join(', ');
const isSwitch = node.name === ':Switch';
const isSwitch = node.name === ':Component';
if (isSwitch) block.contextualise(node.expression);
const expression = (

@ -40,7 +40,7 @@ export default function visitElement(
return;
}
if (generator.components.has(node.name) || node.name === ':Self' || node.name === ':Switch') {
if (generator.components.has(node.name) || node.name === ':Self' || node.name === ':Component') {
visitComponent(generator, block, node);
return;
}

@ -4,7 +4,7 @@ import Generator from '../../Generator';
export default function isChildOfComponent(node: Node, generator: Generator) {
while (node = node.parent) {
if (node.type !== 'Element') continue;
if (node.name === ':Self' || node.name === ':Switch' || generator.components.has(node.name)) return true; // TODO extract this out into a helper
if (node.name === ':Self' || node.name === ':Component' || generator.components.has(node.name)) return true; // TODO extract this out into a helper
if (/-/.test(node.name)) return false;
}
}

@ -15,7 +15,7 @@ import { Node } from '../../interfaces';
const validTagName = /^\!?[a-zA-Z]{1,}:?[a-zA-Z0-9\-]*/;
const SELF = ':Self';
const SWITCH = ':Switch';
const SWITCH = ':Component';
const metaTags = {
':Window': true

@ -14,7 +14,7 @@ export default function validateElement(
elementStack: Node[]
) {
const isComponent =
node.name === ':Self' || node.name === ':Switch' || validator.components.has(node.name);
node.name === ':Self' || node.name === ':Component' || validator.components.has(node.name);
if (!isComponent && /^[A-Z]/.test(node.name[0])) {
// TODO upgrade to validator.error in v2
@ -230,7 +230,7 @@ function checkSlotAttribute(validator: Validator, node: Node, attribute: Node, s
const parent = stack[i];
if (parent.type === 'Element') {
// if we're inside a component or a custom element, gravy
if (parent.name === ':Self' || parent.name === ':Switch' || validator.components.has(parent.name)) return;
if (parent.name === ':Self' || parent.name === ':Component' || validator.components.has(parent.name)) return;
if (/-/.test(parent.name)) return;
}

Loading…
Cancel
Save