@ -3,8 +3,6 @@
import { NAMESPACE _MATHML , NAMESPACE _SVG } from '../../../../constants.js' ;
import * as e from '../../../errors.js' ;
const regex _valid _tag _name = /^[a-zA-Z][a-zA-Z0-9]*-[a-zA-Z0-9-]+$/ ;
/ * *
* @ param { AST . SvelteOptionsRaw } node
* @ returns { AST . Root [ 'options' ] }
@ -229,6 +227,21 @@ function get_boolean_value(attribute) {
return value ;
}
// https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
const tag _name _char =
'[a-z0-9_.\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}-]' ;
const regex _valid _tag _name = new RegExp ( ` ^[a-z] ${ tag _name _char } *- ${ tag _name _char } * $ ` , 'u' ) ;
const reserved _tag _names = [
'annotation-xml' ,
'color-profile' ,
'font-face' ,
'font-face-src' ,
'font-face-uri' ,
'font-face-format' ,
'font-face-name' ,
'missing-glyph'
] ;
/ * *
* @ param { any } attribute
* @ param { string | null } tag
@ -238,7 +251,11 @@ function validate_tag(attribute, tag) {
if ( typeof tag !== 'string' ) {
e . svelte _options _invalid _tagname ( attribute ) ;
}
if ( tag && ! regex _valid _tag _name . test ( tag ) ) {
e . svelte _options _invalid _tagname ( attribute ) ;
if ( tag ) {
if ( ! regex _valid _tag _name . test ( tag ) ) {
e . svelte _options _invalid _tagname ( attribute ) ;
} else if ( reserved _tag _names . includes ( tag ) ) {
e . svelte _options _reserved _tagname ( attribute ) ;
}
}
}