Skip to content

Commit

Permalink
change(compare): Also did caching for sheet.
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDoge committed Nov 8, 2024
1 parent 99e68c1 commit fad5ac8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

### Syntax

[Compare Syntax](https://bafybeic5tz7lvzxxavzvtgdpuccl42x63gex5srukshfhwpii4d3v77pb4.ipfs.dweb.link)
[Compare Syntax](https://bafybeidihk3t2dkpgkqm5ijm5pljwh2pfgoobgjxgdfzuhxntsvh5nyp3q.ipfs.dweb.link)

## Installation 🍙

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ export function css(...params: Parameters<typeof String.raw>) {
return new String(String.raw(...params));
}

export function sheet(css: string) {
const sheet = new CSSStyleSheet();
sheet.replaceSync(css);
const sheetCache = new WeakMap<String, CSSStyleSheet>();
export function sheet(css: String) {
let sheet = sheetCache.get(css);
if (!sheet) {
sheet = new CSSStyleSheet();
sheet.replaceSync(css.toString());
sheetCache.set(css, sheet);
}
return sheet;
}

Expand Down

0 comments on commit fad5ac8

Please sign in to comment.