From 88dfbcba65032b3bc63bfa6074208e7c972a5036 Mon Sep 17 00:00:00 2001 From: julien huang Date: Sun, 30 Jul 2023 21:59:51 +0200 Subject: [PATCH] refactor: use ternary --- packages/nuxt/src/pages/runtime/router.options.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/nuxt/src/pages/runtime/router.options.ts b/packages/nuxt/src/pages/runtime/router.options.ts index b1d22573c0..0551ee04b4 100644 --- a/packages/nuxt/src/pages/runtime/router.options.ts +++ b/packages/nuxt/src/pages/runtime/router.options.ts @@ -63,13 +63,7 @@ function _getHashElementScrollMarginTop (selector: string): number { } function _isDifferentRoute (from: RouteLocationNormalized, to: RouteLocationNormalized): boolean { - const samePageComponent = to.path === from.path + const isSamePath = to.path === from.path - if (!samePageComponent) { - return true - } - if (samePageComponent && JSON.stringify(from.params) !== JSON.stringify(to.params)) { - return true - } - return false + return isSamePath ? JSON.stringify(from.params) !== JSON.stringify(to.params) : true }