pull/12335/head
Rich Harris 2 years ago
commit 412ac8ad60

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: reverse parent/child order in invalid HTML warning

@ -1,3 +1,4 @@
/** @import { Effect, TemplateNode } from '#client' */
import { add_snippet_symbol } from '../../../shared/validate.js';
import { EFFECT_TRANSPARENT } from '../../constants.js';
import { branch, block, destroy_effect } from '../../reactivity/effects.js';
@ -8,8 +9,8 @@ import {
import { hydrate_next, hydrate_node, hydrating } from '../hydration.js';
/**
* @template {(node: import('#client').TemplateNode, ...args: any[]) => import('#client').Dom} SnippetFn
* @param {import('#client').TemplateNode} anchor
* @template {(node: TemplateNode, ...args: any[]) => void} SnippetFn
* @param {TemplateNode} anchor
* @param {() => SnippetFn | null | undefined} get_snippet
* @param {(() => any)[]} args
* @returns {void}
@ -22,7 +23,7 @@ export function snippet(anchor, get_snippet, ...args) {
/** @type {SnippetFn | null | undefined} */
var snippet;
/** @type {import('#client').Effect | null} */
/** @type {Effect | null} */
var snippet_effect;
block(() => {
@ -47,19 +48,17 @@ export function snippet(anchor, get_snippet, ...args) {
* In development, wrap the snippet function so that it passes validation, and so that the
* correct component context is set for ownership checks
* @param {any} component
* @param {(node: import('#client').TemplateNode, ...args: any[]) => import('#client').Dom} fn
* @param {(node: TemplateNode, ...args: any[]) => void} fn
*/
export function wrap_snippet(component, fn) {
return add_snippet_symbol(
(/** @type {import('#client').TemplateNode} */ node, /** @type {any[]} */ ...args) => {
var previous_component_function = dev_current_component_function;
set_dev_current_component_function(component);
return add_snippet_symbol((/** @type {TemplateNode} */ node, /** @type {any[]} */ ...args) => {
var previous_component_function = dev_current_component_function;
set_dev_current_component_function(component);
try {
return fn(node, ...args);
} finally {
set_dev_current_component_function(previous_component_function);
}
try {
return fn(node, ...args);
} finally {
set_dev_current_component_function(previous_component_function);
}
);
});
}

Loading…
Cancel
Save