Skip to content

Commit

Permalink
Merge branch 'hotfix/1.5.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDASILVA committed Mar 27, 2018
2 parents 03dcd9e + c587fb8 commit 6a87251
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 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.4",
"version": "1.5.5",
"description": "NuxtJS module to import Google Maps",
"license": "MIT",
"contributors": [
Expand Down
21 changes: 9 additions & 12 deletions src/plugin.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function (context, inject) {
* Inject the Google object in the Nuxt instance, even if it's
* not used server side.
*/
context.app.google = {};
Vue['__nuxt_$google_installed__'] = true;
inject('google', {});

/**
Expand All @@ -14,21 +14,18 @@ export default function (context, inject) {
* Do an event boomerang to make sure the Google maps API callback was
* called and google injected in Vue.
*/
if (process.client && typeof window !== 'undefined') {
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;
}
})
}
Object.defineProperty(Vue.prototype, '$google', {
get() {
if (typeof window !== 'undefined') {
return window.google;
}
},
configurable: true,
});

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

0 comments on commit 6a87251

Please sign in to comment.