Repository navigation
Method to scan for and register stylesheets - #2233
Conversation
61d730e to
2b8d0b3
Compare
fe474d3 to
7834694
Compare
There was a problem hiding this comment.
Isn't this the same as calling resolve at the end of the function? Would that be simpler?
There was a problem hiding this comment.
Aye aye, fixed. Thanks.
There was a problem hiding this comment.
Less.refresh does the actual transformation, so does less.refresh need to return a promise and then this line here returns that so the promises are chained?
There was a problem hiding this comment.
So, my other PR includes the promise for refresh(). Should I merge it and make the changes you propose?
There was a problem hiding this comment.
Heading out, I'll be back on this on Fri.
There was a problem hiding this comment.
I'll Look later, I can't figure this out on my mobile..
There was a problem hiding this comment.
yeh I got confused between the 2 pull requests.. thought they were 1...
7834694 to
d31be57
Compare
Method to scan for and register stylesheets
|
Hope you don't mind, I made a few tweaks. renamed hasFinished to pageLoadFinished and made it explicit that it will be available immediately (and not changed). |
|
Awesome thanks! Glad we got it knocked out. Id like to beef up the browser docs as well. Any where specific you need help? |
|
Fantastic, yes there is a v2 branch on less-docs - there are basic |
|
Ehm, so just a practical question, does this allow unloading specific stylesheets as per #771? Because as far as I can see this does not, yet that issue states it has been fixed in this pull. |
|
Hi @Greats. This PR addresses the need to dynamically load and unload stylesheets, albeit using a different method than the one detailed in #771. This PR allows you to rescan the DOM after having added or removed stylesheets using some traditional templating means. I'm using AngularJS' After you have the stylesheets you want on the page (not limited to the less.registerStylesheets().then(
function () {
// The new stylesheets have been loaded.
// Now refresh() or modifyVars() to parse the changes.
less.refresh();
}
);Let me know if you're able to get this working with your use case. |
Problem
As web apps become more dynamic developers are now finding they have the need to load/unload stylesheets dynamically. Currently, less does one initial scan for stylesheets on load. This means less will not parse stylesheets added dynamically after page load, even when calling
less.refresh()orless.modifyVars().Proposed Solution
Make the stylesheet loading code available as a method, returning a promise. On resolve, you can
.then()call aless.refresh()orless.modifyVars():