File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1+ export function memoize < T extends HTMLElement > (
2+ fn : ( ) => T ,
3+ key : any ,
4+ cache : Record < string , T >
5+ ) : T {
6+ if ( cache [ key ] ) {
7+ return cache [ key ] ;
8+ }
9+ const element = fn ( ) ;
10+ cache [ key ] = element ;
11+ return element ;
12+ }
Original file line number Diff line number Diff line change 88} from "dreamland/core" ;
99import { Icon } from "./ui/Icon" ;
1010import { IconButton } from "./Omnibox" ;
11+ import { memoize } from "./memoize" ;
12+
13+ let cache = { } ;
1114
1215export const DragTab : Component < {
1316 active : boolean ;
@@ -43,7 +46,13 @@ export const DragTab: Component<{
4346 } }
4447 >
4548 < div class = { use ( this . active ) . map ( ( x ) => `main ${ x ? "active" : "" } ` ) } >
46- < img src = { use ( this . icon ) } />
49+ { memoize (
50+ ( ) => (
51+ < img src = { use ( this . icon ) } />
52+ ) ,
53+ this . icon ,
54+ cache
55+ ) }
4756 < span > { use ( this . title ) } </ span >
4857 < button
4958 class = "close"
You can’t perform that action at this time.
0 commit comments