ded / bonzo

library agnostic, extensible DOM utility
Other
1.32k stars 137 forks source link

`data('key')` where no data element for 'key' leave NaN #48

Closed rvagg closed 12 years ago

rvagg commented 12 years ago
  function dataValue(d) {
    try {
      return d === 'true' ? true : d === 'false' ? false : d === 'null' ? null : !isNaN(d) ? parseFloat(d) : d;
    } catch(e) {}
    return undefined
  }

is returning NaN for a bunch of d values where it should probably return something else, undefined or null probably. Most importantly these values give NaN: '', null (probably the culprit).

needs test cases.

yes, blame me.

rvagg commented 12 years ago

(updated description)

ded commented 12 years ago

indeed. test cases :)

rvagg commented 12 years ago

BTW this is my issue, I just need to find some time to write the tests & fix. Perhaps on the weekend.