Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core/component): runtime checker for web-components #1518

Merged
merged 4 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/core/component/const/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/core/component/const/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
4 changes: 3 additions & 1 deletion src/core/component/const/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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-',
Expand All @@ -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);
}
};
16 changes: 16 additions & 0 deletions src/core/component/const/wc-validators.ts
Original file line number Diff line number Diff line change
@@ -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<string>): boolean {
return false;
}
};
1 change: 1 addition & 0 deletions src/core/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export {
app,

isComponent,
isWebComponent,
rootComponents,

beforeHooks,
Expand Down
Loading