3 ms·
His example is unclear, but he's complaining about the behavior of conditionally casting the initial data values based on pattern matching. <div id="test" d
by underwater 15y ago
His example is unclear, but he's complaining about the behavior of conditionally casting the initial data values based on pattern matching.
<div id="test" data-foo="1.1">
$('#test').data('bar', '1.1');
typeof $('#test').data('foo'); // number
typeof $('#test').data('bar'); // string
If the data-foo value is user input, then converting it to a number might not be expected. E.g.
<div data-emoticon="0.0" />