From abf1f99f91341846b233df93b7f9d9ccb687912f Mon Sep 17 00:00:00 2001 From: gretzkiy Date: Thu, 19 Dec 2024 16:06:57 +0300 Subject: [PATCH 1/3] feat(core/component): runtime checker for web-components --- src/core/component/const/index.ts | 1 + src/core/component/const/validators.ts | 4 +++- src/core/component/const/wc-validators.ts | 16 ++++++++++++++++ src/core/component/index.ts | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/core/component/const/wc-validators.ts diff --git a/src/core/component/const/index.ts b/src/core/component/const/index.ts index 59a7d5b1be..0d84d07731 100644 --- a/src/core/component/const/index.ts +++ b/src/core/component/const/index.ts @@ -15,3 +15,4 @@ export * from 'core/component/const/cache'; export * from 'core/component/const/symbols'; export * from 'core/component/const/enums'; export * from 'core/component/const/validators'; +export * from 'core/component/const/wc-validators'; diff --git a/src/core/component/const/validators.ts b/src/core/component/const/validators.ts index 5ac34accfd..a0e7ad9657 100644 --- a/src/core/component/const/validators.ts +++ b/src/core/component/const/validators.ts @@ -6,6 +6,8 @@ * https://github.com/V4Fire/Client/blob/master/LICENSE */ +import { isWebComponent } from 'core/component/const/wc-validators'; + const componentPrefixes = new Set([ 'b-', 'g-', @@ -28,6 +30,6 @@ export const isComponent = { return false; } - return componentPrefixes.has(name.slice(0, 2)) && !name.includes(' ', 2); + return componentPrefixes.has(name.slice(0, 2)) && !name.includes(' ', 2) && !isWebComponent.test(name); } }; diff --git a/src/core/component/const/wc-validators.ts b/src/core/component/const/wc-validators.ts new file mode 100644 index 0000000000..1d1744b76f --- /dev/null +++ b/src/core/component/const/wc-validators.ts @@ -0,0 +1,16 @@ +/*! + * V4Fire Client Core + * https://github.com/V4Fire/Client + * + * Released under the MIT license + * https://github.com/V4Fire/Client/blob/master/LICENSE + */ + +/** + * A RegExp to check if the given string is the name of a web-component + */ +export const isWebComponent = { + test(_name: Nullable): boolean { + return false; + } +}; diff --git a/src/core/component/index.ts b/src/core/component/index.ts index dc5244087a..3848b3ef6e 100644 --- a/src/core/component/index.ts +++ b/src/core/component/index.ts @@ -30,6 +30,7 @@ export { app, isComponent, + isWebComponent, rootComponents, beforeHooks, From 3cb77879d5436bd40f14d287ff4da3399e47c299 Mon Sep 17 00:00:00 2001 From: gretzkiy Date: Fri, 20 Dec 2024 18:47:41 +0300 Subject: [PATCH 2/3] chore(changelog): add changelog --- CHANGELOG.md | 6 ++++++ src/core/component/const/CHANGELOG.md | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35ea3dc872..b67af7989f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ Changelog _Note: Gaps between patch versions are faulty, broken or test releases._ +## v4.0.0-beta.171 (2024-12-23) + +#### :rocket: New Feature + +* Added a new validator for web-components `isWebComponent` `src/core/component/const/wc-validators` + ## v4.0.0-beta.170 (2024-12-19) #### :house: Internal diff --git a/src/core/component/const/CHANGELOG.md b/src/core/component/const/CHANGELOG.md index 535a274a3f..087e9d76e4 100644 --- a/src/core/component/const/CHANGELOG.md +++ b/src/core/component/const/CHANGELOG.md @@ -9,6 +9,12 @@ Changelog > - :house: [Internal] > - :nail_care: [Polish] +## v4.0.0-beta.171 (2024-12-23) + +#### :rocket: New Feature + +* Added a new validator for web-components `isWebComponent` + ## v3.0.0-rc.133 (2021-01-30) #### :rocket: New Feature From 7346a1b6e343896f5e539bb7d28799f01cab3f99 Mon Sep 17 00:00:00 2001 From: gretzkiy Date: Mon, 23 Dec 2024 14:53:28 +0300 Subject: [PATCH 3/3] chore(changelog): update changelog --- CHANGELOG.md | 5 +---- src/core/component/const/CHANGELOG.md | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ab64124b1..6124d2a2a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,13 +13,10 @@ _Note: Gaps between patch versions are faulty, broken or test releases._ ## v4.0.0-beta.?? (2024-12-23) -#### :rocket: New Feature - -* Added a new validator for web-components `isWebComponent` `src/core/component/const/wc-validators` - #### :house: Internal * Forced v-attrs to be converted into directive for tags that are web components `build/snakeskin` +* Added a new validator for web-components `isWebComponent` `src/core/component/const/wc-validators` ## v4.0.0-beta.170 (2024-12-19) diff --git a/src/core/component/const/CHANGELOG.md b/src/core/component/const/CHANGELOG.md index 087e9d76e4..f840b513cb 100644 --- a/src/core/component/const/CHANGELOG.md +++ b/src/core/component/const/CHANGELOG.md @@ -9,9 +9,9 @@ Changelog > - :house: [Internal] > - :nail_care: [Polish] -## v4.0.0-beta.171 (2024-12-23) +## v4.0.0-beta.?? (2024-12-23) -#### :rocket: New Feature +#### :house: Internal * Added a new validator for web-components `isWebComponent`