From 4b8e4ce9f0a9fdfd2979e0be6d806c8ba7de4aa8 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Wed, 8 May 2024 15:36:02 +0800 Subject: [PATCH] docs: add documentation about the __VUE_PROD_TRUSTED_TYPES__ flag --- packages/runtime-core/src/featureFlags.ts | 5 +++++ packages/vue/README.md | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/packages/runtime-core/src/featureFlags.ts b/packages/runtime-core/src/featureFlags.ts index 6dd136277bd..34deb0a3006 100644 --- a/packages/runtime-core/src/featureFlags.ts +++ b/packages/runtime-core/src/featureFlags.ts @@ -25,6 +25,11 @@ export function initFeatureFlags() { getGlobalThis().__VUE_PROD_HYDRATION_MISMATCH_DETAILS__ = false } + if (typeof __FEATURE_PROD_TRUSTED_TYPES__ !== 'boolean') { + __DEV__ && needWarn.push(`__VUE_PROD_TRUSTED_TYPES__`) + getGlobalThis().__VUE_PROD_TRUSTED_TYPES__ = false + } + if (__DEV__ && needWarn.length) { const multi = needWarn.length > 1 console.warn( diff --git a/packages/vue/README.md b/packages/vue/README.md index 2aca524e03d..364201a219c 100644 --- a/packages/vue/README.md +++ b/packages/vue/README.md @@ -49,6 +49,10 @@ - Default: `false` - Enable / disable detailed warnings for hydration mismatches in production +- `__VUE_PROD_TRUSTED_TYPES__` + - Default: `false` + - Enable / disable built-in Trusted Types Policy for compatibility with the [`trusted-types` CSP directive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types) + The build will work without configuring these flags, however it is **strongly recommended** to properly configure them in order to get proper tree-shaking in the final bundle. ### For Server-Side Rendering