pull/16251/head
Rich Harris 3 months ago
parent 58918e38e9
commit 38d458a01b

@ -515,11 +515,10 @@ export function attribute_effect(
if (is_select) {
var select = /** @type {HTMLSelectElement} */ (element);
queue_micro_task(() => {
effect(() => {
select_option(select, /** @type {Record<string | symbol, any>} */ (prev).value);
});
init_select(select);
});
}
inited = true;

@ -1,4 +1,4 @@
import { effect } from '../../../reactivity/effects.js';
import { effect, teardown } from '../../../reactivity/effects.js';
import { listen_to_event_and_reset_event } from './shared.js';
import { is } from '../../../proxy.js';
import { is_array } from '../../../../shared/utils.js';
@ -54,11 +54,9 @@ export function select_option(select, value, mounting) {
* @param {HTMLSelectElement} select
*/
export function init_select(select) {
queue_micro_task(() => {
var observer = new MutationObserver(() => {
// @ts-ignore
var value = select.__value;
select_option(select, value);
select_option(select, select.__value);
// Deliberately don't update the potential binding value,
// the model should be preserved unless explicitly changed
});
@ -74,9 +72,8 @@ export function init_select(select) {
attributeFilter: ['value']
});
return () => {
teardown(() => {
observer.disconnect();
};
});
}
@ -128,7 +125,6 @@ export function bind_select_value(select, get, set = get) {
mounting = false;
});
// don't pass get_value, we already initialize it in the effect above
init_select(select);
}

Loading…
Cancel
Save