Fix for in without hasOwnProperty

This commit is contained in:
Luke Page
2014-01-10 20:09:36 +00:00
parent 0af345e086
commit 6dfb00751c
8 changed files with 44 additions and 30 deletions

View File

@@ -41,7 +41,9 @@ less.poll = less.poll || (isFileProtocol ? 1000 : 1500);
//Setup user functions
if (less.functions) {
for(var func in less.functions) {
less.tree.functions[func] = less.functions[func];
if (less.functions.hasOwnProperty(func)) {
less.tree.functions[func] = less.functions[func];
}
}
}

View File

@@ -671,12 +671,16 @@ function initFunctions() {
// math
for (f in mathFunctions) {
tf[f] = _math.bind(null, Math[f], mathFunctions[f]);
if (mathFunctions.hasOwnProperty(f)) {
tf[f] = _math.bind(null, Math[f], mathFunctions[f]);
}
}
// color blending
for (f in colorBlendMode) {
tf[f] = colorBlend.bind(null, colorBlendMode[f]);
if (colorBlendMode.hasOwnProperty(f)) {
tf[f] = colorBlend.bind(null, colorBlendMode[f]);
}
}
// default

View File

@@ -224,4 +224,4 @@ require('./join-selector-visitor.js');
require('./to-css-visitor.js');
require('./source-map-output.js');
for (var k in less) { exports[k] = less[k]; }
for (var k in less) { if (less.hasOwnProperty(k)) { exports[k] = less[k]; }}

View File

@@ -79,4 +79,4 @@ var lessc_helper = {
};
// Exports helper functions
for (var h in lessc_helper) { exports[h] = lessc_helper[h]; }
for (var h in lessc_helper) { if (lessc_helper.hasOwnProperty(h)) { exports[h] = lessc_helper[h]; }}

View File

@@ -101,11 +101,14 @@
if (this._outputSourceFiles) {
for(var filename in this._contentsMap) {
var source = this._contentsMap[filename];
if (this._contentsIgnoredCharsMap[filename]) {
source = source.slice(this._contentsIgnoredCharsMap[filename]);
if (this._contentsMap.hasOwnProperty(filename))
{
var source = this._contentsMap[filename];
if (this._contentsIgnoredCharsMap[filename]) {
source = source.slice(this._contentsIgnoredCharsMap[filename]);
}
this._sourceMapGenerator.setSourceContent(this.normalizeFilename(filename), source);
}
this._sourceMapGenerator.setSourceContent(this.normalizeFilename(filename), source);
}
}

View File

@@ -23,14 +23,17 @@ tree.JavaScript.prototype = {
index: this.index };
}
for (var k in env.frames[0].variables()) {
/*jshint loopfunc:true */
context[k.slice(1)] = {
value: env.frames[0].variables()[k].value,
toJS: function () {
return this.value.eval(env).toCSS();
}
};
var variables = env.frames[0].variables();
for (var k in variables) {
if (variables.hasOwnProperty(k)) {
/*jshint loopfunc:true */
context[k.slice(1)] = {
value: variables[k].value,
toJS: function () {
return this.value.eval(env).toCSS();
}
};
}
}
try {

View File

@@ -87,7 +87,7 @@ tree.mixin.Call.prototype = {
defaultFunc.reset();
for (m in candidates) {
for (m = 0; m < candidates.length; m++) {
candidate = candidates[m];
if (!candidate.matchIfDefault || (candidate.matchIfDefaultValue == (candidates.length == 1))) {
try {

View File

@@ -11,18 +11,20 @@
// add .typeIndex to tree node types for lookup table
var key, child;
for (key in parent) {
child = parent[key];
switch (typeof child) {
case "function":
// ignore bound functions directly on tree which do not have a prototype
// or aren't nodes
if (child.prototype && child.prototype.type) {
child.prototype.typeIndex = ticker++;
}
break;
case "object":
ticker = indexNodeTypes(child, ticker);
break;
if (parent.hasOwnProperty(key)) {
child = parent[key];
switch (typeof child) {
case "function":
// ignore bound functions directly on tree which do not have a prototype
// or aren't nodes
if (child.prototype && child.prototype.type) {
child.prototype.typeIndex = ticker++;
}
break;
case "object":
ticker = indexNodeTypes(child, ticker);
break;
}
}
}
return ticker;