mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-08-09 23:57:42 +02:00
Merge remote-tracking branch 'origin/beta' into createTab-utility-function
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user