Skip to content

Commit

Permalink
fix(vue2): Use the super constructor when the instance is a VueCompon…
Browse files Browse the repository at this point in the history
…ent (#1690)
  • Loading branch information
0Rick0 committed Feb 9, 2022
1 parent b3dd744 commit bec47a7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/app-backend-core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ export async function removeApp (app: App, ctx: BackendContext) {
}
}

// eslint-disable-next-line camelcase
function _legacy_getVueFromApp (app) {
if (app.constructor.name === 'VueComponent') {
// When Vue.extend is used the component is an instance of VueComponent instead of Vue.
// VueComponent has a property super which points to the original Vue constructor
return app.constructor.super
}
return app.constructor
}

// eslint-disable-next-line camelcase
export async function _legacy_getAndRegisterApps (ctx: BackendContext) {
// Remove apps that are legacy
Expand All @@ -232,7 +242,7 @@ export async function _legacy_getAndRegisterApps (ctx: BackendContext) {

const apps = scan()
apps.forEach(app => {
const Vue = app.constructor
const Vue = _legacy_getVueFromApp(app)
registerApp({
app,
types: {},
Expand Down

0 comments on commit bec47a7

Please sign in to comment.