mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-16 23:50:02 -04:00
feat: start proxying css getpropertydeclaration
This commit is contained in:
parent
c4070bbd6d
commit
9f04dacd01
6 changed files with 56 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
|||
import { ScramjetClient } from "../client";
|
||||
import { rewriteCss } from "../../shared";
|
||||
import { rewriteCss, unrewriteCss } from "../../shared";
|
||||
|
||||
const cssProperties = [
|
||||
"background",
|
||||
|
@ -21,4 +21,23 @@ export default function (client: ScramjetClient) {
|
|||
ctx.args[1] = rewriteCss(ctx.args[1], client.meta);
|
||||
},
|
||||
});
|
||||
|
||||
client.Proxy("CSSStyleDeclaration.prototype.getPropertyValue", {
|
||||
apply(ctx) {
|
||||
if (cssProperties.includes(ctx.args[0])) {
|
||||
const realProperty = ctx.call();
|
||||
|
||||
return ctx.return(unrewriteCss(realProperty));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
client.Trap("CSSStyleDeclaration.prototype.cssText", {
|
||||
set(ctx, value: string) {
|
||||
ctx.set(rewriteCss(value, client.meta));
|
||||
},
|
||||
get(ctx) {
|
||||
return unrewriteCss(ctx.get());
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue