You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/compiler/parse/read/script.js

26 lines
527 B

8 years ago
import { parse, tokenizer, tokTypes } from 'acorn';
export default function readScript ( parser, start, attributes ) {
const scriptStart = parser.index;
let scriptEnd = null;
const js = {
start,
end: null,
attributes,
content: null
};
const endPattern = /\s*<\/script\>/g;
for ( const token of tokenizer( parser.remaining() ) ) {
endPattern.lastIndex = scriptStart + token.end;
if ( endPattern.test( parser.template ) ) {
scriptEnd = scriptStart + token.end;
break;
}
}
js.content = parse( )
}