Skip to content

Commit

Permalink
vue2-only
Browse files Browse the repository at this point in the history
  • Loading branch information
PNKBizz committed Nov 8, 2021
1 parent 860fb31 commit cef23ed
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@

# vue-yandex-maps

Latest version is only compatible with Vue 2.x<br>
Version for Vue 3 available with `next` tag

```
npm install vue-yandex-maps@next
```

Documentation: [RU](https://vue-yandex-maps.github.io/), [EN](https://vue-yandex-maps.github.io/en/)

## Contributors ✨
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-yandex-maps",
"version": "0.11.00",
"version": "0.11.01",
"description": "Yandex Maps component for VueJS.",
"main": "dist/vue-yandex-maps.umd.js",
"module": "dist/vue-yandex-maps.esm.js",
Expand Down
8 changes: 3 additions & 5 deletions src/Marker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { h } from 'vue';
import * as utils from './utils';

const MARKER_TYPES = [
Expand Down Expand Up @@ -65,9 +64,8 @@ export default {
},
},
data: () => ({ unwatchArr: [] }),
render(createElement) {
const render = typeof createElement === 'function' ? createElement : h;
return this.$slots.balloon && render('div', { style: 'display: none;' }, [typeof this.$slots.balloon === 'function' ? this.$slots.balloon() : this.$slots.balloon]);
render(h) {
return this.$slots.balloon && h('div', { style: 'display: none;' }, [this.$slots.balloon]);
},
mounted() {
Object.keys(this.$props).forEach((prop) => {
Expand Down Expand Up @@ -110,7 +108,7 @@ export default {

if (this.$slots.balloon) {
balloonContentLayout = ymaps.templateLayoutFactory
.createClass(typeof this.$slots.balloon === 'function' ? this.$slots.balloon()[0].elm.outerHTML : this.$slots.balloon[0].elm.outerHTML);
.createClass(this.$slots.balloon[0].elm.outerHTML);
}

if (this.makeComponentBalloonTemplate) {
Expand Down
35 changes: 12 additions & 23 deletions src/YMap.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { h } from 'vue';
import * as utils from './utils';

const { emitter } = utils;
Expand Down Expand Up @@ -281,34 +279,28 @@ export default {
if (this.$options.static.myMap.setBounds) this.$options.static.myMap.setBounds(val);
},
},
render(createElement) {
const render = typeof createElement === 'function' ? createElement : h;
const childProps = typeof createElement === 'function' ? {
attrs: {
id: this.ymapId,
class: this.ymapClass,
style: this.style,
},
} : {
id: this.ymapId,
class: this.ymapClass,
style: this.style,
};
return render(
render(h) {
return h(
'section',
{
class: 'ymap-container',
ref: 'mapContainer',
},
[
render(
h(
'div',
childProps,
{
attrs: {
id: this.ymapId,
class: this.ymapClass,
style: this.style,
},
},
),
this.isReady && render(
this.isReady && h(
'div',
[
typeof this.$slots.default === 'function' ? this.$slots.default() : this.$slots.default,
this.$slots.default,
],
),
],
Expand Down Expand Up @@ -349,7 +341,4 @@ export default {
beforeDestroy() {
if (this.$options.static.myMap.geoObjects) this.$options.static.myMap.geoObjects.removeAll();
},
beforeUnmount() {
if (this.$options.static.myMap.geoObjects) this.$options.static.myMap.geoObjects.removeAll();
},
};
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { setupBalloonClass, ymapLoader } from './utils';

const install = (Vue, options = {}) => {
if (install.installed) return;
console.log(Vue.version[0]);
if (+Vue.version[0] === 3) {
console.warn('Vue-yandex-maps: This version is only compatible with Vue 2.X. Please install vue-yandex-maps@next');
return;
}
install.installed = true;
setupBalloonClass(Vue);
YMapPlugin.pluginOptions = options;
Expand Down

0 comments on commit cef23ed

Please sign in to comment.