@height: document.body.clientHeight - Not work
It is also possible to access the JavaScript environment:
@height: document.body.clientHeight;
This is information on http://lesscss.org. It's no work!
@screenWidth: document.body.clientWidth;
@screenHeight: document.body.clientHeight;
#leadBody {
background: url('../images/sidebar_body.png') repeat fixed left center #0296BA;
width: @screenWidth;
overflow: hidden;
}
Or
@screenWidth: ~document.body.clientWidth;
@screenHeight: ~ document.body.clientHeight;
#leadBody {
background: url('../images/sidebar_body.png') repeat fixed left center #0296BA;
width: @screenWidth;
overflow: hidden;
}
It's no work
In what browser?
I get this with iOS UIWebView or when emulating iOS+phonegap via Mac Chrome + Fiddle. The error is not on the JS execution, but on trying to use that value elsewhere. For instance, if I set @viewportHeight to clientHeight and then set height: @viewportHeight - 42px; for a class I get an exception every time.
Here's an example trace when doing the above (not using .min for clarity here and removed the base href):
Object # has no method 'operate'
in App.less
at tree.Operation.eval (less-1.3.1.js:2947:14)
at tree.Operation.eval (less-1.3.1.js:2935:30)
at Object.tree.Expression.eval (less-1.3.1.js:2493:34)
at Object.tree.Value.eval (less-1.3.1.js:3527:34)
at tree.Rule.eval (less-1.3.1.js:3056:38)
at Object.tree.Ruleset.eval (ess-1.3.1.js:3136:53)
at Object.tree.Ruleset.eval (less-1.3.1.js:3136:53)
at Object.less.Parser.parser.parse.i [as toCSS] (less-1.3.1.js:545:44)
at less.refresh (less-1.3.1.js:3698:28)
at href (less-1.3.1.js:3775:25)
When I pause on exception, I can see that the "a" var declared on line 2935 is tree.Anonymous and doesn't have the "operate" prototype method (or the prototype of that prototype), as indicated by Chrome's inspector of local scope on the exception:
<exception>: TypeError
a: tree.Anonymous
value: 38
__proto__: Object
compare: function (x) {
eval: function () { return this }
toCSS: function () {
__proto__: Object
b: tree.Dimension
unit: "px"
value: 42
__proto__: Object
env: Object
frames: Array[2]
0: tree.Ruleset
1: tree.Ruleset
length: 2
__proto__: Array[0]
__proto__: Object
temp: undefined
this: tree.Expression
I hope some of this is helpful.
Just tried it with less-1.4.0.js in the 1_4_0 branch and it does recognize it as a type error and throws a more specific exception on line 3316:
<exception>: Object
message: "Operation on an invalid type"
name: "OperationError"
__proto__: Object
a: tree.Anonymous
value: 38
__proto__: Object
b: tree.Dimension
unit: tree.Unit
value: 42
__proto__: Object
env: Object
temp: undefined
this: tree.Operation
FWIW, the red error box message is less informative in that codeline:
Operation on an invalid type
in App.less on line null, column 0:
NaN
Doesn't suggest a way to actually use the value though.
ok, I understand.. yes javascript isn't "parsed".. that bug is discussed in #88 #349 and #476
closing as duplicate