@ -310,211 +310,225 @@ function set_attributes(
var is _option _element = node _name ( element ) === OPTION _TAG ;
var is _option _element = node _name ( element ) === OPTION _TAG ;
var is _select _element = node _name ( element ) === SELECT _TAG ;
var is _select _element = node _name ( element ) === SELECT _TAG ;
for ( var key in prev ) {
try {
// don't null our internal $$onX listeners
for ( var key in prev ) {
if ( ! ( key in next ) && key [ 0 ] + key [ 1 ] !== '$$' ) {
// don't null our internal $$onX listeners
next [ key ] = null ;
if ( ! ( key in next ) && key [ 0 ] + key [ 1 ] !== '$$' ) {
next [ key ] = null ;
}
}
}
}
if ( next . class ) {
if ( next . class ) {
next . class = clsx ( next . class ) ;
next . class = clsx ( next . class ) ;
} else if ( css _hash || next [ CLASS ] ) {
} else if ( css _hash || next [ CLASS ] ) {
next . class = null ; /* force call to set_class() */
next . class = null ; /* force call to set_class() */
}
}
if ( next [ STYLE ] ) {
next . style ? ? = null ; /* force call to set_style() */
}
var setters = get _setters ( element ) ;
if ( next [ STYLE ] ) {
next . style ? ? = null ; /* force call to set_style() */
}
if (
var setters = get _setters ( element ) ;
// the following logic only make sense in a dev environment
current _renderer == null &&
node _name ( element ) === INPUT _TAG &&
'type' in next &&
( 'value' in next || '__value' in next )
) {
var type = next . type ;
if ( type !== current . type || ( type === undefined && element . hasAttribute ( 'type' ) ) ) {
if (
current . type = type ;
// the following logic only make sense in a dev environment
set _attribute ( element , 'type' , type , skip _warning ) ;
current _renderer == null &&
}
node _name ( element ) === INPUT _TAG &&
}
'type' in next &&
( 'value' in next || '__value' in next )
) {
var type = next . type ;
// since key is captured we use const
if ( type !== current . type || ( type === undefined && element . hasAttribute ( 'type' ) ) ) {
for ( const key in next ) {
current . type = type ;
// let instead of var because referenced in a closure
set _attribute ( element , 'type' , type , skip _warning ) ;
let value = next [ key ] ;
}
// Up here because we want to do this for the initial value, too, even if it's undefined,
// and this wouldn't be reached in case of undefined because of the equality check below
if ( is _option _element && key === 'value' && value == null ) {
// The <option> element is a special case because removing the value attribute means
// the value is set to the text content of the option element, and setting the value
// to null or undefined means the value is set to the string "null" or "undefined".
// To align with how we handle this case in non-spread-scenarios, this logic is needed.
// There's a super-edge-case bug here that is left in in favor of smaller code size:
// Because of the "set missing props to null" logic above, we can't differentiate
// between a missing value and an explicitly set value of null or undefined. That means
// that once set, the value attribute of an <option> element can't be removed. This is
// a very rare edge case, and removing the attribute altogether isn't possible either
// for the <option value={undefined}> case, so we're not losing any functionality here.
// @ts-ignore
element . value = element . _ _value = '' ;
current [ key ] = value ;
continue ;
}
}
if ( key === 'class' ) {
// since key is captured we use const
var is _html = current _renderer == null && element . namespaceURI === NAMESPACE _HTML ;
for ( const key in next ) {
set _class ( element , is _html , value , css _hash , prev ? . [ CLASS ] , next [ CLASS ] ) ;
// let instead of var because referenced in a closure
current [ key ] = value ;
let value = next [ key ] ;
current [ CLASS ] = next [ CLASS ] ;
continue ;
// Up here because we want to do this for the initial value, too, even if it's undefined,
}
// and this wouldn't be reached in case of undefined because of the equality check below
if ( is _option _element && key === 'value' && value == null ) {
// The <option> element is a special case because removing the value attribute means
// the value is set to the text content of the option element, and setting the value
// to null or undefined means the value is set to the string "null" or "undefined".
// To align with how we handle this case in non-spread-scenarios, this logic is needed.
// There's a super-edge-case bug here that is left in in favor of smaller code size:
// Because of the "set missing props to null" logic above, we can't differentiate
// between a missing value and an explicitly set value of null or undefined. That means
// that once set, the value attribute of an <option> element can't be removed. This is
// a very rare edge case, and removing the attribute altogether isn't possible either
// for the <option value={undefined}> case, so we're not losing any functionality here.
// @ts-ignore
element . value = element . _ _value = '' ;
current [ key ] = value ;
continue ;
}
if ( key === 'style' ) {
if ( key === 'class' ) {
set _style ( element , value , prev ? . [ STYLE ] , next [ STYLE ] ) ;
var is _html = current _renderer == null && element . namespaceURI === NAMESPACE _HTML ;
current [ key ] = value ;
set _class ( element , is _html , value , css _hash , prev ? . [ CLASS ] , next [ CLASS ] ) ;
current [ STYLE ] = next [ STYLE ] ;
current [ key ] = value ;
continue ;
current [ CLASS ] = next [ CLASS ] ;
}
continue ;
}
var prev _value = current [ key ] ;
if ( key === 'style' ) {
set _style ( element , value , prev ? . [ STYLE ] , next [ STYLE ] ) ;
current [ key ] = value ;
current [ STYLE ] = next [ STYLE ] ;
continue ;
}
// Skip if value is unchanged, unless it's `undefined` and the element still has the attribute
var prev _value = current [ key ] ;
if ( value === prev _value && ! ( value === undefined && has _attribute ( element , key ) ) ) {
continue ;
}
current [ key ] = value ;
// Skip if value is unchanged, unless it's `undefined` and the element still has the attribute
if ( value === prev _value && ! ( value === undefined && has _attribute ( element , key ) ) ) {
continue ;
}
var prefix = key [ 0 ] + key [ 1 ] ; // this is faster than key.slice(0, 2)
current [ key ] = value ;
if ( prefix === '$$' ) continue ;
if ( prefix === 'on' ) {
var prefix = key [ 0 ] + key [ 1 ] ; // this is faster than key.slice(0, 2)
/** @type {{ capture?: true }} */
if ( prefix === '$$' ) continue ;
const opts = { } ;
const event _handle _key = '$$' + key ;
let event _name = key . slice ( 2 ) ;
var is _delegated = current _renderer == null && can _delegate _event ( event _name ) ;
if ( is _capture _event ( event _name ) ) {
if ( prefix === 'on' ) {
event _name = event _name . slice ( 0 , - 7 ) ;
/** @type {{ capture?: true }} */
opts . capture = true ;
const opts = { } ;
}
const event _handle _key = '$$' + key ;
let event _name = key . slice ( 2 ) ;
var is _delegated = current _renderer == null && can _delegate _event ( event _name ) ;
if ( ! is _delegated && prev _value ) {
if ( is _capture _event ( event _name ) ) {
// Listening to same event but different handler -> our handle function below takes care of this
event _name = event _name . slice ( 0 , - 7 ) ;
// If we were to remove and add listeners in this case, it could happen that the event is "swallowed"
opts . capture = true ;
// (the browser seems to not know yet that a new one exists now) and doesn't reach the handler
}
// https://github.com/sveltejs/svelte/issues/11903
if ( value != null ) continue ;
remove _event _listener ( element , event _name , current [ event _handle _key ] , opts ) ;
if ( ! is _delegated && prev _value ) {
current [ event _handle _key ] = null ;
// Listening to same event but different handler -> our handle function below takes care of this
}
// If we were to remove and add listeners in this case, it could happen that the event is "swallowed"
// (the browser seems to not know yet that a new one exists now) and doesn't reach the handler
// https://github.com/sveltejs/svelte/issues/11903
if ( value != null ) continue ;
if ( is _delegated ) {
remove _event _listener ( element , event _name , current [ event _handle _key ] , opts ) ;
delegated ( event _name , element , value ) ;
current [ event _handle _key ] = null ;
delegate ( [ event _name ] ) ;
} else if ( value != null ) {
/ * *
* @ this { any }
* @ param { ... any } args
* /
function handle ( ... args ) {
current [ key ] . apply ( this , args ) ;
}
}
current [ event _handle _key ] = create _event ( event _name , element , handle , opts ) ;
if ( is _delegated ) {
}
delegated ( event _name , element , value ) ;
} else if ( key === 'style' ) {
delegate ( [ event _name ] ) ;
// avoid using the setter
} else if ( value != null ) {
set _attribute ( element , key , value ) ;
/ * *
} else if ( key === 'autofocus' ) {
* @ this { any }
if ( current _renderer == null ) {
* @ param { ... any } args
autofocus ( /** @type {HTMLElement} */ ( element ) , Boolean ( value ) ) ;
* /
} else {
function handle ( ... args ) {
// In custom renderer mode, just set autofocus as a regular attribute
current [ key ] . apply ( this , args ) ;
if ( value ) {
}
set _attribute _op ( element , key , value ) ;
current [ event _handle _key ] = create _event ( event _name , element , handle , opts ) ;
}
} else if ( key === 'style' ) {
// avoid using the setter
set _attribute ( element , key , value ) ;
} else if ( key === 'autofocus' ) {
if ( current _renderer == null ) {
autofocus ( /** @type {HTMLElement} */ ( element ) , Boolean ( value ) ) ;
} else {
} else {
remove _attribute ( element , key ) ;
// In custom renderer mode, just set autofocus as a regular attribute
if ( value ) {
set _attribute _op ( element , key , value ) ;
} else {
remove _attribute ( element , key ) ;
}
}
} else if ( ! is _custom _element && ( key === '__value' || ( key === 'value' && value != null ) ) ) {
// @ts-ignore We're not running this for custom elements because __value is actually
// how Lit stores the current value on the element, and messing with that would break things.
element . _ _value = value ;
// we don't set the value if it hasn't changed. This supports invalid number inputs like `1e` because
// 1. user types 1e
// 2. the state is updated reading e.target.value which is ''
// 3. the spreaded value is ''
// 4. updating input.value would thus, clear the user value
if (
prev _value == null ||
// @ts-ignore
element . value !== value ||
( value === 0 && element . nodeName === PROGRESS _TAG )
) {
set _element _value ( element , value ) ;
}
} else if ( key === 'selected' && is _option _element ) {
set _selected ( /** @type {HTMLOptionElement} */ ( element ) , value ) ;
} else {
var name = key ;
if ( ! preserve _attribute _case ) {
name = normalize _attribute ( name ) ;
}
}
}
} else if ( ! is _custom _element && ( key === '__value' || ( key === 'value' && value != null ) ) ) {
// @ts-ignore We're not running this for custom elements because __value is actually
// how Lit stores the current value on the element, and messing with that would break things.
element . _ _value = value ;
set _element _value ( element , value ) ;
} else if ( key === 'selected' && is _option _element ) {
set _selected ( /** @type {HTMLOptionElement} */ ( element ) , value ) ;
} else {
var name = key ;
if ( ! preserve _attribute _case ) {
name = normalize _attribute ( name ) ;
}
var is _default = name === 'defaultValue' || name === 'defaultChecked' ;
var is _default = name === 'defaultValue' || name === 'defaultChecked' ;
// A select's default value is represented by selected options, not a property.
// A select's default value is represented by selected options, not a property.
if ( is _select _element && name === 'defaultValue' ) continue ;
if ( is _select _element && name === 'defaultValue' ) continue ;
if ( value == null && ! is _custom _element && ! is _default ) {
if ( value == null && ! is _custom _element && ! is _default ) {
attributes [ key ] = null ;
attributes [ key ] = null ;
if ( ( name === 'value' || name === 'checked' ) && current _renderer == null ) {
if ( ( name === 'value' || name === 'checked' ) && current _renderer == null ) {
// removing value/checked also removes defaultValue/defaultChecked — preserve
// removing value/checked also removes defaultValue/defaultChecked — preserve
let input = /** @type {HTMLInputElement} */ ( element ) ;
let input = /** @type {HTMLInputElement} */ ( element ) ;
const use _default = prev === undefined ;
const use _default = prev === undefined ;
if ( name === 'value' ) {
if ( name === 'value' ) {
let previous = input . defaultValue ;
let previous = input . defaultValue ;
remove _attribute ( input , name ) ;
remove _attribute ( input , name ) ;
set _element _default _value ( input , previous ) ;
set _element _default _value ( input , previous ) ;
// @ts-ignore
// @ts-ignore
set _element _value ( input , ( input . _ _value = use _default ? previous : null ) ) ;
set _element _value ( input , ( input . _ _value = use _default ? previous : null ) ) ;
} else {
let previous = input . defaultChecked ;
remove _attribute ( input , name ) ;
set _element _default _checked ( input , previous ) ;
set _element _checked ( input , use _default ? previous : false ) ;
}
} else {
} else {
let previous = input . defaultChecked ;
remove _attribute ( element , key ) ;
remove _attribute ( input , name ) ;
if ( name === 'value' ) {
set _element _default _checked ( input , previous ) ;
// @ts-ignore
set _element _checked ( input , use _default ? previous : false ) ;
element . _ _value = null ;
}
}
}
} else {
} else if ( is _default && current _renderer != null ) {
remove _attribute ( element , key ) ;
// Route through the renderer-aware abstraction so custom renderers
if ( name === 'value' ) {
// see defaultValue/defaultChecked as proper attributes
// @ts-ignore
if ( name === 'defaultValue' ) {
element . _ _value = null ;
set _element _default _value ( element , value ) ;
} else {
set _element _default _checked ( element , value ) ;
}
}
// remove it from attributes's cache
if ( name in attributes ) attributes [ name ] = UNINITIALIZED ;
} else if (
is _default ||
( ( is _custom _element || typeof value !== 'string' ) && setters . has ( name ) )
) {
// @ts-ignore
element [ name ] = value ;
// remove it from attributes's cache
if ( name in attributes ) attributes [ name ] = UNINITIALIZED ;
} else if ( typeof value !== 'function' ) {
set _attribute ( element , name , value , skip _warning ) ;
}
}
} else if ( is _default && current _renderer != null ) {
// Route through the renderer-aware abstraction so custom renderers
// see defaultValue/defaultChecked as proper attributes
if ( name === 'defaultValue' ) {
set _element _default _value ( element , value ) ;
} else {
set _element _default _checked ( element , value ) ;
}
// remove it from attributes's cache
if ( name in attributes ) attributes [ name ] = UNINITIALIZED ;
} else if (
is _default ||
( ( is _custom _element || typeof value !== 'string' ) && setters . has ( name ) )
) {
// @ts-ignore
element [ name ] = value ;
// remove it from attributes's cache
if ( name in attributes ) attributes [ name ] = UNINITIALIZED ;
} else if ( typeof value !== 'function' ) {
set _attribute ( element , name , value , skip _warning ) ;
}
}
}
}
}
} finally {
if ( is _hydrating _custom _element ) {
if ( is _hydrating _custom _element ) {
set _hydrating ( true ) ;
set _hydrating ( true ) ;
}
}
}
return current ;
return current ;