diff --git a/src/compiler/parse/state/tag.ts b/src/compiler/parse/state/tag.ts index 761ce5437d..af12e4423e 100644 --- a/src/compiler/parse/state/tag.ts +++ b/src/compiler/parse/state/tag.ts @@ -11,6 +11,7 @@ import { closing_tag_omitted, decode_character_references } from '../utils/html' // characters equivalent to using \s in regex const whitespace_characters = ['\r', '\n', '\t', '\f', '\v', ' ', '\u00a0', '\u1680', '\u2000', '\u2001', '\u2002', '\u2003', '\u2004', '\u2005', '\u2006', '\u2007', '\u2008', '\u2009', '\u200a', '\u2028', '\u2029', '\u202f', '\u205f', '\u3000', '\ufeff']; +const invalid_attribute_characters = [...whitespace_characters, '/', '"', '\'', '=', '<', '>', '`']; // eslint-disable-next-line no-useless-escape const valid_tag_name = /^\!?[a-zA-Z]{1,}:?[a-zA-Z0-9\-]*/; @@ -367,7 +368,6 @@ function read_attribute(parser: Parser, unique_names: Set) { parser.error(parser_errors.unexpected_token('='), parser.index); } - if (type) { const [directive_name, ...modifiers] = name.slice(colon_index + 1).split('|'); @@ -473,8 +473,10 @@ function read_attribute_value(parser: Parser) { let value; try { - const characters = quote_mark ? [quote_mark] : [...whitespace_characters, '/>', '"', '\'', '=', '<', '>', '`']; - value = read_sequence(parser, () => characters.some(c => parser.match(c))); + value = read_sequence(parser, () => { + if (quote_mark) return parser.match(quote_mark); + return invalid_attribute_characters.some(c => parser.match(c)); + }); } catch (error) { if (error.code === 'parse-error') { // if the attribute value didn't close + self-closing tag