I'm running version 1.7.5 and for some incomprehensible reason, all of a sudden I'm getting syntax errors (none of my stylesheets have changed since it was working) and I'm including the .js file in the same way):
Object doesn't support this action
I've traced the error to this curious fragment (line 7880):
new(less.Parser)(env).parse(data, function (e, root) {
if (e) { return callback(e, null, null, sheet); }
try {
callback(e, root, data, sheet, webInfo, path);
} catch (e) {
callback(e, null, null, sheet);
}
}, {modifyVars: modifyVars, globalVars: less.globalVars});
...in the loadStyleSheet
function. I don't understand that syntax, in fact, and trying it at the console I get the same error message:
new(less.Parser) # fails
new(less.Parser)(env) # fails
typeof less.Parser # yields "function"
what is going on here?
description: "Object doesn't support this action" message: "Object doesn't support this action" number: -2146827843 stack: "TypeError: Object doesn't support this action\n at Parser (http://localhost:53109/Scripts/System/less-1.7.5.js:360:5)\n at Anonymous function (http://localhost:53109/Scripts/System/less-1.7.5.js:7880:13)\n at Anonymous function (http://localhost:53109/Scripts/System/less-1.7.5.js:7838:13)\n at handleResponse (http://localhost:53109/Scripts/System/less-1.7.5.js:7763:13)\n at doXHR (http://localhost:53109/Scripts/System/less-1.7.5.js:7783:9)\n
at loadFile (http://localhost:53109/Scripts/System/less-1.7.5.js:7832:5)\n at loadStyleSheet (http://localhost:53109/Scripts/System/less-1.7.5.js:7856:5)\n at loadStyleSheets (http://localhost:53109/Scripts/System/less-1.7.5.js:7896:9)\n at less.refresh (http://localhost:53109/Scripts/System/less-1.7.5.js:7973:5)\n at Anonymous function (http://localhost:53109/Scripts/System/less-1.7.5.js:7999:1)"
* Update I *
so the syntax seems to be ok. I can do:
new(function() {})('x')
so given that less.Parser
is a function the code should work... but it doesn't. here's what I get if I look at less.Parser
:
function Parser(env) {
var input, // LeSS input string
i, // current index in `input`
j, // current chunk
saveStack = [], // holds state for backtracking
furthest, // furthest index the par
[Methods]: {...}
__proto__:
function() {
[native code]
}
arguments: null
caller: null
length: 1
prototype: {...}
does anything look amiss?
* Update II *
realising 1.7.5 is far behind the current, I upgraded to 2.5.0 (right off the CDN) but now it breaks elsewhere (line 2440):
if (typeof Object.create === 'undefined') {
var F = function () {};
F.prototype = Error.prototype;
LessError.prototype = new F();
} else {
LessError.prototype = Object.create(Error.prototype); # breaks here
}
with the error:
Object.create: argument is not an Object and is not null
and if I look at Error.prototype
I get undefined
... grr...
after a bit of wailing and gnashing of teeth I figured it out. one of my scripts was setting:
lesson learned: beware with your variable names! it would have been nice if the compiler had complained about it.