Created
December 3, 2010 19:55
-
-
Save neonstalwart/727464 to your computer and use it in GitHub Desktop.
fix for less.js issue 132
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/less/tree/url.js b/lib/less/tree/url.js | |
index 33b05b9..f53f1ea 100644 | |
--- a/lib/less/tree/url.js | |
+++ b/lib/less/tree/url.js | |
@@ -14,8 +14,15 @@ tree.URL = function (val, paths) { | |
}; | |
tree.URL.prototype = { | |
toCSS: function () { | |
- return "url(" + (this.attrs ? 'data:' + this.attrs.mime + this.attrs.charset + this.attrs.base64 + this.attrs.data | |
- : this.value.toCSS()) + ")"; | |
+ var attrs = this.attrs, | |
+ val = this.value, | |
+ paths = this.paths; | |
+ // adjust the paths for lessc | |
+ if (val && !/^(?:https?:\/|file:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) === 'undefined') { | |
+ val.value = paths[0].replace(/\/?$/, '/') + val.value; | |
+ } | |
+ return "url(" + (attrs ? 'data:' + attrs.mime + attrs.charset + attrs.base64 + attrs.data | |
+ : val.toCSS()) + ")"; | |
}, | |
eval: function (ctx) { | |
return this.attrs ? this : new(tree.URL)(this.value.eval(ctx), this.paths); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment