normalise CSS parse errors

pull/302/head
Rich Harris 9 years ago
parent 2d5fd6f3a5
commit 3e6e5e5304

@ -6,10 +6,20 @@ export default function readStyle ( parser, start, attributes ) {
const styles = parser.readUntil( /<\/style>/ );
const contentEnd = parser.index;
const ast = parse( styles, {
positions: true,
offset: contentStart
});
let ast;
try {
ast = parse( styles, {
positions: true,
offset: contentStart
});
} catch ( err ) {
if ( err.name === 'CssSyntaxError' ) {
parser.error( err.message, err.offset );
} else {
throw err;
}
}
// tidy up AST
walk.all( ast, node => {

@ -0,0 +1,8 @@
{
"message": "LeftCurlyBracket is expected",
"loc": {
"line": 2,
"column": 16
},
"pos": 24
}

@ -0,0 +1,3 @@
<style>
this is not css
</style>
Loading…
Cancel
Save