adjust-boundary-error-message
S. Elliott Johnson 2 weeks ago
parent ba95b56c69
commit 9802fd460a

@ -199,7 +199,7 @@ export function server_component(analysis, options) {
b.stmt(b.call('$$render_inner', b.id('$$inner_payload')))
])
),
b.stmt(b.call('$.assign_payload', b.id('$$payload'), b.id('$$inner_payload')))
b.stmt(b.call('$$payload.subsume', b.id('$$inner_payload')))
];
}

@ -513,8 +513,6 @@ export { push, pop } from './context.js';
export { push_element, pop_element, validate_snippet_args } from './dev.js';
export { assign_payload } from './payload.js';
export { snapshot } from '../shared/clone.js';
export { fallback, to_array } from '../shared/utils.js';
@ -573,28 +571,21 @@ export function valueless_option(payload, children) {
// post-children, `payload` has child content, possibly also with some number of hydration comments.
// we can compact this last chunk of content to see if it matches the select value...
let match = false;
payload.compact({
start: i,
fn: (body) => {
if (body.replace(/<!---->/g, '') === payload.select_value) {
match = true;
// ...and if it does match the select value, we can compact the part of the payload representing the `<option ...>`
// to add the `selected` attribute to the end.
payload.compact({
start: i - 1,
end: i,
fn: (body) => {
return body.slice(0, -1) + ' selected>';
}
});
}
return body;
}
});
if (!match) {
return;
}
// ...and if it does match the select value, we can compact the part of the payload representing the `<option ...>`
// to add the `selected` attribute to the end.
payload.compact({
start: i - 1,
end: i,
fn: (body) => {
return body.slice(0, -1) + ' selected>';
}
});
}

@ -194,6 +194,18 @@ export class HeadPayload extends BasePayload {
head_payload.out = [...this.out];
return head_payload;
}
/**
* @param {HeadPayload} other
*/
subsume(other) {
// @ts-expect-error
this.out = [...other.out];
this.promise = other.promise;
this.#css = other.#css;
this.#title = other.#title;
this.#uid = other.#uid;
}
}
/**
@ -250,29 +262,18 @@ export class Payload extends BasePayload {
payload.out = [...this.out];
return payload;
}
}
/**
* Assigns second payload to first -- legacy nonsense
* @param {Payload} p1
* @param {Payload} p2
* @returns {void}
*/
export function assign_payload(p1, p2) {
p1.out = [...p2.out];
p1.promise = p2.promise;
p1.css.clear();
for (const entry of p2.css) {
p1.css.add(entry);
}
p1.head.out = [...p2.head.out];
p1.head.promise = p2.head.promise;
p1.head.css.clear();
for (const entry of p2.head.css) {
p1.head.css.add(entry);
/**
* @param {Payload} other
*/
subsume(other) {
// @ts-expect-error
this.out = [...other.out];
this.promise = other.promise;
this.#css = other.#css;
this.#uid = other.#uid;
this.#head.subsume(other.#head);
}
p1.head.title.value = p2.head.title.value;
}
/**

@ -31,10 +31,10 @@ export default function Bind_component_snippet($$payload) {
do {
$$settled = true;
$$inner_payload = $.copy_payload($$payload);
$$inner_payload = $$payload.copy();
$$render_inner($$inner_payload);
} while (!$$settled);
$.assign_payload($$payload, $$inner_payload);
$$payload.subsume($$inner_payload);
});
}
Loading…
Cancel
Save