From 976bcb8b4e22185687470ff9b45c0526cc192ee5 Mon Sep 17 00:00:00 2001 From: Lucie <25330882+lihbr@users.noreply.github.com> Date: Wed, 12 Jun 2024 22:56:58 +0200 Subject: [PATCH 1/3] feat(kit): add `isNuxtMajorVersion` compatibility util, deprecate `isNuxt2` and `isNuxt3` (#27564) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: lihbr Co-authored-by: Damian Głowala --- packages/kit/src/compatibility.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/kit/src/compatibility.ts b/packages/kit/src/compatibility.ts index b2720f05c901..af1eeb08dc58 100644 --- a/packages/kit/src/compatibility.ts +++ b/packages/kit/src/compatibility.ts @@ -98,19 +98,26 @@ export async function hasNuxtCompatibility (constraints: NuxtCompatibility, nuxt } /** - * Check if current nuxt instance is version 2 legacy + * Check if current Nuxt instance is of specified major version */ -export function isNuxt2 (nuxt: Nuxt = useNuxt()) { +export function isNuxtMajorVersion (majorVersion: 2 | 3 | 4, nuxt: Nuxt = useNuxt()) { const version = getNuxtVersion(nuxt) - return version[0] === '2' && version[1] === '.' + + return version[0] === majorVersion.toString() && version[1] === '.' +} + +/** + * @deprecated Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version. + */ +export function isNuxt2 (nuxt: Nuxt = useNuxt()) { + return isNuxtMajorVersion(2, nuxt) } /** - * Check if current nuxt instance is version 3 + * @deprecated Use `isNuxtMajorVersion(3, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version. */ export function isNuxt3 (nuxt: Nuxt = useNuxt()) { - const version = getNuxtVersion(nuxt) - return version[0] === '3' && version[1] === '.' + return isNuxtMajorVersion(3, nuxt) } /** From 3c0bb7c97bfbf3a402a1e8cb3427ec1b6c569393 Mon Sep 17 00:00:00 2001 From: garthreckers Date: Wed, 12 Jun 2024 16:04:38 -0700 Subject: [PATCH 2/3] Update 6.meta.md Adding larger warning with more context about a breaking change when meta is set to true --- docs/6.bridge/6.meta.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/6.bridge/6.meta.md b/docs/6.bridge/6.meta.md index 6903a774e67a..e29ca7995f7d 100644 --- a/docs/6.bridge/6.meta.md +++ b/docs/6.bridge/6.meta.md @@ -98,6 +98,10 @@ export default defineNuxtComponent({ ``` +::warning +Possible breaking change: `head` receives the nuxt app but cannot access the component instance. If the code in your `head` tries to access the data object through `this` or `this.$data`, you will need to migrate to the `useHead` composable. +:: + ## Title Template If you want to use a function (for full control), then this cannot be set in your nuxt.config, and it is recommended instead to set it within your `/layouts` directory. From 76ad677de21569f0d7d907ebbebaa31d2df409c4 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 13 Jun 2024 09:42:25 +0100 Subject: [PATCH 3/3] Revert "feat(kit): add `isNuxtMajorVersion` compatibility util, deprecate `isNuxt2` and `isNuxt3` (#27564)" This reverts commit 976bcb8b4e22185687470ff9b45c0526cc192ee5. --- packages/kit/src/compatibility.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/packages/kit/src/compatibility.ts b/packages/kit/src/compatibility.ts index af1eeb08dc58..b2720f05c901 100644 --- a/packages/kit/src/compatibility.ts +++ b/packages/kit/src/compatibility.ts @@ -98,26 +98,19 @@ export async function hasNuxtCompatibility (constraints: NuxtCompatibility, nuxt } /** - * Check if current Nuxt instance is of specified major version - */ -export function isNuxtMajorVersion (majorVersion: 2 | 3 | 4, nuxt: Nuxt = useNuxt()) { - const version = getNuxtVersion(nuxt) - - return version[0] === majorVersion.toString() && version[1] === '.' -} - -/** - * @deprecated Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version. + * Check if current nuxt instance is version 2 legacy */ export function isNuxt2 (nuxt: Nuxt = useNuxt()) { - return isNuxtMajorVersion(2, nuxt) + const version = getNuxtVersion(nuxt) + return version[0] === '2' && version[1] === '.' } /** - * @deprecated Use `isNuxtMajorVersion(3, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version. + * Check if current nuxt instance is version 3 */ export function isNuxt3 (nuxt: Nuxt = useNuxt()) { - return isNuxtMajorVersion(3, nuxt) + const version = getNuxtVersion(nuxt) + return version[0] === '3' && version[1] === '.' } /**