diff --git a/src/client/client.ts b/src/client/client.ts index c3166bb..a39aad3 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -125,19 +125,19 @@ export class ScramjetClient { { get: (target, prop: string) => { if (prop in target) { - return target[prop]; - } else { - const split = prop.split("."); - const realProp = split.pop(); - const realTarget = split.reduce((a, b) => a?.[b], this.global); - - if (!realTarget) return; - - const original = Reflect.get(realTarget, realProp); - target[prop] = original; - return target[prop]; } + + const split = prop.split("."); + const realProp = split.pop(); + const realTarget = split.reduce((a, b) => a?.[b], this.global); + + if (!realTarget) return; + + const original = Reflect.get(realTarget, realProp); + target[prop] = original; + + return target[prop]; }, } ); @@ -146,22 +146,19 @@ export class ScramjetClient { { get: (target, prop: string) => { if (prop in target) { - return target[prop]; - } else { - const split = prop.split("."); - const realProp = split.pop(); - const realTarget = split.reduce((a, b) => a?.[b], this.global); - - if (!realTarget) return; - - const original = nativeGetOwnPropertyDescriptor( - realTarget, - realProp - ); - target[prop] = original; - return target[prop]; } + + const split = prop.split("."); + const realProp = split.pop(); + const realTarget = split.reduce((a, b) => a?.[b], this.global); + + if (!realTarget) return; + + const original = nativeGetOwnPropertyDescriptor(realTarget, realProp); + target[prop] = original; + + return target[prop]; }, } ); diff --git a/src/client/dom/attr.ts b/src/client/dom/attr.ts index 42089bf..6505e08 100644 --- a/src/client/dom/attr.ts +++ b/src/client/dom/attr.ts @@ -65,10 +65,18 @@ export default function (client: ScramjetClient, _self: typeof window) { client.Trap("Attr.prototype.value", { get(ctx) { - return ctx.this.ownerElement?.getAttribute(ctx.this.name); + if (ctx.this?.ownerElement) { + return ctx.this.ownerElement.getAttribute(ctx.this.name); + } + + return ctx.get(); }, set(ctx, value) { - return ctx.this.ownerElement?.setAttribute(ctx.this.name, value); + if (ctx.this?.ownerElement) { + return ctx.this.ownerElement.setAttribute(ctx.this.name, value); + } + + return ctx.set(value); }, }); } diff --git a/src/client/dom/element.ts b/src/client/dom/element.ts index 4c3b2af..64e2abc 100644 --- a/src/client/dom/element.ts +++ b/src/client/dom/element.ts @@ -143,6 +143,12 @@ export default function (client: ScramjetClient, self: typeof window) { }, }); + client.Proxy("Element.prototype.getAttributeNode", { + apply(ctx) { + if (ctx.args[0].startsWith("scramjet-attr")) return ctx.return(null); + }, + }); + client.Proxy("Element.prototype.hasAttribute", { apply(ctx) { if (ctx.args[0].startsWith("scramjet-attr")) return ctx.return(false);