Skip to content

Commit

Permalink
add isRegistered
Browse files Browse the repository at this point in the history
  • Loading branch information
nichoth committed Nov 24, 2024
1 parent 4181baa commit 99f62c0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,13 @@ export abstract class WebComponent extends HTMLElement {
function eventName (namespace:string, evType:string) {
return `${namespace}:${evType}`
}

/**
* Check if the given tag name has been registered.
*
* @param {string} elName The custom element tag name.
* @returns {boolean} True if the given name has been registered already.
*/
export function isRegistered (elName:string) {
return document.createElement(elName).constructor !== HTMLElement
}

0 comments on commit 99f62c0

Please sign in to comment.