@@ -12,7 +12,7 @@ import { add_form_reset_listener, autofocus } from './misc.js';
12
12
import { effect , effect_root } from '../../reactivity/effects.js' ;
13
13
import * as w from '../../warnings.js' ;
14
14
import { LOADING_ATTR_SYMBOL } from '../../constants.js' ;
15
- import { queue_idle_task } from '../task.js' ;
15
+ import { queue_idle_task , queue_micro_task } from '../task.js' ;
16
16
17
17
/**
18
18
* The value/checked attribute in the template actually corresponds to the defaultValue property, so we need
@@ -262,21 +262,13 @@ export function set_attributes(element, prev, next, lowercase_attributes, css_ha
262
262
// On the first run, ensure that events are added after bindings so
263
263
// that their listeners fire after the binding listeners
264
264
if ( ! prev ) {
265
- // In edge cases it may happen that set_attributes is re-run before the
266
- // effect is executed. In that case the render effect which initiates this
267
- // re-run will destroy the inner effect and it will never run. But because
268
- // next and prev may have the same keys, the event would not get added again
269
- // and it would get lost. We prevent this by using a root effect.
270
- const destroy_root = effect_root ( ( ) => {
271
- effect ( ( ) => {
272
- if ( ! element . isConnected ) return ;
273
- for ( const [ key , value , evt ] of events ) {
274
- if ( current [ key ] === value ) {
275
- evt ( ) ;
276
- }
265
+ queue_micro_task ( ( ) => {
266
+ if ( ! element . isConnected ) return ;
267
+ for ( const [ key , value , evt ] of events ) {
268
+ if ( current [ key ] === value ) {
269
+ evt ( ) ;
277
270
}
278
- destroy_root ( ) ;
279
- } ) ;
271
+ }
280
272
} ) ;
281
273
}
282
274
0 commit comments