Merge branch 'master' into gh-40

pull/316/head
Rich Harris 9 years ago
commit 0d41a7813b

@ -123,7 +123,14 @@ export default function parse ( template, options = {} ) {
state = state( parser ) || fragment; state = state( parser ) || fragment;
} }
if ( state !== fragment || parser.stack.length > 1 ) { if ( parser.stack.length > 1 ) {
const current = parser.current();
const type = current.type === 'Element' ? `<${current.name}>` : 'Block';
parser.error( `${type} was left open`, current.start );
}
if ( state !== fragment ) {
parser.error( 'Unexpected end of input' ); parser.error( 'Unexpected end of input' );
} }

@ -45,7 +45,7 @@ describe( 'parse', () => {
svelte.compile( `<h1>unclosed`, { svelte.compile( `<h1>unclosed`, {
onerror ( err ) { onerror ( err ) {
errored = true; errored = true;
assert.equal( err.message, `Unexpected end of input` ); assert.equal( err.message, `<h1> was left open` );
} }
}); });
@ -55,6 +55,6 @@ describe( 'parse', () => {
it( 'throws without options.onerror', () => { it( 'throws without options.onerror', () => {
assert.throws( () => { assert.throws( () => {
svelte.compile( `<h1>unclosed` ); svelte.compile( `<h1>unclosed` );
}, /Unexpected end of input/ ); }, /<h1> was left open/ );
}); });
}); });

@ -0,0 +1,8 @@
{
"message": "Block was left open",
"loc": {
"line": 1,
"column": 0
},
"pos": 0
}

@ -1,8 +1,8 @@
{ {
"message": "Unexpected end of input", "message": "<div> was left open",
"loc": { "loc": {
"line": 1, "line": 1,
"column": 5 "column": 0
}, },
"pos": 5 "pos": 0
} }

Loading…
Cancel
Save