Skip to content

Commit f2d8d80

Browse files
committed
more
1 parent 0105378 commit f2d8d80

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

packages/svelte/src/internal/client/dom/elements/attributes.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { add_form_reset_listener, autofocus } from './misc.js';
1212
import { effect, effect_root } from '../../reactivity/effects.js';
1313
import * as w from '../../warnings.js';
1414
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';
1616

1717
/**
1818
* 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
262262
// On the first run, ensure that events are added after bindings so
263263
// that their listeners fire after the binding listeners
264264
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();
277270
}
278-
destroy_root();
279-
});
271+
}
280272
});
281273
}
282274

0 commit comments

Comments
 (0)