mirror of https://github.com/sveltejs/svelte
fix reference for namespaced component (#5256)
parent
ad8d8564ec
commit
7aae362bcb
@ -0,0 +1,17 @@
|
|||||||
|
import { MemberExpression, Identifier } from "estree";
|
||||||
|
|
||||||
|
export function string_to_member_expression(name: string) {
|
||||||
|
const parts = name.split(".");
|
||||||
|
let node: MemberExpression | Identifier = {
|
||||||
|
type: "Identifier",
|
||||||
|
name: parts[0],
|
||||||
|
};
|
||||||
|
for (let i = 1; i < parts.length; i++) {
|
||||||
|
node = {
|
||||||
|
type: "MemberExpression",
|
||||||
|
object: node,
|
||||||
|
property: { type: "Identifier", name: parts[i] },
|
||||||
|
} as MemberExpression;
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
<p>i am a widget</p>
|
@ -0,0 +1,5 @@
|
|||||||
|
<script context="module">
|
||||||
|
import Tooltip from './Tooltip.svelte';
|
||||||
|
|
||||||
|
export const Widget = { Tooltip };
|
||||||
|
</script>
|
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
html: '<p>i am a widget</p>'
|
||||||
|
};
|
@ -0,0 +1,8 @@
|
|||||||
|
<script>
|
||||||
|
import { Widget } from './Widget.svelte';
|
||||||
|
let widgets = [Widget];
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each widgets as LazyWidget}
|
||||||
|
<LazyWidget.Tooltip />
|
||||||
|
{/each}
|
Loading…
Reference in new issue