-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(omi): tag name can be obtained through exported class, preventin…
…g tree shaking
- Loading branch information
Showing
4 changed files
with
12 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "omi", | ||
"version": "7.1.14", | ||
"version": "7.2.0", | ||
"scripts": { | ||
"start": "vite", | ||
"dev-vite": "vite", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
/** | ||
* Defines a custom element. | ||
* @param name - The name of the custom element. | ||
* @param tagName - The tagName of the custom element. | ||
* @param ctor - The constructor function for the custom element. | ||
*/ | ||
export function define(name: string, ctor: CustomElementConstructor): void { | ||
if (customElements.get(name)) { | ||
console.warn(`Failed to execute 'define' on 'CustomElementRegistry': the name "${name}" has already been used with this registry`) | ||
export function define(tagName: string, ctor: CustomElementConstructor): void { | ||
if (customElements.get(tagName)) { | ||
console.warn(`Failed to execute 'define' on 'CustomElementRegistry': the tag name "${tagName}" has already been used with this registry`) | ||
return | ||
} | ||
|
||
customElements.define(name, ctor) | ||
Object.defineProperty(ctor, 'tagName', { value: tagName, writable: false }) | ||
customElements.define(tagName, ctor) | ||
} | ||
|
||
export function tag(name: string) { | ||
export function tag(tagName: string) { | ||
return function (target: CustomElementConstructor) { | ||
define(name, target) | ||
define(tagName, target) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters