handsontable/jquery-handsontable — pull request #1888 by NickStefan (2014-11-10 03:43:53+00:00)
Title: fix instance.dataType checker inside loadData()

Inside loadData, the "instanceof" checker was being used to set the instance.dataType property to either 'obj' or 'array'. Unfortunately, this breaks when a pseudoclassical constructor builds an instantiation settings object with a data property that is an array. Instanceof will instead register the data property as an object, breaking the table in some instances.

Array.isArray is instead better able to accurately note the type of the data property. I've used the provided polyfill/shim helper Handsontable.helper.isArray already found in the code base.

The bug that I'm referring to can be reproduced in a jsfiddle. alert(constructed.data instanceof array) incorrectly alerts false, even though it is definitely an array. The exact point of break I was finding in my own project was in src/core 1742, which did not like that my data array was being noted as instance.dataType === 'obj'. The jsfiddle table doesnt break, but this is definitely the bug breaking it in my project. The instanceof being a poor type checker is still shown in practice here: http://jsfiddle.net/17Lgkoap/

src/core 1025 now:
if (Handsontable.helper.isArray(priv.settings.dataSchema) || Handsontable.helper.isArray(data[0])) {

src/core 1025 formerly:
if (priv.settings.dataSchema instanceof Array || data[0] instanceof Array) {