Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
Merge branch 'feat/v3-compat-h' into feat/v3-compat-define-component
Browse files Browse the repository at this point in the history
  • Loading branch information
eunjae-lee committed May 31, 2021
2 parents 9be2f6c + 53601b6 commit 3eff5f6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@
"dependencies": {
"algoliasearch-helper": "^3.1.0",
"instantsearch.js": "^4.20.0",
"mitt": "^2.1.0"
"mitt": "^2.1.0",
"vue-demi": "^0.9.1"
},
"peerDependencies": {
"algoliasearch": ">= 3.32.0 < 5",
"vue": "^2.6.0",
"vue": "^2.6.0 || >=3.0.0-rc.0",
"vue-server-renderer": "^2.6.11"
},
"devDependencies": {
Expand Down
21 changes: 10 additions & 11 deletions src/components/Highlighter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@
</template>

<script>
import { isVue3 } from 'vue-demi';
import { parseAlgoliaHit } from '../util/parseAlgoliaHit';
import { getVueVersion } from '../util/getVueVersion';
const TextNode =
getVueVersion().split('.')[0] === '3'
? (props, context) => context.slots.default()
: {
functional: true,
render(createElement, context) {
const slots = context.slots();
return slots.default;
},
};
const TextNode = isVue3
? (props, context) => context.slots.default()
: {
functional: true,
render(createElement, context) {
const slots = context.slots();
return slots.default;
},
};
export default {
name: 'AisHighlighter',
Expand Down
8 changes: 5 additions & 3 deletions src/util/getVueVersion.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { isVue3, version, Vue2 } from 'vue-demi';

export function getVueVersion() {
if (typeof window !== 'undefined' && typeof window.Vue !== 'undefined') {
return window.Vue.version; // for umd
if (isVue3) {
return version;
} else {
return require('vue').version;
return Vue2.version;
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15561,6 +15561,11 @@ vue-class-component@^7.0.1:
resolved "https://registry.yarnpkg.com/vue-class-component/-/vue-class-component-7.0.1.tgz#7af2225c600667c7042b60712eefdf41dfc6de63"
integrity sha512-YIihdl7YmceEOjSwcxLhCXCNA3TKC2FStuMcjtuzhUAgw5x5d1T5gZTmVQHGyOaQsaKffL4GlZzYN3dlMYl53w==

vue-demi@^0.9.1:
version "0.9.1"
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.9.1.tgz#25d6e1ebd4d4010757ff3571e2bf6a1d7bf3de82"
integrity sha512-7s1lufRD2l369eFWPjgLvhqCRk0XzGWJsQc7K4q+0mZtixyGIvsK1Cg88P4NcaRIEiBuuN4q1NN4SZKFKwQswA==

vue-eslint-parser@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-2.0.3.tgz#c268c96c6d94cfe3d938a5f7593959b0ca3360d1"
Expand Down

0 comments on commit 3eff5f6

Please sign in to comment.