mirror of https://github.com/sveltejs/svelte
parent
a02c3dba28
commit
50654fab88
@ -1,42 +0,0 @@
|
||||
import flattenReference from '../../utils/flattenReference';
|
||||
import fuzzymatch from '../utils/fuzzymatch';
|
||||
import list from '../../utils/list';
|
||||
import validateEventHandler from './validateEventHandler';
|
||||
import { Validator } from '../index';
|
||||
import { Node } from '../../interfaces';
|
||||
|
||||
const descriptions = {
|
||||
Bindings: 'two-way bindings',
|
||||
EventHandler: 'event handlers',
|
||||
Transition: 'transitions',
|
||||
Ref: 'refs'
|
||||
};
|
||||
|
||||
export default function validateWindow(validator: Validator, node: Node, refs: Map<string, Node[]>, refCallees: Node[]) {
|
||||
node.attributes.forEach((attribute: Node) => {
|
||||
if (attribute.type === 'Attribute') {
|
||||
if (attribute.name !== 'title') {
|
||||
validator.error(
|
||||
`<:Document> can only have a 'title' attribute`,
|
||||
attribute.start
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
const description = descriptions[attribute.type];
|
||||
if (description) {
|
||||
validator.error(
|
||||
`<:Document> does not support ${description}`,
|
||||
attribute.start
|
||||
);
|
||||
} else {
|
||||
// future-proofing
|
||||
validator.error(
|
||||
`<:Document> can only have a 'title' attribute`,
|
||||
attribute.start
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
import { Validator } from '../index';
|
||||
import { Node } from '../../interfaces';
|
||||
|
||||
export default function validateHead(validator: Validator, node: Node, refs: Map<string, Node[]>, refCallees: Node[]) {
|
||||
if (node.attributes.length) {
|
||||
validator.error(`<:Head> should not have any attributes or directives`, node.start);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
<:Document title='a {{adjective}} title'/>
|
@ -1 +0,0 @@
|
||||
<:Document title='changed'/>
|
@ -1,4 +1,6 @@
|
||||
export default {
|
||||
solo: true,
|
||||
|
||||
data: {
|
||||
adjective: 'custom'
|
||||
},
|
@ -0,0 +1,4 @@
|
||||
<:Head>
|
||||
<title>a {{adjective}} title</title>
|
||||
<meta name='twitter:creator' content='@sveltejs'>
|
||||
</:Head>
|
@ -0,0 +1,4 @@
|
||||
<:Head>
|
||||
<title>changed</title>
|
||||
<meta name='twitter:creator' content='@sveltejs'>
|
||||
</:Head>
|
@ -1 +0,0 @@
|
||||
<:Document title='a {{adjective}} title'/>
|
@ -0,0 +1,3 @@
|
||||
<:Head>
|
||||
<title>a {{adjective}} title</title>
|
||||
</:Head>
|
Loading…
Reference in new issue