( comp: any, instance: ComponentInternalInstance | null, )
| 9 | import { convertLegacyFunctionalComponent } from './componentFunctional' |
| 10 | |
| 11 | export function convertLegacyComponent( |
| 12 | comp: any, |
| 13 | instance: ComponentInternalInstance | null, |
| 14 | ): Component { |
| 15 | if (comp.__isBuiltIn) { |
| 16 | return comp |
| 17 | } |
| 18 | |
| 19 | // 2.x constructor |
| 20 | if (isFunction(comp) && comp.cid) { |
| 21 | // #7766 |
| 22 | if (comp.render) { |
| 23 | // only necessary when compiled from SFC |
| 24 | comp.options.render = comp.render |
| 25 | } |
| 26 | // copy over internal properties set by the SFC compiler |
| 27 | comp.options.__file = comp.__file |
| 28 | comp.options.__hmrId = comp.__hmrId |
| 29 | comp.options.__scopeId = comp.__scopeId |
| 30 | comp = comp.options |
| 31 | } |
| 32 | |
| 33 | // 2.x async component |
| 34 | if ( |
| 35 | isFunction(comp) && |
| 36 | checkCompatEnabled(DeprecationTypes.COMPONENT_ASYNC, instance, comp) |
| 37 | ) { |
| 38 | // since after disabling this, plain functions are still valid usage, do not |
| 39 | // use softAssert here. |
| 40 | return convertLegacyAsyncComponent(comp) |
| 41 | } |
| 42 | |
| 43 | // 2.x functional component |
| 44 | if ( |
| 45 | isObject(comp) && |
| 46 | comp.functional && |
| 47 | softAssertCompatEnabled( |
| 48 | DeprecationTypes.COMPONENT_FUNCTIONAL, |
| 49 | instance, |
| 50 | comp, |
| 51 | ) |
| 52 | ) { |
| 53 | return convertLegacyFunctionalComponent(comp) |
| 54 | } |
| 55 | |
| 56 | return comp |
| 57 | } |
no test coverage detected