fix a couple of TODOs

pull/1193/head
Rich Harris 8 years ago
parent 0648998a5c
commit 1bc675da50

@ -168,7 +168,7 @@ export default class Generator {
if (options.customElement === true) {
this.customElement = {
tag: this.tag,
props: this.props // TODO autofill this in
props: this.props
}
} else {
this.customElement = options.customElement;
@ -752,12 +752,6 @@ export default class Generator {
if (node.type === 'Element' && (node.name === ':Component' || node.name === ':Self' || generator.components.has(node.name))) {
node.type = 'Component';
Object.setPrototypeOf(node, nodes.Component.prototype);
} else if (node.name === ':Window') { // TODO do this in parse?
node.type = 'Window';
Object.setPrototypeOf(node, nodes.Window.prototype);
} else if (node.name === ':Head') { // TODO do this in parse?
node.type = 'Head';
Object.setPrototypeOf(node, nodes.Head.prototype);
} else if (node.type === 'Element' && node.name === 'title' && parentIsHead(parent)) { // TODO do this in parse?
node.type = 'Title';
Object.setPrototypeOf(node, nodes.Title.prototype);

@ -308,22 +308,19 @@ export default class Block {
if (this.hasOutroMethod) {
if (hasOutros) {
properties.addBlock(deindent`
o: function outro(${this.alias('outrocallback')}) {
o: function outro(#outrocallback) {
if (${outroing}) return;
${outroing} = true;
${hasIntros && `${introing} = false;`}
var ${this.alias('outros')} = ${this.outros};
var #outros = ${this.outros};
${this.builders.outro}
},
`);
} else {
// TODO should this be a helper?
properties.addBlock(deindent`
o: function outro(outrocallback) {
outrocallback();
},
o: @run,
`);
}
}

@ -109,10 +109,14 @@ export default function tag(parser: Parser) {
}
}
const type = metaTags.has(name)
? name.slice(1)
: 'Element'; // TODO in v2, capitalised name means 'Component'
const element: Node = {
start,
end: null, // filled in later
type: 'Element',
type,
name,
attributes: [],
children: [],

@ -138,6 +138,10 @@ export function onDev(eventName, handler) {
return on.call(this, eventName, handler);
}
export function run(fn) {
fn();
}
export function set(newState) {
this._set(assign({}, newState));
if (this.root._lock) return;

@ -7,11 +7,6 @@ import flattenReference from '../../utils/flattenReference';
import { Validator } from '../index';
import { Node } from '../../interfaces';
const meta = new Map([
[':Window', validateWindow],
[':Head', validateHead]
]);
function isEmptyBlock(node: Node) {
if (!/Block$/.test(node.type) || !node.children) return false;
if (node.children.length > 1) return false;
@ -26,11 +21,15 @@ export default function validateHtml(validator: Validator, html: Node) {
const elementStack: Node[] = [];
function visit(node: Node) {
if (node.type === 'Element') {
if (meta.has(node.name)) {
return meta.get(node.name)(validator, node, refs, refCallees);
}
if (node.type === 'Window') {
validateWindow(validator, node, refs, refCallees);
}
else if (node.type === 'Head') {
validateHead(validator, node, refs, refCallees);
}
else if (node.type === 'Element') {
const isComponent =
node.name === ':Self' ||
node.name === ':Component' ||
@ -49,7 +48,9 @@ export default function validateHtml(validator: Validator, html: Node) {
if (!isComponent) {
a11y(validator, node, elementStack);
}
} else if (node.type === 'EachBlock') {
}
else if (node.type === 'EachBlock') {
if (validator.helpers.has(node.context)) {
let c = node.expression.end;

Loading…
Cancel
Save