pull/9754/head
Simon Holthausen 3 years ago
parent e41e54758e
commit abcbdc0b8d

@ -26,7 +26,9 @@ const parse = {
'unclosed-element': (name) => `<${name}> was left open`,
'unclosed-block': () => `Block was left open`,
'unexpected-block-close': () => `Unexpected block closing tag`,
'unexpected-eof': () => `Unexpected end of input`,
/** @param {string} [expected] */
'unexpected-eof': (expected) =>
`Unexpected end of input` + (expected ? ` (expected ${expected})` : ''),
/** @param {string} message */
'js-parse-error': (message) => message,
/** @param {string} token */
@ -96,12 +98,9 @@ const css = {
'invalid-css-empty-declaration': () => `Declaration cannot be empty`,
'invalid-css-global-placement': () =>
`:global(...) can be at the start or end of a selector sequence, but not in the middle`,
'invalid-css-global-selector': () => `:global(...) must contain exactly one selector`,
'invalid-css-global-selector-list': () =>
`:global(...) cannot be used to modify a selector, or be modified by another selector`,
'invalid-css-selector': () => `Invalid selector`,
'invalid-css-identifier': () => 'Expected a valid CSS identifier'
};

@ -147,7 +147,7 @@ export class Parser {
if (required) {
if (this.index === this.template.length) {
error(this.index, 'unexpected-eof');
error(this.index, 'unexpected-eof', str);
} else {
error(this.index, 'expected-token', str);
}

@ -235,6 +235,8 @@ function read_selector(parser, inside_pseudo_class = false) {
if (parser.eat('(')) {
args = read_selector_list(parser, true);
parser.eat(')', true);
} else if (name === 'global') {
error(parser.index, 'invalid-css-global-selector');
}
children.push({

@ -3,7 +3,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'missing-attribute-value',
message: 'Expected value for the attribute',
message: 'Expected attribute value',
position: [12, 12]
}
});

@ -2,8 +2,8 @@ import { test } from '../../test';
export default test({
error: {
code: 'unclosed-comment',
message: 'comment was left open, expected -->',
code: 'unexpected-eof',
message: 'Unexpected end of input (expected -->)',
position: [24, 24]
}
});

@ -2,8 +2,8 @@ import { test } from '../../test';
export default test({
error: {
code: 'invalid-css-identifier',
message: ':global() must contain a selector',
position: [9, 9]
code: 'invalid-css-global-selector',
message: ':global(...) must contain exactly one selector',
position: [16, 16]
}
});

@ -3,7 +3,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'invalid-css-identifier',
message: '"{" is expected',
position: [24, 24]
message: 'Expected a valid CSS identifier',
position: [25, 25]
}
});

@ -3,7 +3,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'duplicate-style-element',
message: 'You can only have one top-level <style> tag per component',
message: 'A component can have a single top-level <style> element',
position: [58, 58]
}
});

@ -2,8 +2,8 @@ import { test } from '../../test';
export default test({
error: {
code: 'unclosed-script',
message: '<script> must have a closing tag',
code: 'unexpected-eof',
message: 'Unexpected end of input',
position: [32, 32]
}
});

@ -1,3 +1,3 @@
<script>
<h1>Hello {name}!</h1>
<h1>Hello {name}!</h1>
<script>

@ -2,8 +2,8 @@ import { test } from '../../test';
export default test({
error: {
code: 'unclosed-script',
message: '<script> must have a closing tag',
code: 'unclosed-element',
message: '<script> was left open',
position: [32, 32]
}
});

@ -1,3 +1,3 @@
<h1>Hello {name}!</h1>
<script>
<script>
<h1>Hello {name}!</h1>

@ -2,8 +2,8 @@ import { test } from '../../test';
export default test({
error: {
code: 'unclosed-style',
message: '<style> must have a closing tag',
code: 'expected-token',
message: 'Expected token </style',
position: [31, 31]
}
});

@ -1,3 +1,3 @@
<style>
<h1>Hello {name}!</h1>
<h1>Hello {name}!</h1>
<style>

@ -2,8 +2,8 @@ import { test } from '../../test';
export default test({
error: {
code: 'unclosed-style',
message: '<style> must have a closing tag',
position: [31, 31]
code: 'invalid-css-identifier',
message: 'Expected a valid CSS identifier',
position: [9, 9]
}
});

@ -1,3 +1,3 @@
<h1>Hello {name}!</h1>
<style>
<style>
<h1>Hello {name}!</h1>
Loading…
Cancel
Save