Fixed those two bugs
Fixed Looping over String Issue in CSS Method. And fixed Android Type…
…Error - can't convert object to primitive
Fixed Buuuug - numbers could not be assigned to CSS-rules
Thanks for the pull request. This needs tests.
More specifically, the commit that claims to have fixed a bug needs tests. The first commit is an optimization and therefore doesn't need tests (but I'll cover the functionality in my speed tests)
(It would be better to have this in separate pull requests!)
Because both changes are to the same method, I don't mind that this is in a single PR. But, I need evidence that a bug exists—evidence in form of failing test.
I just created a simple test case @ jsperf:
The first thing can be tested very easily:
just ably $('#foo').css('display', 'block'), open your JS debugger and set a breakpoint to the css-Method.
you will observe, that the method firstly iterates over each chareckter of "display" and then will do the correct job.
For the second one you will need a Samsung Galaxy or any other Android driven device.
Then it happen that you get a Type-Error "Cannot Convert Object to Primitive Value" if you pass an object literall.
The css method has changed quite a bit since this PR. If it's still a problem, please add tests and a proposed solution in a new pull request.