Skip to content

Commit

Permalink
feat(core/component): runtime checker for web-components
Browse files Browse the repository at this point in the history
  • Loading branch information
gretzkiy committed Dec 19, 2024
1 parent 46c9b13 commit 11ce891
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
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 { isV4WebComponent } 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 !isV4WebComponent.test(name) && componentPrefixes.has(name.slice(0, 2)) && !name.includes(' ', 2);
}
};
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 isV4WebComponent = {
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,
isV4WebComponent,
rootComponents,

beforeHooks,
Expand Down

0 comments on commit 11ce891

Please sign in to comment.