Revert "chore: consistent nextSibling usage (#11694)" (#11696)

This reverts commit f3dbfc91d6.
pull/11602/merge
Rich Harris 2 months ago committed by GitHub
parent f3dbfc91d6
commit 43d2f750b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -9,7 +9,7 @@ import {
HYDRATION_START
} from '../../../../constants.js';
import { hydrate_anchor, hydrate_nodes, hydrating, set_hydrating } from '../hydration.js';
import { clear_text_content, empty, next_sibling } from '../operations.js';
import { clear_text_content, empty } from '../operations.js';
import { remove } from '../reconciler.js';
import { untrack } from '../../runtime.js';
import {
@ -175,7 +175,7 @@ export function each(anchor, flags, get_collection, get_key, render_fn, fallback
var key = get_key(value, i);
item = create_item(child_open, child_anchor, prev, null, value, key, i, render_fn, flags);
state.items.set(key, item);
child_anchor = /** @type {Comment} */ (next_sibling(child_anchor));
child_anchor = /** @type {Comment} */ (child_anchor.nextSibling);
prev = item;
}
@ -183,7 +183,7 @@ export function each(anchor, flags, get_collection, get_key, render_fn, fallback
// remove excess nodes
if (length > 0) {
while (child_anchor !== anchor) {
var next = /** @type {import('#client').TemplateNode} */ (next_sibling(child_anchor));
var next = /** @type {import('#client').TemplateNode} */ (child_anchor.nextSibling);
/** @type {import('#client').TemplateNode} */ (child_anchor).remove();
child_anchor = next;
}
@ -501,7 +501,7 @@ function move(item, next, anchor) {
var node = /** @type {import('#client').TemplateNode} */ (item.o);
while (node !== end) {
var next_node = /** @type {import('#client').TemplateNode} */ (next_sibling(node));
var next_node = /** @type {import('#client').TemplateNode} */ (node.nextSibling);
dest.before(node);
node = next_node;
}

@ -1,7 +1,7 @@
import { hydrate_anchor, hydrate_nodes, hydrating, set_hydrate_nodes } from '../hydration.js';
import { empty, next_sibling } from '../operations.js';
import { empty } from '../operations.js';
import { block } from '../../reactivity/effects.js';
import { HYDRATION_START } from '../../../../constants.js';
import { HYDRATION_END, HYDRATION_START } from '../../../../constants.js';
/**
* @type {Node | undefined}
@ -37,11 +37,11 @@ export function head(render_fn) {
head_anchor.nodeType !== 8 ||
/** @type {Comment} */ (head_anchor).data !== HYDRATION_START
) {
head_anchor = /** @type {import('#client').TemplateNode} */ (next_sibling(head_anchor));
head_anchor = /** @type {import('#client').TemplateNode} */ (head_anchor.nextSibling);
}
head_anchor = /** @type {import('#client').TemplateNode} */ (hydrate_anchor(head_anchor));
head_anchor = /** @type {import('#client').TemplateNode} */ (next_sibling(head_anchor));
head_anchor = /** @type {import('#client').TemplateNode} */ (head_anchor.nextSibling);
} else {
anchor = document.head.appendChild(empty());
}

@ -1,7 +1,6 @@
import { DEV } from 'esm-env';
import { HYDRATION_END, HYDRATION_START, HYDRATION_ERROR } from '../../../constants.js';
import * as w from '../warnings.js';
import { next_sibling } from './operations.js';
/**
* Use this variable to guard everything related to hydration code so it can be treeshaken out
@ -50,7 +49,7 @@ export function hydrate_anchor(node) {
var nodes = [];
var depth = 0;
while ((current = next_sibling(/** @type {Node} */ (current))) !== null) {
while ((current = /** @type {Node} */ (current).nextSibling) !== null) {
if (current.nodeType === 8) {
var data = /** @type {Comment} */ (current).data;

@ -173,16 +173,6 @@ export function first_child(fragment, is_text) {
return hydrate_anchor(first_node);
}
/**
* @template {Node} N
* @param {N} node
* @returns {Node | null}
*/
/*#__NO_SIDE_EFFECTS__*/
export function next_sibling(node) {
return next_sibling_get.call(node);
}
/**
* @template {Node} N
* @param {N} node

@ -4,8 +4,7 @@ import {
clear_text_content,
create_element,
empty,
init_operations,
next_sibling
init_operations
} from './dom/operations.js';
import { HYDRATION_ERROR, HYDRATION_START, PassiveDelegatedEvents } from '../../constants.js';
import { flush_sync, push, pop, current_component_context } from './runtime.js';
@ -107,7 +106,6 @@ export function mount(component, options) {
if (DEV) {
validate_component(component);
}
init_operations();
const anchor = options.anchor ?? options.target.appendChild(empty());
// Don't flush previous effects to ensure order of outer effects stays consistent
@ -135,7 +133,6 @@ export function hydrate(component, options) {
if (DEV) {
validate_component(component);
}
init_operations();
const target = options.target;
const previous_hydrate_nodes = hydrate_nodes;
@ -147,13 +144,12 @@ export function hydrate(component, options) {
return flush_sync(() => {
set_hydrating(true);
/** @type {Node | null} */
var node = target.firstChild;
while (
node &&
(node.nodeType !== 8 || /** @type {Comment} */ (node).data !== HYDRATION_START)
) {
node = next_sibling(node);
node = node.nextSibling;
}
if (!node) {
@ -176,6 +172,8 @@ export function hydrate(component, options) {
e.hydration_failed();
}
// If an error occured above, the operations might not yet have been initialised.
init_operations();
clear_text_content(target);
set_hydrating(false);
@ -204,6 +202,8 @@ export function hydrate(component, options) {
* @returns {Exports}
*/
function _mount(Component, { target, anchor, props = {}, events, context, intro = false }) {
init_operations();
const registered_events = new Set();
const bound_event_listener = handle_event_propagation.bind(null, target);

Loading…
Cancel
Save