Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): registered vue components can't access the appContext #4601

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ui/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@

export * from './component-manager';
export * from './z-index-manager';
export * from "./teleport";

Check failure on line 19 in packages/ui/src/common/index.ts

View workflow job for this annotation

GitHub Actions / eslint

Expected "./teleport" to come before "./z-index-manager"
43 changes: 43 additions & 0 deletions packages/ui/src/common/teleport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Fragment, reactive, Teleport, markRaw, defineComponent, h } from "vue";

Check failure on line 1 in packages/ui/src/common/teleport.ts

View workflow job for this annotation

GitHub Actions / eslint

missing header

Check failure on line 1 in packages/ui/src/common/teleport.ts

View workflow job for this annotation

GitHub Actions / eslint

Expected "markRaw" to come before "Teleport"

Check failure on line 1 in packages/ui/src/common/teleport.ts

View workflow job for this annotation

GitHub Actions / eslint

Member 'markRaw' of the import declaration should be sorted alphabetically

Check failure on line 1 in packages/ui/src/common/teleport.ts

View workflow job for this annotation

GitHub Actions / eslint

Expected "defineComponent" to come before "markRaw"

let active = false;
const items = reactive<{ [key: string]: any }>({});

export function connect(
id: string | number,
component: any,
container: HTMLDivElement,
props: Record<string, any>
) {
if (active) {
items[id] = markRaw(
defineComponent({
render: () =>
h(Teleport, { to: container } as any, [
h(component, props),
]),
})
);
}
}

export function disconnect(id: string | number) {
if (active) {
delete items[id];
}
}

export function getTeleport(): any {
active = true;

return defineComponent({
setup() {
return () =>
h(
Fragment,
{},
Object.keys(items).map((id) => h(items[id]))
);
},
});
}
Loading