mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(app): add deprecation warning on using process.browser (#4174)
This commit is contained in:
parent
96bdcaba01
commit
23228db73c
@ -156,7 +156,12 @@ async function createApp(ssrContext) {
|
||||
<% } %>
|
||||
|
||||
<% if (store) { %>
|
||||
if (process.client) {
|
||||
if (process.client || process.browser) {
|
||||
<% if (isDev) { %>
|
||||
if (process.browser) {
|
||||
console.warn('process.browser is deprecated, use process.client instead.')
|
||||
}
|
||||
<% } %>
|
||||
// Replace store state before plugins execution
|
||||
if (window.<%= globals.context %> && window.<%= globals.context %>.state) {
|
||||
store.replaceState(window.<%= globals.context %>.state)
|
||||
@ -169,7 +174,13 @@ async function createApp(ssrContext) {
|
||||
<% plugins.filter(p => p.ssr).forEach((plugin) => { %>
|
||||
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %>
|
||||
<% if (plugins.filter(p => !p.ssr).length) { %>
|
||||
if (process.client) { <% plugins.filter((p) => !p.ssr).forEach((plugin) => { %>
|
||||
if (process.client || process.browser) {
|
||||
<% if (isDev) { %>
|
||||
if (process.browser) {
|
||||
console.warn('process.browser is deprecated, use process.client instead.')
|
||||
}
|
||||
<% } %>
|
||||
<% plugins.filter((p) => !p.ssr).forEach((plugin) => { %>
|
||||
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %>
|
||||
}<% } %>
|
||||
<%= isTest ? '/* eslint-enable camelcase */' : '' %>
|
||||
|
@ -51,7 +51,12 @@ Vue.use(Router)
|
||||
<% if (router.scrollBehavior) { %>
|
||||
const scrollBehavior = <%= serialize(router.scrollBehavior).replace(/scrollBehavior\s*\(/, 'function(').replace('function function', 'function') %>
|
||||
<% } else { %>
|
||||
if (process.client) {
|
||||
if (process.client || process.browser) {
|
||||
<% if (isDev) { %>
|
||||
if (process.browser) {
|
||||
console.warn('process.browser is deprecated, use process.client instead.')
|
||||
}
|
||||
<% } %>
|
||||
window.history.scrollRestoration = 'manual'
|
||||
}
|
||||
const scrollBehavior = function (to, from, savedPosition) {
|
||||
|
@ -4,7 +4,13 @@ const noopData = () => ({})
|
||||
|
||||
// window.{{globals.loadedCallback}} hook
|
||||
// Useful for jsdom testing or plugins (https://github.com/tmpvar/jsdom#dealing-with-asynchronous-script-loading)
|
||||
if (process.client) {
|
||||
if (process.client || process.browser) {
|
||||
<% if (isDev) { %>
|
||||
if (process.browser) {
|
||||
console.warn('process.browser is deprecated, use process.client instead.')
|
||||
}
|
||||
<% } %>
|
||||
|
||||
window.<%= globals.readyCallback %>Cbs = []
|
||||
window.<%= globals.readyCallback %> = (cb) => {
|
||||
window.<%= globals.readyCallback %>Cbs.push(cb)
|
||||
@ -165,7 +171,13 @@ export async function setContext(app, context) {
|
||||
status: status
|
||||
})
|
||||
}
|
||||
if (process.client) {
|
||||
if (process.client || process.browser) {
|
||||
<% if (isDev) { %>
|
||||
if (process.browser) {
|
||||
console.warn('process.browser is deprecated, use process.client instead.')
|
||||
}
|
||||
<% } %>
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Location/replace
|
||||
window.location.replace(path)
|
||||
|
||||
@ -177,7 +189,12 @@ export async function setContext(app, context) {
|
||||
if (process.server) {
|
||||
app.context.beforeNuxtRender = fn => context.beforeRenderFns.push(fn)
|
||||
}
|
||||
if (process.client) {
|
||||
if (process.client || process.browser) {
|
||||
<% if (isDev) { %>
|
||||
if (process.browser) {
|
||||
console.warn('process.browser is deprecated, use process.client instead.')
|
||||
}
|
||||
<% } %>
|
||||
app.context.nuxtState = window.<%= globals.context %>
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user