This commit is contained in:
Geoff Doty 2025-03-27 12:27:49 -05:00
parent bafe02e7ed
commit 83ba66afa4
1 changed files with 8 additions and 7 deletions

View File

@ -22,7 +22,7 @@ export class Mite {
if (!this.root) throw new Error(`Element ${selector} not found`);
this.state = {};
for (let key in options.state) {
for (const key in options.state) {
this.state[key] = signal(options.state[key]);
}
@ -32,8 +32,8 @@ export class Mite {
unmounted: options.unmounted || (() => {})
};
for (let key in this.methods) {
if (typeof this.methods[key] === 'function') {
for (const key in this.methods) {
if (typeof this.methods[key] === "function") {
this.methods[key] = this.methods[key].bind(this);
}
}
@ -55,7 +55,7 @@ export class Mite {
this.scanAndBind(this.root);
for (let key in this.state) {
for (const key in this.state) {
this.update(key);
}
}
@ -78,7 +78,7 @@ export class Mite {
});
}
} else if (node.nodeType === Node.ELEMENT_NODE) {
for (let attr of node.attributes) {
for (const attr of node.attributes) {
const matches = attr.value.match(/{(\w+)}/g);
if (matches) {
if (attr.name.startsWith('@')) {
@ -181,8 +181,8 @@ export class Mite {
binding.node.style.display = this.state[key].value ? '' : 'none';
break;
case 'each':
let parent = this.root.querySelector(binding.parentSelector);
case 'each': {
const parent = this.root.querySelector(binding.parentSelector);
if (!parent) {
console.error(`Parent node (${binding.parentSelector}) not found for r-each="${binding.originalReach}"`);
return;
@ -223,6 +223,7 @@ export class Mite {
parent.appendChild(clone);
});
break;
}
}
});
}