fix: allow more characters in the unicode range as component identifiers (#13198)

fixes #13194

We narrowed the allowed characters in #13057, but didn't take into account all possible (and for JavaScript identifiers allowed) unicode characters. This widens that, which also removes the accidental breaking change (because in Svelte 4 you were allowed to use these unicode characters).
pull/13141/head
Simon H 3 months ago committed by GitHub
parent ccbb0b1de2
commit 7998f4ce54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: allow more characters in the unicode range as component identifiers

@ -24,7 +24,9 @@ const regex_attribute_value = /^(?:"([^"]*)"|'([^'])*'|([^>\s]+))/;
const regex_valid_element_name =
/^(?:![a-zA-Z]+|[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|[a-zA-Z][a-zA-Z0-9]*:[a-zA-Z][a-zA-Z0-9-]*[a-zA-Z0-9])$/;
const regex_valid_component_name =
/^(?:[A-Z][A-Za-z0-9_$.]*|[a-z][A-Za-z0-9_$]*(?:\.[A-Za-z0-9_$]+)+)$/;
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers adjusted for our needs
// (must start with uppercase letter if no dots, can contain dots)
/^(?:\p{Lu}[$\u200c\u200d\p{ID_Continue}.]*|\p{ID_Start}[$\u200c\u200d\p{ID_Continue}]*(?:\.[$\u200c\u200d\p{ID_Continue}]+)+)$/u;
/** @type {Map<string, ElementLike['type']>} */
const root_only_meta_tags = new Map([

@ -5,6 +5,6 @@ export default test({
code: 'tag_invalid_name',
message:
'Expected a valid element or component name. Components must have a valid variable name or dot notation expression',
position: [1, 14]
position: [71, 84]
}
});

@ -1 +1,7 @@
<!-- ok -->
<Component />
<Wunderschön />
<Cæжα />
<!-- error -->
<Components[1] />

Loading…
Cancel
Save