@ -3,6 +3,7 @@
/** @import { ComponentContext } from '../../types' */
import { is _event _attribute , is _text _attribute } from '../../../../../utils/ast.js' ;
import * as b from '../../../../../utils/builders.js' ;
import { is _inlinable _expression } from '../../utils.js' ;
import { build _template _literal , build _update } from './utils.js' ;
/ * *
@ -97,7 +98,7 @@ export function process_children(nodes, initial, is_element, { visit, state }) {
let child _state = state ;
if ( is _static _element ( node )) {
if ( is _static _element ( node , state )) {
skipped += 1 ;
} else if ( node . type === 'EachBlock' && nodes . length === 1 && is _element ) {
node . metadata . is _controlled = true ;
@ -124,10 +125,12 @@ export function process_children(nodes, initial, is_element, { visit, state }) {
/ * *
* @ param { SvelteNode } node
* @ param { ComponentContext [ "state" ] } state
* /
function is _static _element ( node ) {
function is _static _element ( node , state ) {
if ( node . type !== 'RegularElement' ) return false ;
if ( node . fragment . metadata . dynamic ) return false ;
if ( node . name . includes ( '-' ) ) return false ; // we're setting all attributes on custom elements through properties
for ( const attribute of node . attributes ) {
if ( attribute . type !== 'Attribute' ) {
@ -138,10 +141,6 @@ function is_static_element(node) {
return false ;
}
if ( attribute . value !== true && ! is _text _attribute ( attribute ) ) {
return false ;
}
if ( attribute . name === 'autofocus' || attribute . name === 'muted' ) {
return false ;
}
@ -155,8 +154,14 @@ function is_static_element(node) {
return false ;
}
if ( node . name . includes ( '-' ) ) {
return false ; // we're setting all attributes on custom elements through properties
if (
attribute . value !== true &&
! is _text _attribute ( attribute ) &&
// If the attribute is not a text attribute but is inlinable we will directly inline it in the
// the template so before returning false we need to check that the attribute is not inlinable
! is _inlinable _expression ( attribute . value , state )
) {
return false ;
}
}