fix: more precise `validate_dynamic_component`

pull/12452/head
paoloricciuti 2 years ago
parent e74341a227
commit 19f6abb81d

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: more precise `validate_dynamic_component`

@ -1,6 +1,7 @@
import { untrack } from './runtime.js';
import { get_descriptor, is_array } from '../shared/utils.js';
import * as e from './errors.js';
import { validate_component } from '../shared/validate.js';
/** regex of all html void element names */
const void_element_names =
@ -28,7 +29,10 @@ export function validate_dynamic_component(component_fn) {
} catch (err) {
const { message } = /** @type {Error} */ (err);
if (typeof message === 'string' && message.indexOf('is not a function') !== -1) {
if (
typeof message === 'string' &&
message.indexOf(`${validate_component.name}(...) is not a function`) !== -1
) {
e.svelte_component_invalid_this_value();
}

@ -0,0 +1,5 @@
<script>
let { prop } = $props();
</script>
{prop}

@ -0,0 +1,9 @@
import { test } from '../../test';
export default test({
expect_unhandled_rejections: true,
error: 'is not a function',
compileOptions: {
dev: true
}
});

@ -0,0 +1,9 @@
<script>
import A from "./A.svelte";
</script>
{#snippet snip(comp, func)}
<svelte:component this={comp} prop={func(10)}></svelte:component>
{/snippet}
{@render snip(A)}
Loading…
Cancel
Save