File tree 1 file changed +19
-10
lines changed 1 file changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -223,16 +223,21 @@ if (/!watch/.test(location.hash)) {
223
223
//
224
224
// Get all <link> tags with the 'rel' attribute set to "stylesheet/less"
225
225
//
226
- var links = document . getElementsByTagName ( 'link' ) ;
227
-
228
- less . sheets = [ ] ;
226
+ less . registerStylesheets = function ( ) {
227
+ return new PromiseConstructor ( function ( resolve , reject ) {
228
+ var links = document . getElementsByTagName ( 'link' ) ;
229
+ less . sheets = [ ] ;
230
+
231
+ for ( var i = 0 ; i < links . length ; i ++ ) {
232
+ if ( links [ i ] . rel === 'stylesheet/less' || ( links [ i ] . rel . match ( / s t y l e s h e e t / ) &&
233
+ ( links [ i ] . type . match ( typePattern ) ) ) ) {
234
+ less . sheets . push ( links [ i ] ) ;
235
+ }
236
+ }
229
237
230
- for ( var i = 0 ; i < links . length ; i ++ ) {
231
- if ( links [ i ] . rel === 'stylesheet/less' || ( links [ i ] . rel . match ( / s t y l e s h e e t / ) &&
232
- ( links [ i ] . type . match ( typePattern ) ) ) ) {
233
- less . sheets . push ( links [ i ] ) ;
234
- }
235
- }
238
+ resolve ( ) ;
239
+ } ) ;
240
+ } ;
236
241
237
242
//
238
243
// With this function, it's possible to alter variables and re-render
@@ -282,4 +287,8 @@ less.refresh = function (reload, modifyVars) {
282
287
283
288
less . refreshStyles = loadStyles ;
284
289
285
- less . refresh ( less . env === 'development' ) ;
290
+ less . registerStylesheets ( ) . then (
291
+ function ( ) {
292
+ less . refresh ( less . env === 'development' ) ;
293
+ }
294
+ ) ;
You can’t perform that action at this time.
0 commit comments