From 59ece4978e274ccd1b0e8ba0ff59f7fc20c4f854 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 15 May 2017 02:26:00 +0430 Subject: [PATCH] fix plugins injectAs --- lib/app/client.js | 4 ++-- lib/app/server.js | 4 ++-- lib/app/utils.js | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index 793c631983..6fada6c0b6 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -89,7 +89,7 @@ function render (to, from, next) { nextCalled = true next(path) } - let context = getContext({ to<%= (store ? ', store' : '') %>, isClient: true, next: _next.bind(this), error: this.error.bind(this) }) + let context = getContext({ to<%= (store ? ', store' : '') %>, isClient: true, next: _next.bind(this), error: this.error.bind(this) }, app) let Components = getMatchedComponents(to) this._context = context this._dateLastError = this.$options._nuxt.dateErr @@ -274,7 +274,7 @@ function addHotReload ($component, depth) { <%= (loading ? 'this.$loading.finish && this.$loading.finish()' : '') %> router.push(path) } - let context = getContext({ route: router.currentRoute<%= (store ? ', store' : '') %>, isClient: true, next: next.bind(this), error: this.error }) + let context = getContext({ route: router.currentRoute<%= (store ? ', store' : '') %>, isClient: true, next: next.bind(this), error: this.error }, app) <%= (loading ? 'this.$loading.start && this.$loading.start()' : '') %> callMiddleware.call(this, Components, context) .then(() => { diff --git a/lib/app/server.js b/lib/app/server.js index ff50771a7a..5d028e3c33 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -82,10 +82,10 @@ export default context => { // Add route to the context context.route = router.currentRoute // Update context - ctx = getContext(context) + ctx = getContext(context, app) // nuxtServerInit <% if (store) { %> - let promise = (store._actions && store._actions.nuxtServerInit ? store.dispatch('nuxtServerInit', omit(getContext(context), 'redirect', 'error')) : null) + let promise = (store._actions && store._actions.nuxtServerInit ? store.dispatch('nuxtServerInit', omit(getContext(context, app), 'redirect', 'error')) : null) if (!promise || (!(promise instanceof Promise) && (typeof promise.then !== 'function'))) promise = Promise.resolve() <% } else { %> let promise = Promise.resolve() diff --git a/lib/app/utils.js b/lib/app/utils.js index 8af0355682..05d6ca560c 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -1,6 +1,4 @@ 'use strict' -import { app } from './index' - const noopData = () => ({}) export function applyAsyncData (Component, asyncData = {}) { @@ -38,7 +36,7 @@ export function flatMapComponents (route, fn) { })) } -export function getContext (context) { +export function getContext (context, app) { let ctx = { isServer: !!context.isServer, isClient: !!context.isClient,