Skip to content

Commit

Permalink
Merge branch 'hotfix/1.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDASILVA committed Mar 14, 2018
2 parents 318269c + 185cedf commit f5052d0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuxt-google-maps-module",
"version": "1.5.2",
"version": "1.5.3",
"description": "NuxtJS module to import Google Maps",
"license": "MIT",
"contributors": [
Expand Down
30 changes: 19 additions & 11 deletions src/plugin.template.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import Vue from 'vue';

export default function (context) {
/**
* Inject Google object in our Vue app (client side only)
* Do an event boomerang to make sure the Google maps API callback was
* called and google injected in Vue.
*/
if (process.client) {
/**
* Do an event boomerang to make sure the Google maps API callback was
* called and google injected in Vue.
*/
if (typeof window !== 'undefined') {
const event = new window.Event('maps-module:initiated');
window.dispatchEvent(event);
window.addEventListener('maps-module:loaded', () => {
context.app.google = window.google;
if (typeof window !== 'undefined') {
const event = new window.Event('maps-module:initiated');
window.dispatchEvent(event);
window.addEventListener('maps-module:loaded', () => {
Vue.use(() => {
if (!Vue.prototype.hasOwnProperty('$google')) {
Object.defineProperty(Vue.prototype, '$google', {
get () {
return window.google;
}
})
}
});
}

context.app.google = window.google;
});
}
}

0 comments on commit f5052d0

Please sign in to comment.