diff options
author | 2021-03-21 00:44:42 -0700 | |
---|---|---|
committer | 2021-03-21 00:44:42 -0700 | |
commit | 417657f138fbc5e194df3dd511e3b9c8e53920fd (patch) | |
tree | c15f73c625d3c222304557f4f753204c65304607 /src/compiler/parse/read/script.ts | |
parent | 2082001ff8702ec48072b59caafe85573a3b2891 (diff) | |
download | astro-417657f138fbc5e194df3dd511e3b9c8e53920fd.tar.gz astro-417657f138fbc5e194df3dd511e3b9c8e53920fd.tar.zst astro-417657f138fbc5e194df3dd511e3b9c8e53920fd.zip |
lots of improvements
Diffstat (limited to 'src/compiler/parse/read/script.ts')
-rw-r--r-- | src/compiler/parse/read/script.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/compiler/parse/read/script.ts b/src/compiler/parse/read/script.ts index eb7a8c5b3..7afbfb08f 100644 --- a/src/compiler/parse/read/script.ts +++ b/src/compiler/parse/read/script.ts @@ -7,15 +7,16 @@ import { Node, Program } from 'estree'; const script_closing_tag = '</script>'; -function get_context(parser: Parser, attributes: any[], start: number): string { - const context = attributes.find((attribute) => attribute.name === 'context'); - if (!context) return 'default'; +function get_context(parser: Parser, attributes: any[], start: number): 'runtime' | 'setup' { + const context = attributes.find((attribute) => attribute.name === 'astro'); + if (!context) return 'runtime'; + if (context.value === true) return 'setup'; if (context.value.length !== 1 || context.value[0].type !== 'Text') { parser.error( { code: 'invalid-script', - message: 'context attribute must be static', + message: 'astro attribute must be static', }, start ); @@ -23,11 +24,11 @@ function get_context(parser: Parser, attributes: any[], start: number): string { const value = context.value[0].data; - if (value !== 'module') { + if (value !== 'setup') { parser.error( { code: 'invalid-script', - message: 'If the context attribute is supplied, its value must be "module"', + message: 'If the "astro" attribute has a value, its value must be "setup"', }, context.start ); |