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 cfe4aa7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/core/component/const/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ const componentPrefixes = new Set([
'i-'
]);

/**
* 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;
}
};

/**
* A RegExp to check if the given string is the name of a component
*
Expand All @@ -28,6 +37,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);
}
};
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 cfe4aa7

Please sign in to comment.