Merge remote-tracking branch 'origin/beta' into createTab-utility-function

This commit is contained in:
Olivia Godone-Maresca
2023-04-06 16:36:25 -04:00
13 changed files with 486 additions and 82 deletions

View File

@ -690,7 +690,9 @@ function createElement(tagName, attributes, classes, textOrElements) {
const element = document.createElement(tagName)
if (attributes) {
Object.entries(attributes).forEach(([key, value]) => {
element.setAttribute(key, value)
if (value !== undefined && value !== null) {
element.setAttribute(key, value)
}
});
}
if (classes) {
@ -709,6 +711,21 @@ function createElement(tagName, attributes, classes, textOrElements) {
return element
}
/*
* Add a listener for arrays
* @param {keyof Array} method
* @param {(args) => {}} callback
*/
Array.prototype.addEventListener = function(method, callback) {
const originalFunction = this[method]
if (originalFunction) {
this[method] = function() {
originalFunction.apply(this, arguments)
callback.apply(this, arguments)
}
}
}
/**
* @typedef {object} TabOpenDetails
* @property {HTMLElement} contentElement