@ -13,7 +13,7 @@ export function hash(str) {
return ( hash >>> 0 ) . toString ( 36 ) ;
}
const VOID _ELEMENT _NAMES = [
const VOID _ELEMENT _NAMES = new Set ( [
'area' ,
'base' ,
'br' ,
@ -30,17 +30,17 @@ const VOID_ELEMENT_NAMES = [
'source' ,
'track' ,
'wbr'
] ;
] ) ;
/ * *
* Returns ` true ` if ` name ` is of a void element
* @ param { string } name
* /
export function is _void ( name ) {
return VOID _ELEMENT _NAMES . include s( name ) || name . toLowerCase ( ) === '!doctype' ;
return VOID _ELEMENT _NAMES . ha s( name ) || name . toLowerCase ( ) === '!doctype' ;
}
const RESERVED _WORDS = [
const RESERVED _WORDS = new Set ( [
'arguments' ,
'await' ,
'break' ,
@ -89,14 +89,14 @@ const RESERVED_WORDS = [
'while' ,
'with' ,
'yield'
] ;
] ) ;
/ * *
* Returns ` true ` if ` word ` is a reserved JavaScript keyword
* @ param { string } word
* /
export function is _reserved ( word ) {
return RESERVED _WORDS . include s( word ) ;
return RESERVED _WORDS . ha s( word ) ;
}
/ * *
@ -106,8 +106,8 @@ export function is_capture_event(name) {
return name . endsWith ( 'capture' ) && name !== 'gotpointercapture' && name !== 'lostpointercapture' ;
}
/** Lis t of Element events that will be delegated */
const DELEGATED _EVENTS = [
/** Se t of Element events that will be delegated */
const DELEGATED _EVENTS = new Set ( [
'beforeinput' ,
'click' ,
'change' ,
@ -131,20 +131,20 @@ const DELEGATED_EVENTS = [
'touchend' ,
'touchmove' ,
'touchstart'
] ;
] ) ;
/ * *
* Returns ` true ` if ` event_name ` is a delegated event
* @ param { string } event _name
* /
export function can _delegate _event ( event _name ) {
return DELEGATED _EVENTS . include s( event _name ) ;
return DELEGATED _EVENTS . ha s( event _name ) ;
}
/ * *
* Attributes that are boolean , i . e . they are present or not present .
* /
const DOM _BOOLEAN _ATTRIBUTES = [
const DOM _BOOLEAN _ATTRIBUTES = new Set ( [
'allowfullscreen' ,
'async' ,
'autofocus' ,
@ -173,14 +173,14 @@ const DOM_BOOLEAN_ATTRIBUTES = [
'defer' ,
'disablepictureinpicture' ,
'disableremoteplayback'
] ;
] ) ;
/ * *
* Returns ` true ` if ` name ` is a boolean attribute
* @ param { string } name
* /
export function is _boolean _attribute ( name ) {
return DOM _BOOLEAN _ATTRIBUTES . include s( name ) ;
return DOM _BOOLEAN _ATTRIBUTES . ha s( name ) ;
}
/ * *
@ -213,7 +213,7 @@ export function normalize_attribute(name) {
return ATTRIBUTE _ALIASES [ name ] ? ? name ;
}
const DOM _PROPERTIES = [
const DOM _PROPERTIES = new Set ( [
... DOM _BOOLEAN _ATTRIBUTES ,
'formNoValidate' ,
'isMap' ,
@ -229,16 +229,16 @@ const DOM_PROPERTIES = [
'allowFullscreen' ,
'disablePictureInPicture' ,
'disableRemotePlayback'
] ;
] ) ;
/ * *
* @ param { string } name
* /
export function is _dom _property ( name ) {
return DOM _PROPERTIES . include s( name ) ;
return DOM _PROPERTIES . ha s( name ) ;
}
const NON _STATIC _PROPERTIES = [ 'autofocus' , 'muted' , 'defaultValue' , 'defaultChecked' ] ;
const NON _STATIC _PROPERTIES = new Set ( [ 'autofocus' , 'muted' , 'defaultValue' , 'defaultChecked' ] ) ;
/ * *
* Returns ` true ` if the given attribute cannot be set through the template
@ -246,7 +246,7 @@ const NON_STATIC_PROPERTIES = ['autofocus', 'muted', 'defaultValue', 'defaultChe
* @ param { string } name
* /
export function cannot _be _set _statically ( name ) {
return NON _STATIC _PROPERTIES . include s( name ) ;
return NON _STATIC _PROPERTIES . ha s( name ) ;
}
/ * *
@ -258,24 +258,24 @@ export function cannot_be_set_statically(name) {
* - they apply to mobile which is generally less performant
* we ' re marking them as passive by default for other elements , too .
* /
const PASSIVE _EVENTS = [ 'touchstart' , 'touchmove' ] ;
const PASSIVE _EVENTS = new Set ( [ 'touchstart' , 'touchmove' ] ) ;
/ * *
* Returns ` true ` if ` name ` is a passive event
* @ param { string } name
* /
export function is _passive _event ( name ) {
return PASSIVE _EVENTS . include s( name ) ;
return PASSIVE _EVENTS . ha s( name ) ;
}
const CONTENT _EDITABLE _BINDINGS = [ 'textContent' , 'innerHTML' , 'innerText' ] ;
const CONTENT _EDITABLE _BINDINGS = new Set ( [ 'textContent' , 'innerHTML' , 'innerText' ] ) ;
/** @param {string} name */
export function is _content _editable _binding ( name ) {
return CONTENT _EDITABLE _BINDINGS . include s( name ) ;
return CONTENT _EDITABLE _BINDINGS . ha s( name ) ;
}
const LOAD _ERROR _ELEMENTS = [
const LOAD _ERROR _ELEMENTS = new Set ( [
'body' ,
'embed' ,
'iframe' ,
@ -285,17 +285,17 @@ const LOAD_ERROR_ELEMENTS = [
'script' ,
'style' ,
'track'
] ;
] ) ;
/ * *
* Returns ` true ` if the element emits ` load ` and ` error ` events
* @ param { string } name
* /
export function is _load _error _element ( name ) {
return LOAD _ERROR _ELEMENTS . include s( name ) ;
return LOAD _ERROR _ELEMENTS . ha s( name ) ;
}
const SVG _ELEMENTS = [
const SVG _ELEMENTS = new Set ( [
'altGlyph' ,
'altGlyphDef' ,
'altGlyphItem' ,
@ -382,14 +382,14 @@ const SVG_ELEMENTS = [
'use' ,
'view' ,
'vkern'
] ;
] ) ;
/** @param {string} name */
export function is _svg ( name ) {
return SVG _ELEMENTS . include s( name ) ;
return SVG _ELEMENTS . ha s( name ) ;
}
const MATHML _ELEMENTS = [
const MATHML _ELEMENTS = new Set ( [
'annotation' ,
'annotation-xml' ,
'maction' ,
@ -420,64 +420,64 @@ const MATHML_ELEMENTS = [
'munder' ,
'munderover' ,
'semantics'
] ;
] ) ;
/** @param {string} name */
export function is _mathml ( name ) {
return MATHML _ELEMENTS . include s( name ) ;
return MATHML _ELEMENTS . ha s( name ) ;
}
const STATE _CREATION _RUNES = /** @type {const} */ ( [
'$state' ,
'$state.raw' ,
'$derived' ,
'$derived.by'
] ) ;
const RUNES = /** @type {const} */ ( [
... STATE _CREATION _RUNES ,
'$ state.eager ',
'$state.snapshot ',
'$props ',
'$props.id ',
'$bindabl e',
'$effect ',
'$effect.pre ',
'$effect.track ing',
'$effect.roo t',
'$effect.pending ',
'$inspect ',
'$inspect().with' ,
'$inspect.trace' ,
'$host'
] ) ;
/** @typedef {typeof RUNES[number]} RuneName */
const STATE _CREATION _RUNES = new Set (
/** @type {const} */ ( [ '$state' , '$state.raw' , '$derived' , '$derived.by' ] )
) ;
const RUNES = new Set (
/** @type {const} */ ( [
... STATE _CREATION _RUNES ,
'$state.eager' ,
'$state.snapshot' ,
'$ prop s',
'$props.id ',
'$bindable ',
'$effect ',
'$effect.pr e',
'$effect .tracking ',
'$effect.root ',
'$effect.pend ing',
'$inspec t',
'$inspect().with ',
'$inspect .trace ',
'$host'
] )
) ;
/** @typedef {typeof RUNES extends Set<infer T> ? T : never} RuneName */
/** @typedef {typeof STATE_CREATION_RUNES extends Set<infer T> ? T : never} StateCreation RuneName */
/ * *
* @ param { string } name
* @ returns { name is RuneName }
* /
export function is _rune ( name ) {
return RUNES . include s( /** @type {RuneName} */ ( name ) ) ;
return RUNES . ha s( /** @type {RuneName} */ ( name ) ) ;
}
/** @typedef {typeof STATE_CREATION_RUNES[number]} StateCreationRuneName */
/ * *
* @ param { string } name
* @ returns { name is StateCreationRuneName }
* /
export function is _state _creation _rune ( name ) {
return STATE _CREATION _RUNES . include s( /** @type {StateCreationRuneName} */ ( name ) ) ;
return STATE _CREATION _RUNES . ha s( /** @type {StateCreationRuneName} */ ( name ) ) ;
}
/** List of elements that require raw contents and should not have SSR comments put in them */
const RAW _TEXT _ELEMENTS = /** @type {const} */ ( [ 'textarea' , 'script' , 'style' , 'title' ] ) ;
/** Elements that require raw contents and should not have SSR comments put in them */
const RAW _TEXT _ELEMENTS = new Set ( /** @type {const} */ ( [ 'textarea' , 'script' , 'style' , 'title' ] ) ) ;
/** @typedef {typeof RAW_TEXT_ELEMENTS extends Set<infer T> ? T : never} RawTextElement */
/** @param {string} name */
export function is _raw _text _element ( name ) {
return RAW _TEXT _ELEMENTS . includes( /** @type {typeof RAW_TEXT_ELEMENTS[number] } */ ( name ) ) ;
return RAW _TEXT _ELEMENTS . has( /** @type {RawTextElement } */ ( name ) ) ;
}
// Matches valid HTML/SVG/MathML element names and custom element names.