@@ -8,32 +8,32 @@ import 'vs/css!./codicon/codicon-modifications';
88import 'vs/css!./codicon/codicon-animations' ;
99
1010import { Codicon , iconRegistry } from 'vs/base/common/codicons' ;
11- import { createCSSRule , createStyleSheet } from 'vs/base/browser/dom' ;
12-
13- let codiconStyleSheet : undefined | HTMLStyleElement ;
14-
15- function getOrCreateStyleSheet ( ) : HTMLStyleElement {
16- if ( ! codiconStyleSheet ) {
17- codiconStyleSheet = createStyleSheet ( ) ;
18- codiconStyleSheet . className = 'codiconStyleSheet' ;
19- }
20- return codiconStyleSheet ;
21- }
11+ import { createStyleSheet } from 'vs/base/browser/dom' ;
12+ import { RunOnceScheduler } from 'vs/base/common/async' ;
2213
2314function initialize ( ) {
24- for ( let c of iconRegistry . all ) {
25- register ( c ) ;
15+ let codiconStyleSheet = createStyleSheet ( ) ;
16+ codiconStyleSheet . id = 'codiconStyles' ;
17+
18+ function updateAll ( ) {
19+ const rules = [ ] ;
20+ for ( let c of iconRegistry . all ) {
21+ rules . push ( formatRule ( c ) ) ;
22+ }
23+ codiconStyleSheet . innerHTML = rules . join ( '\n' ) ;
2624 }
27- iconRegistry . onDidRegister ( register ) ;
28- }
2925
26+ const delayer = new RunOnceScheduler ( updateAll , 0 ) ;
27+ iconRegistry . onDidRegister ( ( ) => delayer . schedule ( ) ) ;
28+ delayer . schedule ( ) ;
29+ }
3030
31- function register ( c : Codicon ) {
31+ function formatRule ( c : Codicon ) {
3232 let def = c . definition ;
3333 while ( def instanceof Codicon ) {
3434 def = def . definition ;
3535 }
36- createCSSRule ( `.codicon-${ c . id } :before` , ` content: '${ def . character } '` , getOrCreateStyleSheet ( ) ) ;
36+ return `.codicon-${ c . id } :before { content: '${ def . character } '; }` ;
3737}
3838
3939initialize ( ) ;
0 commit comments