Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fix for #320 #333 Node.js 0.5+ removes require.paths array #377

Closed
wants to merge 11 commits into from

7 participants

@kixxauth

Although I did not add any new tests to prove this fix is complete, the current test suite is passing on the latest Node.js 0.5.5

Addresses issues #320 and #333

Kristoffer W... added some commits
Kristoffer Walker bug: window.localStorage in Firefox
Firefox 3.6.4 throws an error when trying to access `window.localStorage`.
(at least from `chrome://` URLs in extensions if not more)
6d620c9
Kristoffer Walker Support chrome: and resource: location protocols.
XMLHttpRequest tried to load `chrome:` and `resource:` protocols as if
they were not local. Change isFileProtocol flag to accurately represent
them.
7f52dc5
Kristoffer Walker Use .overrideMimeType() for Firefox XHR
By overriding the mime type of the default XML to 'text/css' we get rid
of the automatic XML parsing and DOM building that XMLHttpRequest tries
to do whenever it gets a response.
550efb6
Kristoffer Walker Merge branch 'master' of git://github.com/cloudhead/less.js
Conflicts:

	lib/less/browser.js
499bc1c
Kristoffer Walker Merge branch 'master' of git://github.com/cloudhead/less.js into inte…
…grate
5a634b5
Kristoffer Walker change require calls to use relative paths
 On branch kris
	modified:   functions.js
	modified:   index.js
	modified:   parser.js
	modified:   tree.js
	modified:   tree/alpha.js
	modified:   tree/anonymous.js
	modified:   tree/call.js
	modified:   tree/color.js
	modified:   tree/comment.js
	modified:   tree/dimension.js
	modified:   tree/directive.js
	modified:   tree/element.js
	modified:   tree/expression.js
	modified:   tree/import.js
	modified:   tree/javascript.js
	modified:   tree/keyword.js
	modified:   tree/mixin.js
	modified:   tree/operation.js
	modified:   tree/quoted.js
	modified:   tree/rule.js
	modified:   tree/ruleset.js
	modified:   tree/selector.js
	modified:   tree/url.js
	modified:   tree/value.js
	modified:   tree/variable.js
ea58e1d
Kristoffer Walker tests are running - albeit failing
 On branch kris
	modified:   benchmark/less-benchmark.js
	modified:   bin/lessc
	modified:   lib/less/index.js
	modified:   test/less-test.js
be557ce
Kristoffer Walker remove leftover merge cruft
 On branch kris
	modified:   lib/less/index.js
cf0013f
Kristoffer Walker tests are passing
 On branch kris
	modified:   lib/less/tree.js
3cc04d4
@NateFerrero

Urgent! This would help so much. For a temporary fix by unknownbrackets, see https://gist.github.com/1176345

Kristoffer Walker bug: change `this` to `less` in index.js
Thanks to
less/less.js#377 (comment)

 On branch master
	modified:   lib/less/index.js
a754101
@kixxauth

I don't believe there is any test coverage for index.js. Also, I don't use index.js in my own projects, but just import the Parser module directly, so there may be more problems lurking. Let me know.

@NateFerrero

I like to use the concise format:

require('less').render('less code', callback);

I guess one could do it directly. After making the change in my
comment, at least the render function works. Thanks!

Kristoffer Walker bug: module.id doesn't work in browser require()
In Less.js for the browser, a stub for require() needs to be used in
non-commonjs environments, which cannot support module.id

 On branch master
	modified:   lib/less/tree.js
197e020
@kixxauth

Also, just discovered and fixed a bug this patch introduced into the browser build. But again, this is untested and there may be more problems still lurking in index.js and the browser side build.

@gerardo

What's the status of this pull request?

@kixxauth

gerardo:

I've been using my own fork for the time being. It's been in my development environment, as well as in production since this pull request was made, without a problem. So, for now:

https://github.com/kixxauth/less.js

@gerardo

Nice @kixxauth, thanks!

@ryall

Tested this and it works.

Thanks!

@fxfred

I'm waiting for this to update my node to 0.6.0. Now I'm still in 0.4.12.
Is there anyway I can use npm to install https://github.com/kixxauth/less.js instead of the master one?

Thanks

@neonstalwart

you can use npm to install from a url - use its help to find out how.

@cloudhead
Owner

Can't merge this anymore, as the commit wasn't isolated in its own branch. I will cherry-pick.

@cloudhead cloudhead closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 29, 2010
  1. bug: window.localStorage in Firefox

    Kristoffer Walker authored
    Firefox 3.6.4 throws an error when trying to access `window.localStorage`.
    (at least from `chrome://` URLs in extensions if not more)
  2. Support chrome: and resource: location protocols.

    Kristoffer Walker authored
    XMLHttpRequest tried to load `chrome:` and `resource:` protocols as if
    they were not local. Change isFileProtocol flag to accurately represent
    them.
  3. Use .overrideMimeType() for Firefox XHR

    Kristoffer Walker authored
    By overriding the mime type of the default XML to 'text/css' we get rid
    of the automatic XML parsing and DOM building that XMLHttpRequest tries
    to do whenever it gets a response.
Commits on Oct 5, 2010
  1. Merge branch 'master' of git://github.com/cloudhead/less.js

    Kristoffer Walker authored
    Conflicts:
    
    	lib/less/browser.js
Commits on Sep 6, 2011
  1. Merge branch 'master' of git://github.com/cloudhead/less.js into inte…

    Kristoffer Walker authored
    …grate
  2. change require calls to use relative paths

    Kristoffer Walker authored
     On branch kris
    	modified:   functions.js
    	modified:   index.js
    	modified:   parser.js
    	modified:   tree.js
    	modified:   tree/alpha.js
    	modified:   tree/anonymous.js
    	modified:   tree/call.js
    	modified:   tree/color.js
    	modified:   tree/comment.js
    	modified:   tree/dimension.js
    	modified:   tree/directive.js
    	modified:   tree/element.js
    	modified:   tree/expression.js
    	modified:   tree/import.js
    	modified:   tree/javascript.js
    	modified:   tree/keyword.js
    	modified:   tree/mixin.js
    	modified:   tree/operation.js
    	modified:   tree/quoted.js
    	modified:   tree/rule.js
    	modified:   tree/ruleset.js
    	modified:   tree/selector.js
    	modified:   tree/url.js
    	modified:   tree/value.js
    	modified:   tree/variable.js
  3. tests are running - albeit failing

    Kristoffer Walker authored
     On branch kris
    	modified:   benchmark/less-benchmark.js
    	modified:   bin/lessc
    	modified:   lib/less/index.js
    	modified:   test/less-test.js
  4. remove leftover merge cruft

    Kristoffer Walker authored
     On branch kris
    	modified:   lib/less/index.js
  5. tests are passing

    Kristoffer Walker authored
     On branch kris
    	modified:   lib/less/tree.js
Commits on Sep 7, 2011
  1. bug: change `this` to `less` in index.js

    Kristoffer Walker authored
    Thanks to
    less/less.js#377 (comment)
    
     On branch master
    	modified:   lib/less/index.js
  2. bug: module.id doesn't work in browser require()

    Kristoffer Walker authored
    In Less.js for the browser, a stub for require() needs to be used in
    non-commonjs environments, which cannot support module.id
    
     On branch master
    	modified:   lib/less/tree.js
This page is out of date. Refresh to see the latest.
View
4 benchmark/less-benchmark.js
@@ -2,9 +2,7 @@ var path = require('path'),
fs = require('fs'),
sys = require('sys');
-require.paths.unshift(__dirname, path.join(__dirname, '..'));
-
-var less = require('lib/less');
+var less = require('../lib/less');
var file = path.join(__dirname, 'benchmark.less');
if (process.argv[2]) { file = path.join(process.cwd(), process.argv[2]) }
View
2  bin/lessc
@@ -4,8 +4,6 @@ var path = require('path'),
fs = require('fs'),
sys = require('sys');
-require.paths.unshift(path.join(__dirname, '..', 'lib'));
-
var less = require('less');
var args = process.argv.slice(1);
var options = {
View
1  lib/less/browser.js
@@ -51,7 +51,6 @@ if (less.env === 'development') {
}
var cache;
-
try {
cache = (typeof(window.localStorage) === 'undefined') ? null : window.localStorage;
} catch (_) {
View
2  lib/less/functions.js
@@ -182,4 +182,4 @@ function clamp(val) {
return Math.min(1, Math.max(0, val));
}
-})(require('less/tree'));
+})(require('./tree'));
View
14 lib/less/index.js
@@ -2,13 +2,11 @@ var path = require('path'),
sys = require('sys'),
fs = require('fs');
-require.paths.unshift(path.join(__dirname, '..'));
-
var less = {
version: [1, 1, 3],
- Parser: require('less/parser').Parser,
- importer: require('less/parser').importer,
- tree: require('less/tree'),
+ Parser: require('./parser').Parser,
+ importer: require('./parser').importer,
+ tree: require('./tree'),
render: function (input, options, callback) {
options = options || {};
@@ -16,7 +14,7 @@ var less = {
callback = options, options = {};
}
- var parser = new(this.Parser)(options),
+ var parser = new(less.Parser)(options),
ee;
if (callback) {
@@ -81,7 +79,7 @@ var less = {
'call', 'url', 'alpha', 'import',
'mixin', 'comment', 'anonymous', 'value', 'javascript'
].forEach(function (n) {
- require(path.join('less', 'tree', n));
+ require('./tree/'+ n);
});
less.Parser.importer = function (file, paths, callback) {
@@ -117,7 +115,7 @@ less.Parser.importer = function (file, paths, callback) {
}
}
-require('less/functions');
+require('./functions');
for (var k in less) { exports[k] = less[k] }
View
2  lib/less/parser.js
@@ -2,7 +2,7 @@ var less, tree;
if (typeof(window) === 'undefined') {
less = exports,
- tree = require('less/tree');
+ tree = require('./tree');
} else {
if (typeof(window.less) === 'undefined') { window.less = {} }
less = window.less,
View
4 lib/less/tree.js
@@ -1,10 +1,10 @@
-require('less/tree').find = function (obj, fun) {
+require('./tree').find = function (obj, fun) {
for (var i = 0, r; i < obj.length; i++) {
if (r = fun.call(obj, obj[i])) { return r }
}
return null;
};
-require('less/tree').jsify = function (obj) {
+require('./tree').jsify = function (obj) {
if (Array.isArray(obj.value) && (obj.value.length > 1)) {
return '[' + obj.value.map(function (v) { return v.toCSS(false) }).join(', ') + ']';
} else {
View
2  lib/less/tree/alpha.js
@@ -14,4 +14,4 @@ tree.Alpha.prototype = {
}
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/anonymous.js
@@ -10,4 +10,4 @@ tree.Anonymous.prototype = {
eval: function () { return this }
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/call.js
@@ -42,4 +42,4 @@ tree.Call.prototype = {
}
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/color.js
@@ -98,4 +98,4 @@ tree.Color.prototype = {
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/comment.js
@@ -11,4 +11,4 @@ tree.Comment.prototype = {
eval: function () { return this }
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/dimension.js
@@ -31,4 +31,4 @@ tree.Dimension.prototype = {
}
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/directive.js
@@ -30,4 +30,4 @@ tree.Directive.prototype = {
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) }
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/element.js
@@ -32,4 +32,4 @@ tree.Combinator.prototype.toCSS = function (env) {
}[this.value];
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/expression.js
@@ -20,4 +20,4 @@ tree.Expression.prototype = {
}
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/import.js
@@ -74,4 +74,4 @@ tree.Import.prototype = {
}
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/javascript.js
@@ -47,5 +47,5 @@ tree.JavaScript.prototype = {
}
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/keyword.js
@@ -6,4 +6,4 @@ tree.Keyword.prototype = {
toCSS: function () { return this.value }
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/mixin.js
@@ -103,4 +103,4 @@ tree.mixin.Definition.prototype = {
}
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/operation.js
@@ -29,4 +29,4 @@ tree.operate = function (op, a, b) {
}
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/quoted.js
@@ -26,4 +26,4 @@ tree.Quoted.prototype = {
}
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/rule.js
@@ -35,4 +35,4 @@ tree.Shorthand.prototype = {
eval: function () { return this }
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/ruleset.js
@@ -209,4 +209,4 @@ tree.Ruleset.prototype = {
}
}
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/selector.js
@@ -39,4 +39,4 @@ tree.Selector.prototype.toCSS = function (env) {
}).join('');
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/url.js
@@ -22,4 +22,4 @@ tree.URL.prototype = {
}
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/value.js
@@ -21,4 +21,4 @@ tree.Value.prototype = {
}
};
-})(require('less/tree'));
+})(require('../tree'));
View
2  lib/less/tree/variable.js
@@ -21,4 +21,4 @@ tree.Variable.prototype = {
}
};
-})(require('less/tree'));
+})(require('../tree'));
View
4 test/less-test.js
@@ -2,9 +2,7 @@ var path = require('path'),
fs = require('fs'),
sys = require('sys');
-require.paths.unshift(__dirname, path.join(__dirname, '..'));
-
-var less = require('lib/less');
+var less = require('../lib/less');
less.tree.functions.add = function (a, b) {
return new(less.tree.Dimension)(a.value + b.value);
Something went wrong with that request. Please try again.