revert strict dom check

fix-15337
7nik 1 month ago
parent 1bf68d8ce4
commit 62bf167f53

@ -6,7 +6,6 @@ import { is_event_attribute, is_text_attribute } from '../../../../../utils/ast.
import * as b from '#compiler/builders';
import { is_custom_element_node } from '../../../../nodes.js';
import { build_template_chunk } from './utils.js';
import { ELEMENT_NODE, TEXT_NODE } from '#client/constants';
/**
* Processes an array of template nodes, joining sibling text/expression nodes
@ -26,11 +25,8 @@ export function process_children(nodes, initial, is_element, context) {
/** @type {Sequence} */
let sequence = [];
/**
* @param {boolean} is_text
* @param {number} node_type
**/
function get_node(is_text, node_type) {
/** @param {boolean} is_text */
function get_node(is_text) {
if (skipped === 0) {
return prev(is_text);
}
@ -38,7 +34,6 @@ export function process_children(nodes, initial, is_element, context) {
return b.call(
'$.sibling',
prev(false),
b.literal(node_type),
(is_text || skipped !== 1) && b.literal(skipped),
is_text && b.true
);
@ -49,10 +44,7 @@ export function process_children(nodes, initial, is_element, context) {
* @param {string} name
*/
function flush_node(is_text, name) {
const expression = get_node(
is_text,
name === 'text' ? TEXT_NODE : name === 'node' ? 0 : ELEMENT_NODE
);
const expression = get_node(is_text);
let id = expression;
if (id.type !== 'Identifier') {

@ -3,11 +3,9 @@ import { hydrate_node, hydrating, set_hydrate_node } from './hydration.js';
import { DEV } from 'esm-env';
import { init_array_prototype_warnings } from '../dev/equality.js';
import { get_descriptor, is_extensible } from '../../shared/utils.js';
import { COMMENT_NODE, TEXT_NODE, EFFECT_RAN } from '#client/constants';
import { HYDRATION_END, HYDRATION_ERROR } from '../../../constants.js';
import { hydration_mismatch } from '../warnings.js';
import { active_effect } from '../runtime.js';
import { async_mode_flag } from '../../flags/index.js';
import { TEXT_NODE, EFFECT_RAN } from '#client/constants';
// export these for reference in the compiled code, making global name deduplication unnecessary
/** @type {Window} */
@ -162,40 +160,26 @@ export function first_child(fragment, is_text) {
/**
* Don't mark this as side-effect-free, hydration needs to walk all nodes
* @param {TemplateNode} node
* @param {number} node_type
* @param {number} count
* @param {boolean} add_text
* @param {boolean} is_text
* @returns {Node | null}
*/
export function sibling(node, node_type, count = 1, add_text = false) {
var next_sibling = hydrating ? hydrate_node : node;
export function sibling(node, count = 1, is_text = false) {
let next_sibling = hydrating ? hydrate_node : node;
var last_sibling;
while (count--) {
last_sibling = next_sibling;
next_sibling = /** @type {TemplateNode} */ (get_next_sibling(next_sibling));
if (
(next_sibling === null && !add_text) ||
(next_sibling?.nodeType === COMMENT_NODE &&
/** @type {Comment} */ (next_sibling).data === HYDRATION_END)
) {
hydration_mismatch();
throw HYDRATION_ERROR;
}
}
if (!hydrating) {
return next_sibling;
}
if (hydrating && node_type !== 0 && !add_text && next_sibling?.nodeType !== node_type) {
hydration_mismatch();
throw HYDRATION_ERROR;
}
// if a sibling {expression} is empty during SSR, there might be no
// text node to hydrate — we must therefore create one
if (add_text && next_sibling?.nodeType !== TEXT_NODE) {
if (is_text && next_sibling?.nodeType !== TEXT_NODE) {
var text = create_text();
// If the next sibling is `null` and we're handling text then it's because
// the SSR content was empty for the text, so we need to generate a new text
@ -210,7 +194,7 @@ export function sibling(node, node_type, count = 1, add_text = false) {
}
set_hydrate_node(next_sibling);
return next_sibling;
return /** @type {TemplateNode} */ (next_sibling);
}
/**

@ -19,11 +19,11 @@ export default function Await_block_scope($$anchor) {
$.reset(button);
var node = $.sibling(button, 0, 2);
var node = $.sibling(button, 2);
$.await(node, () => $.get(promise), null, ($$anchor, counter) => {});
var text_1 = $.sibling(node, 3);
var text_1 = $.sibling(node);
$.template_effect(() => {
$.set_text(text, `clicks: ${counter.count ?? ''}`);

@ -28,7 +28,7 @@ export default function Bind_component_snippet($$anchor) {
}
});
var text_1 = $.sibling(node, 3);
var text_1 = $.sibling(node);
$.template_effect(() => $.set_text(text_1, ` value: ${$.get(value) ?? ''}`));
$.append($$anchor, fragment);

@ -13,17 +13,17 @@ export default function Main($$anchor) {
$.set_attribute(div, 'foobar', x);
var svg = $.sibling(div, 1, 2);
var svg = $.sibling(div, 2);
$.set_attribute(svg, 'viewBox', x);
var custom_element = $.sibling(svg, 1, 2);
var custom_element = $.sibling(svg, 2);
$.set_custom_element_data(custom_element, 'fooBar', x);
var div_1 = $.sibling(custom_element, 1, 2);
var svg_1 = $.sibling(div_1, 1, 2);
var custom_element_1 = $.sibling(svg_1, 1, 2);
var div_1 = $.sibling(custom_element, 2);
var svg_1 = $.sibling(div_1, 2);
var custom_element_1 = $.sibling(svg_1, 2);
$.template_effect(() => $.set_custom_element_data(custom_element_1, 'fooBar', y()));

@ -12,11 +12,11 @@ export default function Nullish_coallescence_omittance($$anchor) {
h1.textContent = 'Hello, world!';
var b = $.sibling(h1, 1, 2);
var b = $.sibling(h1, 2);
b.textContent = '123';
var button = $.sibling(b, 1, 2);
var button = $.sibling(b, 2);
button.__click = [on_click, count];
@ -24,7 +24,7 @@ export default function Nullish_coallescence_omittance($$anchor) {
$.reset(button);
var h1_1 = $.sibling(button, 1, 2);
var h1_1 = $.sibling(button, 2);
h1_1.textContent = 'Hello, world';
$.template_effect(() => $.set_text(text, `Count is ${$.get(count) ?? ''}`));

@ -10,11 +10,11 @@ export default function Purity($$anchor) {
p.textContent = '0';
var p_1 = $.sibling(p, 1, 2);
var p_1 = $.sibling(p, 2);
p_1.textContent = location.href;
var node = $.sibling(p_1, 0, 2);
var node = $.sibling(p_1, 2);
Child(node, { prop: encodeURIComponent('hello') });
$.append($$anchor, fragment);

@ -5,43 +5,43 @@ var root = $.from_html(`<header><nav><a href="/">Home</a> <a href="/away">Away</
export default function Skip_static_subtree($$anchor, $$props) {
var fragment = root();
var main = $.sibling($.first_child(fragment), 1, 2);
var main = $.sibling($.first_child(fragment), 2);
var h1 = $.child(main);
var text = $.child(h1, true);
$.reset(h1);
var node = $.sibling(h1, 0, 10);
var node = $.sibling(h1, 10);
$.html(node, () => $$props.content);
$.next(14);
$.reset(main);
var cant_skip = $.sibling(main, 1, 2);
var cant_skip = $.sibling(main, 2);
var custom_elements = $.child(cant_skip);
$.set_custom_element_data(custom_elements, 'with', 'attributes');
$.reset(cant_skip);
var div = $.sibling(cant_skip, 1, 2);
var div = $.sibling(cant_skip, 2);
var input = $.child(div);
$.autofocus(input, true);
$.reset(div);
var div_1 = $.sibling(div, 1, 2);
var div_1 = $.sibling(div, 2);
var source = $.child(div_1);
source.muted = true;
$.reset(div_1);
var select = $.sibling(div_1, 1, 2);
var select = $.sibling(div_1, 2);
var option = $.child(select);
option.value = option.__value = 'a';
$.reset(select);
var img = $.sibling(select, 1, 2);
var img = $.sibling(select, 2);
$.next(2);
$.template_effect(() => $.set_text(text, $$props.title));

@ -18,11 +18,11 @@ export default function State_proxy_literal($$anchor) {
$.remove_input_defaults(input);
var input_1 = $.sibling(input, 1, 2);
var input_1 = $.sibling(input, 2);
$.remove_input_defaults(input_1);
var button = $.sibling(input_1, 1, 2);
var button = $.sibling(input_1, 2);
button.__click = [reset, str, tpl];
$.bind_value(input, () => $.get(str), ($$value) => $.set(str, $$value));

Loading…
Cancel
Save