tweak ("execute the child" is the sort of thing that gets you visited by the FBI)

pull/16017/head
Rich Harris 4 months ago
parent d40ad7555f
commit 9cd02ab5f0

@ -551,19 +551,14 @@ export function maybe_selected(payload, value) {
* @returns {void} * @returns {void}
*/ */
export function valueless_option(payload, children) { export function valueless_option(payload, children) {
// store the initial payload before rendering children var i = payload.out.length;
let i = payload.out.length;
// execute the child to get the runtime body of the option
children(); children();
// remove the initial payload and eventual hydration comments var body = payload.out.slice(i);
let body = payload.out.slice(i);
// check the value of the body with the select_value
if (body.replace(/<!---->/g, '') === payload.select_value) { if (body.replace(/<!---->/g, '') === payload.select_value) {
// substring the initial payload to remove the last character (the closing `>`) // replace '>' with ' selected>' (closing tag will be added later)
// append selected and the body (the closing tag will be added later)
payload.out = payload.out.slice(0, i - 1) + ' selected>' + body; payload.out = payload.out.slice(0, i - 1) + ' selected>' + body;
} }
} }

Loading…
Cancel
Save