-
-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for .data() method to read scientific notation as string as is. #399
Conversation
|
Hi Fabio, JSON.parse will convert the '1e99' into a number. What we want for .data() is to return '1e99' as '1e99' and not as 1000000000. So before we pass the string to JSON.parse, we need to check if it has a scientific notation format. This is consistent with jQuery, Zepto, and native Element.dataset.get() routine. I will revert the dist and other edits from this pull request. Thanks! |
Thank you but our Moreover if there's a |
I respect your decision on this. Regarding jQuery and Element.dataset, they probably based it on HTML Spec from WHATWG, where values of dataset properties are returned as DOMString. https://html.spec.whatwg.org/multipage/dom.html#domstringmap Still, cash-dom's .data() method might be a more practical implementation in real world case than it is to follow the specs strictly. Thank you for your review and have a nice day! |
You might consider using the Sorry for the inconvenience. |
Problem
<div class="data-scientific" data-unsigned="1234e5" data-epositive="1234e+5" data-enegative="1234e-5"></div>
Solution