mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 22:40:01 -04:00
better dev server and css api rewriting
This commit is contained in:
parent
7303441341
commit
d8f1f78d53
4 changed files with 72 additions and 18 deletions
21
src/client/css.ts
Normal file
21
src/client/css.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
const cssProperties = ["background", "background-image", "mask", "mask-image", "list-style", "list-style-image", "border-image", "border-image-source", "cursor"];
|
||||
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] = self.__scramjet$bundle.rewriters.rewriteCss(argArray[1]);
|
||||
|
||||
return Reflect.apply(target, thisArg, argArray);
|
||||
},
|
||||
});
|
||||
|
||||
jsProperties.forEach((prop) => {
|
||||
const propDescriptor = Object.getOwnPropertyDescriptor(CSSStyleDeclaration.prototype, prop);
|
||||
|
||||
Object.defineProperty(CSSStyleDeclaration.prototype, prop, {
|
||||
set(v) {
|
||||
propDescriptor.set.call(this, self.__scramjet$bundle.rewriters.rewriteCss(v));
|
||||
},
|
||||
})
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue