fix sleeve memory bug

This commit is contained in:
Olivier Gagnon
2021-09-08 23:47:34 -04:00
parent bada8a5f39
commit 2a13db39c7
360 changed files with 5424 additions and 15764 deletions
+1 -3
View File
@@ -5,9 +5,7 @@ import { getElementById } from "./getElementById";
* replacing. Then returns the new cloned element.
* @param elemId The HTML ID to retrieve the element by.
*/
export function clearEventListeners(
elemId: string | HTMLElement,
): HTMLElement | null {
export function clearEventListeners(elemId: string | HTMLElement): HTMLElement | null {
try {
let elem: HTMLElement;
if (typeof elemId === "string") {
+2 -6
View File
@@ -24,17 +24,13 @@ interface IAccordionConfigurationParameters {
* Creates both the header and panel element of an accordion and sets the click handler
* @param params The creation parameters.
*/
export function createAccordionElement(
params: IAccordionConfigurationParameters,
): any[] {
export function createAccordionElement(params: IAccordionConfigurationParameters): any[] {
const liElem: HTMLLIElement = createElement("li") as HTMLLIElement;
const header: HTMLButtonElement = createElement("button", {
class: "accordion-header",
clickListener() {
this.classList.toggle("active");
const pnl: CSSStyleDeclaration = (
this.nextElementSibling as HTMLDivElement
).style;
const pnl: CSSStyleDeclaration = (this.nextElementSibling as HTMLDivElement).style;
pnl.display = pnl.display === "block" ? "none" : "block";
},
id: params.id !== undefined ? `${params.id}-hdr` : undefined,
+7 -28
View File
@@ -102,10 +102,7 @@ interface ICreateElementOptions
tabIndex?: number;
}
function setElementAnchor(
el: HTMLAnchorElement,
params: ICreateElementAnchorOptions,
): void {
function setElementAnchor(el: HTMLAnchorElement, params: ICreateElementAnchorOptions): void {
if (params.text !== undefined) {
el.text = params.text;
}
@@ -117,10 +114,7 @@ function setElementAnchor(
}
}
function setElementInput(
el: HTMLInputElement,
params: ICreateElementInputOptions,
): void {
function setElementInput(el: HTMLInputElement, params: ICreateElementInputOptions): void {
if (params.name !== undefined) {
el.name = params.name;
}
@@ -153,19 +147,13 @@ function setElementInput(
}
}
function setElementLabel(
el: HTMLLabelElement,
params: ICreateElementLabelOptions,
): void {
function setElementLabel(el: HTMLLabelElement, params: ICreateElementLabelOptions): void {
if (params.for !== undefined) {
el.htmlFor = params.for;
}
}
function setElementListeners(
el: HTMLElement,
params: ICreateElementListenerOptions,
): void {
function setElementListeners(el: HTMLElement, params: ICreateElementListenerOptions): void {
// tslint:disable:no-unbound-method
if (params.clickListener !== undefined) {
el.addEventListener("click", params.clickListener);
@@ -188,10 +176,7 @@ function setElementListeners(
// tslint:enable:no-unbound-method
}
function setElementStyle(
el: HTMLElement,
params: ICreateElementStyleOptions,
): void {
function setElementStyle(el: HTMLElement, params: ICreateElementStyleOptions): void {
if (params.display !== undefined) {
el.style.display = params.display;
}
@@ -248,10 +233,7 @@ function setElementStyle(
}
}
function setElementTooltip(
el: HTMLElement,
params: ICreateElementTooltipOptions,
): void {
function setElementTooltip(el: HTMLElement, params: ICreateElementTooltipOptions): void {
if (params.tooltip !== undefined && params.tooltip !== "") {
el.className += " tooltip";
el.appendChild(
@@ -292,10 +274,7 @@ function setElementTooltip(
* @param tagName The HTML tag/element name
* @param params Additional parameters to set on the element
*/
export function createElement(
tagName: string,
params: ICreateElementOptions = {},
): HTMLElement {
export function createElement(tagName: string, params: ICreateElementOptions = {}): HTMLElement {
const el: HTMLElement = document.createElement(tagName);
if (params.id !== undefined) {
+1 -4
View File
@@ -1,9 +1,6 @@
import { createElement } from "./createElement";
export function createOptionElement(
text: string,
value = "",
): HTMLOptionElement {
export function createOptionElement(text: string, value = ""): HTMLOptionElement {
let sanitizedValue: string = value;
if (sanitizedValue === "") {
sanitizedValue = text;
+1 -5
View File
@@ -10,11 +10,7 @@ interface ICreatePopupOptions {
* @param id The (hopefully) unique identifier for the popup container.
* @param elems The collection of HTML Elements to show within the popup.
*/
export function createPopup(
id: string,
elems: HTMLElement[],
options: ICreatePopupOptions = {},
): HTMLDivElement {
export function createPopup(id: string, elems: HTMLElement[], options: ICreatePopupOptions = {}): HTMLDivElement {
const container: HTMLDivElement = createElement("div", {
class: "popup-box-container",
display: "flex",
+1 -3
View File
@@ -12,9 +12,7 @@ export function removeChildrenFromElement(el: string | null | Element): void {
}
try {
const elem: HTMLElement | Element = isString(el)
? getElementById(el as string)
: (el as Element);
const elem: HTMLElement | Element = isString(el) ? getElementById(el as string) : (el as Element);
if (elem instanceof Element) {
while (elem.firstChild !== null) {
+1 -3
View File
@@ -11,9 +11,7 @@ export function removeElement(elem: Element | null): void {
}
if (!(elem instanceof Element)) {
// tslint:disable-next-line:no-console
console.debug(
"The element passed into 'removeElement' was not an instance of an Element.",
);
console.debug("The element passed into 'removeElement' was not an instance of an Element.");
return;
}