4 Commits

Author SHA1 Message Date
Christian Hammond
f66757554f Fix synchronously loading/applying stylesheets on page load.
Starting in 2.0, stylesheet loading became asynchronous, through the
usage of promises for both calculating the list of stylesheets and the
initial call to less.refresh(). This resulted in visual issues while
loading on some browsers (noticed in Firefox and Safari), along with
breakages of any custom JavaScript that depended on the computed style
of elements on the page, due to race conditions.

This change preserves the promise for initial page loading, in order to
retain support for less.pageLoadFinished, but immediately executes the
stylesheet scan (through a new less.registerStylesheetsImmediately
function) and the less.refresh() call. That resulting behavior matches
versions of less prior to 2.0.

This unveiled a regression in registering functions, both in the browser
and in unit tests, that was not previously noticed due to the
asynchronous load. Registered functions would have a 'less' variable set
to the less options, and not less itself, when not going through the
asynchronous loading mode. This meant that both unit tests and
real-world function registration would break when the sync page loading
was fixed. Overriding window.less to point to the actual less module and
not less.options during bootstrap fixes this.

This fixes #2317.
2015-04-28 02:08:39 -07:00
Luke Page
31c3d04980 jscs style checking. Fixed whitespace issues. 2015-01-26 23:34:35 +00:00
Luke Page
e9b227c9ac add an onReady option that disables less running on page load. Fixes #2327 2015-01-03 09:12:37 +00:00
Luke Page
9ddd81fc07 seperate out bootstrapping less and the browser api 2014-11-01 17:05:21 +00:00