mirror of https://github.com/sveltejs/svelte
chore: improve output for `<svelte:element>` (#9648)
- doesn't add spread_dynamic_element_attributes when there are no attributes — Unnecessary spread_dynamic_element_attributes call #9646 - skips the child render function altogether if there is nothing to dopull/9650/head
parent
6e863e617c
commit
5836c1cdbd
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
chore: improve `<svelte:element>` generated code
|
@ -0,0 +1,3 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({});
|
@ -0,0 +1,17 @@
|
||||
// index.svelte (Svelte VERSION)
|
||||
// Note: compiler output will change before 5.0 is released!
|
||||
import "svelte/internal/disclose-version";
|
||||
import * as $ from "svelte/internal";
|
||||
|
||||
export default function Svelte_element($$anchor, $$props) {
|
||||
$.push($$props, true);
|
||||
|
||||
let tag = $.prop_source($$props, "tag", 'hr', false);
|
||||
/* Init */
|
||||
var fragment = $.comment($$anchor);
|
||||
var node = $.child_frag(fragment);
|
||||
|
||||
$.element(node, () => $.get(tag));
|
||||
$.close_frag($$anchor, fragment);
|
||||
$.pop();
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
// index.svelte (Svelte VERSION)
|
||||
// Note: compiler output will change before 5.0 is released!
|
||||
import * as $ from "svelte/internal/server";
|
||||
|
||||
export default function Svelte_element($$payload, $$props) {
|
||||
$.push(true);
|
||||
|
||||
let { tag = 'hr' } = $$props;
|
||||
const anchor = $.create_anchor($$payload);
|
||||
|
||||
$$payload.out += `${anchor}`;
|
||||
|
||||
if (tag) {
|
||||
const anchor_1 = $.create_anchor($$payload);
|
||||
|
||||
$$payload.out += `<${tag}>`;
|
||||
|
||||
if (!$.VoidElements.has(tag)) {
|
||||
$$payload.out += `${anchor_1}`;
|
||||
$$payload.out += `${anchor_1}</${tag}>`;
|
||||
}
|
||||
}
|
||||
|
||||
$$payload.out += `${anchor}`;
|
||||
$.bind_props($$props, { tag });
|
||||
$.pop();
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
let { tag = 'hr' } = $props();
|
||||
</script>
|
||||
|
||||
<svelte:element this={tag} />
|
Loading…
Reference in new issue