fix: order of arguments for `push_element` in `svelte:element` (#12763)

* fix: order of arguments for `push_element` in `svelte:element`

* chore: move test to runtime

* fix: add line and column to function call
pull/12767/head
Paolo Ricciuti 1 year ago committed by GitHub
parent 1942f87ed9
commit 60148d3352
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: order of arguments for `push_element` in `svelte:element`

@ -1,7 +1,8 @@
/** @import { Location } from 'locate-character' */
/** @import { BlockStatement, Expression } from 'estree' */
/** @import { SvelteElement } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */
import { dev } from '../../../../state.js';
import { dev, locator } from '../../../../state.js';
import * as b from '../../../../utils/builders.js';
import { determine_namespace_for_children } from '../../utils.js';
import { build_element_attributes } from './shared/element.js';
@ -36,7 +37,18 @@ export function SvelteElement(node, context) {
build_element_attributes(node, { ...context, state });
if (dev) {
context.state.template.push(b.stmt(b.call('$.push_element', tag, b.id('$$payload'))));
const location = /** @type {Location} */ (locator(node.start));
context.state.template.push(
b.stmt(
b.call(
'$.push_element',
b.id('$$payload'),
tag,
b.literal(location.line),
b.literal(location.column)
)
)
);
}
const attributes = b.block([...state.init, ...build_template(state.template)]);

@ -0,0 +1,7 @@
import { test } from '../../test';
export default test({
compileOptions: {
dev: true
}
});

@ -0,0 +1 @@
<!--[--><!----><p ><!----><p ><!----></p><!----><!----></p><!----><!--]-->

@ -0,0 +1 @@
<script>console.error("node_invalid_placement_ssr: `<p>` (packages/svelte/tests/server-side-rendering/samples/invalid-nested-svelte-element/main.svelte:1:0) cannot contain `<p>` (packages/svelte/tests/server-side-rendering/samples/invalid-nested-svelte-element/main.svelte:2:1)\n\nThis can cause content to shift around as the browser repairs the HTML, and will likely result in a `hydration_mismatch` warning.")</script>

@ -0,0 +1,3 @@
<svelte:element this={'p'}>
<svelte:element this={'p'}></svelte:element>
</svelte:element>
Loading…
Cancel
Save