asyncPostProcess is fired too often when the array.prototype has been extended #380

Closed
arose opened this Issue Jun 20, 2012 · 3 comments

Comments

Projects
None yet
2 participants

arose commented Jun 20, 2012

in slick.grid.js::asyncPostProcessRows there is a loop

for (var columnIdx in cacheEntry.cellNodesByColumnIdx) {
    ...
}

cacheEntry.cellNodesByColumnIdx is an array, so when array.prototype has been extended with e.g. a unique function, the loop is also called for 'unique'.

maybe use something like this:

var n = cacheEntry.cellNodesByColumnIdx.length;
for (var i = 0; i < n; ++i) {
    columnIdx = cacheEntry.cellNodesByColumnIdx[i] | 0;
    ...
}

great lib, thanks!!!

Owner

mleibman commented Jun 20, 2012

It really annoys me when people mess with the prototypes of built-in objects...

arose commented Jun 20, 2012

I almost completely agree, though would I like to note that it's very convenient to simulate recent additions to the JavaScript standard (e.g. https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some) by extending the prototype and that's probably not uncommon. Also, the order in which array entries are iterated over with foo...in is not guaranteed, see https://developer.mozilla.org/en/JavaScript/Reference/Statements/for...in.

Owner

mleibman commented Jun 20, 2012

Yea, yea... I'm just ranting :)
Though, in this case, I don't really care about the order of iteration at all.

@mleibman mleibman closed this in 5b42d6b Jun 22, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment