mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-17 08:00:02 -04:00
refactor: automatic proxy constructor
This commit is contained in:
parent
eba3e759fd
commit
80d51ed7a7
11 changed files with 192 additions and 131 deletions
|
@ -1,3 +1,4 @@
|
|||
import { client } from ".";
|
||||
import { rewriteCss } from "./shared";
|
||||
|
||||
const cssProperties = [
|
||||
|
@ -13,14 +14,9 @@ const cssProperties = [
|
|||
];
|
||||
// const jsProperties = ["background", "backgroundImage", "mask", "maskImage", "listStyle", "listStyleImage", "borderImage", "borderImageSource", "cursor"];
|
||||
|
||||
CSSStyleDeclaration.prototype.setProperty = new Proxy(
|
||||
CSSStyleDeclaration.prototype.setProperty,
|
||||
{
|
||||
apply(target, thisArg, argArray) {
|
||||
if (cssProperties.includes(argArray[0]))
|
||||
argArray[1] = rewriteCss(argArray[1]);
|
||||
|
||||
return Reflect.apply(target, thisArg, argArray);
|
||||
},
|
||||
}
|
||||
);
|
||||
client.Proxy(CSSStyleDeclaration.prototype, "setProperty", {
|
||||
apply(ctx) {
|
||||
if (cssProperties.includes(ctx.args[0]))
|
||||
ctx.args[1] = rewriteCss(ctx.args[1]);
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue