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

@ -665,10 +665,6 @@ function build_element_special_value_attribute(element, node_id, attribute, cont
: inner_assignment
);
if (is_select_with_value) {
state.init.push(b.stmt(b.call('$.init_select', node_id)));
}
if (has_state) {
const id = b.id(state.scope.generate(`${node_id.name}_value`));
@ -682,4 +678,8 @@ function build_element_special_value_attribute(element, node_id, attribute, cont
} else {
state.init.push(update);
}
if (is_select_with_value) {
state.init.push(b.stmt(b.call('$.init_select', node_id)));
}
}

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

@ -1,9 +1,9 @@
import { effect } from '../../../reactivity/effects.js';
import { listen_to_event_and_reset_event } from './shared.js';
import { untrack } from '../../../runtime.js';
import { is } from '../../../proxy.js';
import { is_array } from '../../../../shared/utils.js';
import * as w from '../../../warnings.js';
import { queue_micro_task } from '../../task.js';
/**
* Selects the correct option(s) (depending on whether this is a multiple select)
@ -51,11 +51,10 @@ export function select_option(select, value, mounting) {
* current selection to the dom when it changes. Such
* changes could for example occur when options are
* inside an `#each` block.
* @template V
* @param {HTMLSelectElement} select
*/
export function init_select(select) {
effect(() => {
queue_micro_task(() => {
var observer = new MutationObserver(() => {
// @ts-ignore
var value = select.__value;

Loading…
Cancel
Save