Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Support vue component file that exports Vue.extend. (#95)
Browse files Browse the repository at this point in the history
* Support vue component file that exports Vue.extend.

Normally, vue component js file exports an options object. For example: export default {props:{title:""}}. In some cases, vue component js file needs to exports Vue.extend. For example: export default Vue.extend(options). Vue natually support it. This fix is used to support Vue.extend when using Vue components in React.

* Fix eslint error.

Fix below two errors:
   3:41  error  Missing space before function parentheses  space-before-function-paren
  16:33  error  Missing space before function parentheses  space-before-function-paren
  • Loading branch information
wenlz123 authored and akxcv committed Oct 14, 2019
1 parent deb2689 commit eee1b3b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/vuera.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ function isReactComponent(component) {
return false;
}

return !(typeof component === 'function' && component.prototype && component.prototype.constructor.super && component.prototype.constructor.super.isVue);
return !(typeof component === 'function' && component.prototype && (component.prototype.constructor.super && component.prototype.constructor.super.isVue || component.prototype instanceof Vue));
}

function isReactForwardReference(component) {
Expand Down
2 changes: 1 addition & 1 deletion dist/vuera.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ function isReactComponent(component) {
return false;
}

return !(typeof component === 'function' && component.prototype && component.prototype.constructor.super && component.prototype.constructor.super.isVue);
return !(typeof component === 'function' && component.prototype && (component.prototype.constructor.super && component.prototype.constructor.super.isVue || component.prototype instanceof Vue));
}

function isReactForwardReference(component) {
Expand Down
2 changes: 1 addition & 1 deletion dist/vuera.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ function isReactComponent(component) {
return false;
}

return !(typeof component === 'function' && component.prototype && component.prototype.constructor.super && component.prototype.constructor.super.isVue);
return !(typeof component === 'function' && component.prototype && (component.prototype.constructor.super && component.prototype.constructor.super.isVue || component.prototype instanceof Vue));
}

function isReactForwardReference(component) {
Expand Down
6 changes: 4 additions & 2 deletions src/utils/isReactComponent.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Vue from 'vue'

export default function isReactComponent (component) {
if (typeof component === 'object' && !isReactForwardReference(component)) {
return false
Expand All @@ -6,8 +8,8 @@ export default function isReactComponent (component) {
return !(
typeof component === 'function' &&
component.prototype &&
component.prototype.constructor.super &&
component.prototype.constructor.super.isVue
((component.prototype.constructor.super && component.prototype.constructor.super.isVue) ||
component.prototype instanceof Vue)
)
}

Expand Down

0 comments on commit eee1b3b

Please sign in to comment.