-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b01bfb4
commit 651b2a3
Showing
34 changed files
with
279 additions
and
194 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,3 +1,6 @@ | ||
export type DominarTagAttributes = { | ||
/** | ||
* Represents the attributes of a Dominar tag. | ||
*/ | ||
export type DominarTagAttributesType = { | ||
[attributeName: string]: string | number | true; | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { attachListenerHelper } from "../helper/attachListener"; | ||
import { DominarTagEventListenersType } from "./types"; | ||
|
||
/** | ||
* Attaches event listeners to an HTML element. | ||
* @param {HTMLElement} element - The HTML element. | ||
* @param {DominarTagEventListenersType} eventListeners - The event listeners to be attached. | ||
* @returns {void} | ||
*/ | ||
export function attachEventListeners( | ||
element: HTMLElement, | ||
eventListeners: DominarTagEventListenersType | ||
): void { | ||
Object.entries(eventListeners).forEach(([type, listener]) => { | ||
attachListenerHelper(element, type, listener); | ||
}); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { detachListenerHelper } from "../helper/detachListener"; | ||
import { DominarEventListenersTypes } from "./types"; | ||
|
||
/** | ||
* Detaches event listeners from an HTML element. | ||
* @param {HTMLElement} element - The HTML element. | ||
* @param {DominarEventListenersTypes | DominarEventListenersTypes[]} eventListenerTypes - The type(s) of event listeners to be detached. | ||
* @returns {void} | ||
*/ | ||
export function detachEventListeners( | ||
element: HTMLElement, | ||
eventListenerTypes: | ||
| DominarEventListenersTypes | ||
| DominarEventListenersTypes[] | ||
): void { | ||
if (typeof eventListenerTypes === "string") | ||
detachListenerHelper(document.body, eventListenerTypes); | ||
else if (typeof eventListenerTypes === "object") | ||
eventListenerTypes.forEach((type) => { | ||
detachListenerHelper(element, type); | ||
}); | ||
} |
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,3 +1,11 @@ | ||
export type DominarTagEventListeners = { | ||
/** | ||
* Represents the event listeners of a Dominar tag. | ||
*/ | ||
export type DominarTagEventListenersType = { | ||
[K in keyof HTMLElementEventMap]?: (ev: HTMLElementEventMap[K]) => void; | ||
}; | ||
|
||
/** | ||
* Represents the types of event listeners supported by HTMLElementEventMap. | ||
*/ | ||
export type DominarEventListenersTypes = keyof HTMLElementEventMap; |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function attachListenerHelper(element, type, listener) { | ||
element[`on${type}`] = listener; | ||
} |
Oops, something went wrong.