improving authpage

This commit is contained in:
metacryst
2026-03-24 06:07:29 -05:00
parent c5b71add07
commit a87d521a4f
3 changed files with 137 additions and 70 deletions

View File

@@ -1,6 +1,7 @@
/*
Sam Russell
Captured Sun
2.24.26 - Allowing state() to watch other elements
2.21.26 - Making state() be called on initial definition, fixing fontSize so it works with clamp(), other strings
2.20.26 - Adding state()
2.19.26 - Adding dynamicText()
@@ -700,19 +701,34 @@ HTMLElement.prototype.horizontalAlign = function (value) {
/* Elements */
HTMLElement.prototype.state = function(attr, cb) {
HTMLElement.prototype.state = function(arg1, arg2, arg3) {
let el;
let attr;
let cb;
if(arg3) {
el = arg1
attr = arg2
cb = arg3
} else {
el = this
attr = arg1
cb = arg2
}
if (attr !== attr.toLowerCase()) {
throw new Error(`quill: dynamicText() attr "${attr}" must be lowercase`);
}
new MutationObserver(() => {
const value = this.getAttribute(attr);
let handler = () => {
const value = el.getAttribute(attr);
cb.call(this, value)
})
.observe(this, { attributes: true, attributeFilter: [attr] });
}
const value = this.getAttribute(attr);
cb.call(this, value)
new MutationObserver(handler)
.observe(el, { attributes: true, attributeFilter: [attr] });
handler()
return this
}
@@ -1230,22 +1246,23 @@ HTMLElement.prototype.removeAllListeners = function() {
/* ATTRIBUTES */
HTMLElement.prototype.attr = function(attributes) {
if (
typeof attributes !== "object" ||
attributes === null ||
Array.isArray(attributes)
) {
throw new TypeError("attr() expects an object with key-value pairs");
}
for (const [key, value] of Object.entries(attributes)) {
if(value === null) {
this.removeAttribute(key)
} else {
this.setAttribute(key, value);
HTMLElement.prototype.attr = function(arg1, arg2) {
if(typeof arg1 === "object") {
for (const [key, value] of Object.entries(arg1)) {
if(value === null) {
this.removeAttribute(key)
} else {
this.setAttribute(key, value);
}
}
}
return this;
return this;
} else if(typeof arg1 === "string" && arg2) {
this.setAttribute(arg1, arg2)
return this
} else if(typeof arg1 === "string") {
return this.getAttribute("")
} else {
throw new TypeError("wrong parameter for attr(): ", arg1);
}
};