pull/16797/head
Rich Harris 6 days ago
parent 6eac9ed41e
commit 31d326451e

@ -137,14 +137,7 @@ export function RegularElement(node, context) {
return;
}
if (
node.name === 'option' &&
!node.attributes.some(
(attribute) =>
(attribute.type === 'Attribute' && attribute.name === 'value') ||
attribute.type === 'SpreadAttribute'
)
) {
if (node.name === 'option') {
const attributes = build_spread_object(
node,
node.attributes.filter(

@ -212,26 +212,6 @@ export function build_element_attributes(node, context, transform) {
context,
transform
);
if (node.name === 'option') {
// TODO this is all wrong, it inlines the spread twice
const object = build_spread_object(
node,
node.attributes.filter(
(attribute) =>
attribute.type === 'Attribute' ||
attribute.type === 'BindDirective' ||
attribute.type === 'SpreadAttribute'
),
context,
transform
);
context.state.template.push(
b.call('$.maybe_selected', b.id('$$renderer'), b.member(object, 'value', false, true))
);
}
} else {
const css_hash = node.metadata.scoped ? context.state.analysis.css.hash : null;
@ -267,16 +247,6 @@ export function build_element_attributes(node, context, transform) {
);
}
if (node.name === 'option' && name === 'value') {
context.state.template.push(
b.call(
'$.maybe_selected',
b.id('$$renderer'),
literal_value != null ? b.literal(/** @type {any} */ (literal_value)) : b.void0
)
);
}
continue;
}
@ -304,10 +274,6 @@ export function build_element_attributes(node, context, transform) {
b.call('$.attr', b.literal(name), value, is_boolean_attribute(name) && b.true)
);
}
if (name === 'value' && node.name === 'option') {
context.state.template.push(b.call('$.maybe_selected', b.id('$$renderer'), value));
}
}
}

@ -494,15 +494,6 @@ export function derived(fn) {
};
}
/**
*
* @param {Renderer} renderer
* @param {unknown} value
*/
export function maybe_selected(renderer, value) {
return value === renderer.local.select_value ? ' selected' : '';
}
/**
* Since your document can only have one `title`, we have to have some sort of algorithm for determining
* which one "wins". To do this, we perform a depth-first comparison of where the title was encountered --

@ -3,5 +3,11 @@ import * as $ from 'svelte/internal/server';
export default function Skip_static_subtree($$renderer, $$props) {
let { title, content } = $$props;
$$renderer.push(`<header><nav><a href="/">Home</a> <a href="/away">Away</a></nav></header> <main><h1>${$.escape(title)}</h1> <div class="static"><p>we don't need to traverse these nodes</p></div> <p>or</p> <p>these</p> <p>ones</p> ${$.html(content)} <p>these</p> <p>trailing</p> <p>nodes</p> <p>can</p> <p>be</p> <p>completely</p> <p>ignored</p></main> <cant-skip><custom-elements with="attributes"></custom-elements></cant-skip> <div><input autofocus/></div> <div><source muted/></div> <select><option value="a"${$.maybe_selected($$renderer, 'a')}>a</option></select> <img src="..." alt="" loading="lazy"/> <div><img src="..." alt="" loading="lazy"/></div>`);
$$renderer.push(`<header><nav><a href="/">Home</a> <a href="/away">Away</a></nav></header> <main><h1>${$.escape(title)}</h1> <div class="static"><p>we don't need to traverse these nodes</p></div> <p>or</p> <p>these</p> <p>ones</p> ${$.html(content)} <p>these</p> <p>trailing</p> <p>nodes</p> <p>can</p> <p>be</p> <p>completely</p> <p>ignored</p></main> <cant-skip><custom-elements with="attributes"></custom-elements></cant-skip> <div><input autofocus/></div> <div><source muted/></div> <select>`);
$$renderer.option({ value: 'a' }, ($$renderer) => {
$$renderer.push(`a`);
});
$$renderer.push(`</select> <img src="..." alt="" loading="lazy"/> <div><img src="..." alt="" loading="lazy"/></div>`);
}
Loading…
Cancel
Save