Skip to content

Commit d85d2fb

Browse files
authored
Revert "feat: function watchQuery (nuxt#6245)" (nuxt#6296)
This reverts commit 3c61830.
1 parent 3c61830 commit d85d2fb

File tree

3 files changed

+8
-48
lines changed

3 files changed

+8
-48
lines changed

packages/vue-app/template/client.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ async function render(to, from, next) {
279279
// Get route's matched components
280280
const matches = []
281281
const Components = getMatchedComponents(to, matches)
282-
const instances = getMatchedComponentsInstances(to)
283282

284283
// If no Components matched, generate 404
285284
if (!Components.length) {
@@ -372,8 +371,6 @@ async function render(to, from, next) {
372371
Component._dataRefresh = true
373372
} else if (Array.isArray(watchQuery)) {
374373
Component._dataRefresh = watchQuery.some(key => this._diffQuery[key])
375-
} else if (typeof watchQuery === 'function') {
376-
Component._dataRefresh = watchQuery.apply(instances[i], [to.query, from.query])
377374
}
378375
}
379376
if (!this._hadError && this._isMounted && !Component._dataRefresh) {
@@ -494,13 +491,18 @@ function showNextPage(to) {
494491
function fixPrepatch(to, ___) {
495492
if (this._pathChanged === false && this._queryChanged === false) return
496493

497-
const instances = getMatchedComponentsInstances(to)
498-
const Components = getMatchedComponents(to)
494+
const matches = []
495+
const instances = getMatchedComponentsInstances(to, matches)
496+
const Components = getMatchedComponents(to, matches)
499497

500498
Vue.nextTick(() => {
501499
instances.forEach((instance, i) => {
502500
if (!instance || instance._isDestroyed) return
503-
501+
// if (
502+
// !this._queryChanged &&
503+
// to.matched[matches[i]].path.indexOf(':') === -1 &&
504+
// to.matched[matches[i]].path.indexOf('*') === -1
505+
// ) return // If not a dynamic route, skip
504506
if (
505507
instance.constructor._dataRefresh &&
506508
Components[i] === instance.constructor &&

test/e2e/basic.browser.test.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -180,24 +180,6 @@ describe('basic browser', () => {
180180
page.close()
181181
})
182182

183-
test('/scroll-to-top in the same page with watchQuery function', async () => {
184-
const page = await browser.page(url('/scroll-to-top/watch-query-fn'))
185-
await page.evaluate(() => window.scrollBy(0, window.innerHeight))
186-
await page.nuxt.navigate('/scroll-to-top/watch-query-fn?other=1')
187-
let pageYOffset = await page.evaluate(() => window.pageYOffset)
188-
expect(pageYOffset).toBeGreaterThan(0)
189-
await page.nuxt.go(-1)
190-
pageYOffset = await page.evaluate(() => window.pageYOffset)
191-
expect(pageYOffset).toBeGreaterThan(0)
192-
await page.nuxt.navigate('/scroll-to-top/watch-query-fn?test=1')
193-
pageYOffset = await page.evaluate(() => window.pageYOffset)
194-
expect(pageYOffset).toBe(0)
195-
await page.nuxt.go(-1)
196-
pageYOffset = await page.evaluate(() => window.pageYOffset)
197-
expect(pageYOffset).toBe(0)
198-
page.close()
199-
})
200-
201183
test('/validate should display a 404', async () => {
202184
await page.nuxt.navigate('/validate')
203185

test/fixtures/basic/pages/scroll-to-top/watch-query-fn.vue

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)