mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 23:10:02 -04:00
fix: attr proxy
This commit is contained in:
parent
2a81385540
commit
a36b829f7a
1 changed files with 9 additions and 32 deletions
|
@ -34,38 +34,6 @@ export default function (client: ScramjetClient, self: typeof window) {
|
|||
|
||||
if (!this.has(target, prop)) return undefined;
|
||||
|
||||
if (value instanceof Attr) {
|
||||
const attr = value;
|
||||
|
||||
return new Proxy(attr, {
|
||||
get(target, prop) {
|
||||
if (
|
||||
prop === "value" ||
|
||||
prop === "nodeValue" ||
|
||||
prop === "textContent"
|
||||
) {
|
||||
// we're using the proxied getAttribute here
|
||||
return target.ownerElement.getAttribute(target.name);
|
||||
}
|
||||
|
||||
return Reflect.get(target, prop);
|
||||
},
|
||||
set(target, prop, value) {
|
||||
if (
|
||||
prop === "value" ||
|
||||
prop === "nodeValue" ||
|
||||
prop === "textContent"
|
||||
) {
|
||||
target.ownerElement.setAttribute(target.name, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return Reflect.set(target, prop, value);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return value;
|
||||
},
|
||||
ownKeys(target) {
|
||||
|
@ -85,4 +53,13 @@ export default function (client: ScramjetClient, self: typeof window) {
|
|||
return proxy;
|
||||
},
|
||||
});
|
||||
|
||||
client.Trap("Attr.prototype.value", {
|
||||
get(ctx) {
|
||||
return ctx.this.ownerElement.getAttribute(ctx.this.name);
|
||||
},
|
||||
set(ctx, value) {
|
||||
return ctx.this.ownerElement.setAttribute(ctx.this.name, value);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue