diff --git a/documentation/docs/98-reference/.generated/compile-errors.md b/documentation/docs/98-reference/.generated/compile-errors.md index a7ff9e7f627d..05304d747f43 100644 --- a/documentation/docs/98-reference/.generated/compile-errors.md +++ b/documentation/docs/98-reference/.generated/compile-errors.md @@ -400,12 +400,6 @@ Expected token %token% Expected whitespace ``` -### unterminated_string_constant - -``` -Unterminated string constant -``` - ### export_undefined ``` @@ -994,6 +988,12 @@ Unexpected end of input '%word%' is a reserved word in JavaScript and cannot be used here ``` +### unterminated_string_constant + +``` +Unterminated string constant +``` + ### void_element_invalid_content ``` diff --git a/packages/svelte/messages/compile-errors/template.md b/packages/svelte/messages/compile-errors/template.md index 6540af7c76d7..599a1d77a57f 100644 --- a/packages/svelte/messages/compile-errors/template.md +++ b/packages/svelte/messages/compile-errors/template.md @@ -172,10 +172,6 @@ > Expected whitespace -## unterminated_string_constant - -> Unterminated string constant - ## illegal_element_attribute > `<%name%>` does not support non-event attributes or spread attributes @@ -414,6 +410,10 @@ See https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-ele > '%word%' is a reserved word in JavaScript and cannot be used here +## unterminated_string_constant + +> Unterminated string constant + ## void_element_invalid_content > Void elements cannot have children or closing tags diff --git a/packages/svelte/src/compiler/errors.js b/packages/svelte/src/compiler/errors.js index 97b284af8b35..4c51a6422e67 100644 --- a/packages/svelte/src/compiler/errors.js +++ b/packages/svelte/src/compiler/errors.js @@ -1003,15 +1003,6 @@ export function expected_whitespace(node) { e(node, "expected_whitespace", "Expected whitespace"); } -/** - * Unterminated string constant - * @param {null | number | NodeLike} node - * @returns {never} - */ -export function unterminated_string_constant(node) { - e(node, "unterminated_string_constant", "Unterminated string constant"); -} - /** * `<%name%>` does not support non-event attributes or spread attributes * @param {null | number | NodeLike} node @@ -1546,6 +1537,15 @@ export function unexpected_reserved_word(node, word) { e(node, "unexpected_reserved_word", `'${word}' is a reserved word in JavaScript and cannot be used here`); } +/** + * Unterminated string constant + * @param {null | number | NodeLike} node + * @returns {never} + */ +export function unterminated_string_constant(node) { + e(node, "unterminated_string_constant", "Unterminated string constant"); +} + /** * Void elements cannot have children or closing tags * @param {null | number | NodeLike} node @@ -1553,4 +1553,4 @@ export function unexpected_reserved_word(node, word) { */ export function void_element_invalid_content(node) { e(node, "void_element_invalid_content", "Void elements cannot have children or closing tags"); -} +} \ No newline at end of file diff --git a/packages/svelte/src/compiler/phases/1-parse/read/context.js b/packages/svelte/src/compiler/phases/1-parse/read/context.js index 20f021f3a38e..08a0cc482295 100644 --- a/packages/svelte/src/compiler/phases/1-parse/read/context.js +++ b/packages/svelte/src/compiler/phases/1-parse/read/context.js @@ -102,7 +102,10 @@ function read_expression_length(parser, start) { } else if (is_bracket_close(code)) { const popped = /** @type {number} */ (bracket_stack.pop()); if (!is_bracket_pair(popped, code)) { - e.expected_token(i, String.fromCharCode(/** @type {number} */(get_bracket_close(popped)))); + e.expected_token( + i, + String.fromCharCode(/** @type {number} */ (get_bracket_close(popped))) + ); } if (bracket_stack.length === 0) { i += code <= 0xffff ? 1 : 2; @@ -145,10 +148,11 @@ function read_string_length(parser, start, quote) { if ( i < parser.template.length - 1 && is_back_quote(quote) && - code === DOLAR && full_char_code_at(parser.template, i + 1) === LEFT_BRACKET + code === DOLAR && + full_char_code_at(parser.template, i + 1) === LEFT_BRACKET ) { i++; - i = read_expression_length(parser, i) + i = read_expression_length(parser, i); } else { i += code <= 0xffff ? 1 : 2; } diff --git a/packages/svelte/src/compiler/phases/1-parse/utils/quote.js b/packages/svelte/src/compiler/phases/1-parse/utils/quote.js index 25f9e1fac8ab..517e7b3a55da 100644 --- a/packages/svelte/src/compiler/phases/1-parse/utils/quote.js +++ b/packages/svelte/src/compiler/phases/1-parse/utils/quote.js @@ -1,4 +1,4 @@ -const SINGLE_QUOTE = '\''.charCodeAt(0); +const SINGLE_QUOTE = "'".charCodeAt(0); const DOUBLE_QUOTE = '"'.charCodeAt(0); const BACK_QUOTE = '`'.charCodeAt(0);