adding state() to quill, after-request error handling to login

This commit is contained in:
metacryst
2026-03-20 00:36:33 -05:00
parent dd1ec2c374
commit 41a9c9d269
2 changed files with 38 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
/*
Sam Russell
Captured Sun
2.20.26 - Adding state()
2.19.26 - Adding dynamicText()
2.16.26 - Adding event objects to the onTouch callbacks
1.16.26 - Moving nav event dispatch out of pushState, adding null feature to attr()
@@ -692,6 +693,20 @@ HTMLElement.prototype.horizontalAlign = function (value) {
/* Elements */
HTMLElement.prototype.state = function(attr, cb) {
if (attr !== attr.toLowerCase()) {
throw new Error(`quill: dynamicText() attr "${attr}" must be lowercase`);
}
new MutationObserver(() => {
const value = this.getAttribute(attr);
cb.call(this, value)
})
.observe(this, { attributes: true, attributeFilter: [attr] });
return this
}
HTMLElement.prototype.dynamicText = function(attr, template) {
// Set initial text if attr already has a value
if (attr !== attr.toLowerCase()) {
@@ -702,7 +717,6 @@ HTMLElement.prototype.dynamicText = function(attr, template) {
}
new MutationObserver(() => {
console.log("mutateing")
const value = this.getAttribute(attr);
this.innerText = template.replace('{{}}', value ?? '');
}).observe(this, { attributes: true, attributeFilter: [attr] });