mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +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 (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
|
// Replace store state before plugins execution
|
||||||
if (window.<%= globals.context %> && window.<%= globals.context %>.state) {
|
if (window.<%= globals.context %> && window.<%= globals.context %>.state) {
|
||||||
store.replaceState(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) => { %>
|
<% plugins.filter(p => p.ssr).forEach((plugin) => { %>
|
||||||
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %>
|
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %>
|
||||||
<% if (plugins.filter(p => !p.ssr).length) { %>
|
<% 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)<% }) %>
|
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %>
|
||||||
}<% } %>
|
}<% } %>
|
||||||
<%= isTest ? '/* eslint-enable camelcase */' : '' %>
|
<%= isTest ? '/* eslint-enable camelcase */' : '' %>
|
||||||
|
@ -51,7 +51,12 @@ Vue.use(Router)
|
|||||||
<% if (router.scrollBehavior) { %>
|
<% if (router.scrollBehavior) { %>
|
||||||
const scrollBehavior = <%= serialize(router.scrollBehavior).replace(/scrollBehavior\s*\(/, 'function(').replace('function function', 'function') %>
|
const scrollBehavior = <%= serialize(router.scrollBehavior).replace(/scrollBehavior\s*\(/, 'function(').replace('function function', 'function') %>
|
||||||
<% } else { %>
|
<% } 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'
|
window.history.scrollRestoration = 'manual'
|
||||||
}
|
}
|
||||||
const scrollBehavior = function (to, from, savedPosition) {
|
const scrollBehavior = function (to, from, savedPosition) {
|
||||||
|
@ -4,7 +4,13 @@ const noopData = () => ({})
|
|||||||
|
|
||||||
// window.{{globals.loadedCallback}} hook
|
// window.{{globals.loadedCallback}} hook
|
||||||
// Useful for jsdom testing or plugins (https://github.com/tmpvar/jsdom#dealing-with-asynchronous-script-loading)
|
// 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 %>Cbs = []
|
||||||
window.<%= globals.readyCallback %> = (cb) => {
|
window.<%= globals.readyCallback %> = (cb) => {
|
||||||
window.<%= globals.readyCallback %>Cbs.push(cb)
|
window.<%= globals.readyCallback %>Cbs.push(cb)
|
||||||
@ -165,7 +171,13 @@ export async function setContext(app, context) {
|
|||||||
status: status
|
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
|
// https://developer.mozilla.org/en-US/docs/Web/API/Location/replace
|
||||||
window.location.replace(path)
|
window.location.replace(path)
|
||||||
|
|
||||||
@ -177,7 +189,12 @@ export async function setContext(app, context) {
|
|||||||
if (process.server) {
|
if (process.server) {
|
||||||
app.context.beforeNuxtRender = fn => context.beforeRenderFns.push(fn)
|
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 %>
|
app.context.nuxtState = window.<%= globals.context %>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user