2022-02-01 00:07:49 +01:00
|
|
|
// Caution before editing - For latest builds, this module is replaced with emptiness and thus not imported (see build-scripts/bundle.js)
|
2021-06-03 22:50:33 +02:00
|
|
|
import "lit/polyfill-support";
|
2021-09-30 01:34:52 +02:00
|
|
|
|
2023-12-04 14:34:31 +01:00
|
|
|
import ResizeObserver from "@lit-labs/virtualizer/polyfills/resize-observer-polyfill/ResizeObserver";
|
2023-02-02 20:20:23 +01:00
|
|
|
|
2023-12-04 14:34:31 +01:00
|
|
|
window.ResizeObserver = ResizeObserver;
|
2023-02-02 20:20:23 +01:00
|
|
|
|
2020-10-14 22:20:39 +02:00
|
|
|
// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/append()/append().md
|
|
|
|
(function (arr) {
|
2021-07-15 12:08:04 +02:00
|
|
|
arr.forEach((item) => {
|
2020-10-14 22:20:39 +02:00
|
|
|
if (Object.prototype.hasOwnProperty.call(item, "append")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Object.defineProperty(item, "append", {
|
|
|
|
configurable: true,
|
|
|
|
enumerable: true,
|
|
|
|
writable: true,
|
|
|
|
value: function append(...argArr) {
|
|
|
|
const docFrag = document.createDocumentFragment();
|
|
|
|
|
2021-07-15 12:08:04 +02:00
|
|
|
argArr.forEach((argItem) => {
|
2020-10-14 22:20:39 +02:00
|
|
|
const isNode = argItem instanceof Node;
|
|
|
|
docFrag.appendChild(
|
|
|
|
isNode ? argItem : document.createTextNode(String(argItem))
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.appendChild(docFrag);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})([Element.prototype, Document.prototype, DocumentFragment.prototype]);
|
2021-06-03 22:50:33 +02:00
|
|
|
|
|
|
|
// Source: https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNames
|
|
|
|
if (Element.prototype.getAttributeNames === undefined) {
|
|
|
|
Element.prototype.getAttributeNames = function () {
|
|
|
|
const attributes = this.attributes;
|
|
|
|
const length = attributes.length;
|
|
|
|
const result = new Array(length);
|
|
|
|
for (let i = 0; i < length; i++) {
|
|
|
|
result[i] = attributes[i].name;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
}
|
2023-05-04 15:49:28 +02:00
|
|
|
|
|
|
|
// Source: https://gist.github.com/rebelchris/365f26f95d7e9f432f64f21886d9b9ef
|
|
|
|
if (!Element.prototype.toggleAttribute) {
|
|
|
|
Element.prototype.toggleAttribute = function (name, force) {
|
|
|
|
if (force !== undefined) {
|
|
|
|
force = !!force;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.hasAttribute(name)) {
|
|
|
|
if (force) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.removeAttribute(name);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (force === false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setAttribute(name, "");
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
}
|