|
|
|
@ -89,7 +89,7 @@ export class Renderer {
|
|
|
|
* State that is local to the branch it is declared in.
|
|
|
|
* State that is local to the branch it is declared in.
|
|
|
|
* It will be shallow-copied to all children.
|
|
|
|
* It will be shallow-copied to all children.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @type {{ select_value: any, select_default_multiple: boolean }}
|
|
|
|
* @type {{ select_value: any, multiple: boolean }}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
local;
|
|
|
|
local;
|
|
|
|
|
|
|
|
|
|
|
|
@ -101,9 +101,7 @@ export class Renderer {
|
|
|
|
this.#parent = parent;
|
|
|
|
this.#parent = parent;
|
|
|
|
|
|
|
|
|
|
|
|
this.global = global;
|
|
|
|
this.global = global;
|
|
|
|
this.local = parent
|
|
|
|
this.local = parent ? { ...parent.local } : { select_value: undefined, multiple: false };
|
|
|
|
? { ...parent.local }
|
|
|
|
|
|
|
|
: { select_value: undefined, select_default_multiple: false };
|
|
|
|
|
|
|
|
this.type = parent ? parent.type : 'body';
|
|
|
|
this.type = parent ? parent.type : 'body';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -346,8 +344,7 @@ export class Renderer {
|
|
|
|
this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
|
|
|
|
this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
|
|
|
|
this.child((renderer) => {
|
|
|
|
this.child((renderer) => {
|
|
|
|
renderer.local.select_value = value === undefined ? defaultValue : value;
|
|
|
|
renderer.local.select_value = value === undefined ? defaultValue : value;
|
|
|
|
renderer.local.select_default_multiple =
|
|
|
|
renderer.local.multiple = !!select_attrs.multiple;
|
|
|
|
value === undefined && Boolean(select_attrs.multiple);
|
|
|
|
|
|
|
|
fn(renderer);
|
|
|
|
fn(renderer);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.push(`${is_rich ? '<!>' : ''}</select>`);
|
|
|
|
this.push(`${is_rich ? '<!>' : ''}</select>`);
|
|
|
|
@ -375,10 +372,14 @@ export class Renderer {
|
|
|
|
value = attrs.value;
|
|
|
|
value = attrs.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var select_value = this.local.select_value;
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
this.local.select_default_multiple
|
|
|
|
// Super edge-case, but theoretically someone could use arrays with non-multiple selects,
|
|
|
|
? is_array(this.local.select_value) && this.local.select_value.includes(value)
|
|
|
|
// so we gotta check for the multiple attribute presence, too.
|
|
|
|
: value === this.local.select_value
|
|
|
|
this.local.multiple && is_array(select_value)
|
|
|
|
|
|
|
|
? select_value.includes(value)
|
|
|
|
|
|
|
|
: value === select_value
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
renderer.#out.push(' selected=""');
|
|
|
|
renderer.#out.push(' selected=""');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|