pull/15961/head
Rich Harris 4 months ago
parent 5876ef7102
commit eaf9e5eee4

@ -478,8 +478,8 @@ export function attribute_effect(
) { ) {
const deriveds = thunks.map(d); const deriveds = thunks.map(d);
/** @type {Record<string | symbol, any>} */ /** @type {Record<string | symbol, any> | undefined} */
var prev = {}; var prev = undefined;
/** @type {Record<symbol, Effect>} */ /** @type {Record<symbol, Effect>} */
var effects = {}; var effects = {};
@ -503,7 +503,7 @@ export function attribute_effect(
for (let symbol of Object.getOwnPropertySymbols(next)) { for (let symbol of Object.getOwnPropertySymbols(next)) {
var n = next[symbol]; var n = next[symbol];
if (symbol.description === ATTACHMENT_KEY && n !== prev[symbol]) { if (symbol.description === ATTACHMENT_KEY && (!prev || n !== prev[symbol])) {
if (effects[symbol]) destroy_effect(effects[symbol]); if (effects[symbol]) destroy_effect(effects[symbol]);
effects[symbol] = branch(() => attach(element, () => n)); effects[symbol] = branch(() => attach(element, () => n));
} }
@ -513,7 +513,10 @@ export function attribute_effect(
}); });
if (is_select) { if (is_select) {
init_select(/** @type {HTMLSelectElement} */ (element), () => prev.value); init_select(
/** @type {HTMLSelectElement} */ (element),
() => /** @type {Record<string | symbol, any>} */ (prev).value
);
} }
inited = true; inited = true;

Loading…
Cancel
Save