-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Minor code improvements of lib.js #580
Conversation
1. Added cross-browser support for Array.prototype.indexOf function It gives an ability to new browsers perform better on array search operations, and provides a fallback to the browsers which lacks this function support 2. In all places declaration of vars moved to a single declaration blocks which is a good-practice 3. Improved addClass function. Now it will not produce unnecessary spaces 4. Improved removeClass function by using nativer indexOf function for browsers which do support it. Algorithm improved also, it now takes into account that className of an element could have same class name included several times, and as result removes all of them.
@@ -1,15 +1,66 @@ | |||
var hasOwnProp = Object.prototype.hasOwnProperty; | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually tried adding Array indexOf before and it created issues in IE8 (#205). It's also a pretty hefty piece of code, so I don't think we want to add it back in since we've already worked around not having it.
The other changes look good. Could you remove the indexOf updates from the rest? |
The problem is that some of other changes relying on Array.indexOf function :) Let me see what I can do in this case |
Yeah, I think the other changes are still valuable. |
@Mikhus do you think you'll be able to finish this off? |
Sure, I will, in a few coming days
|
Awesome, thanks. On Jul 18, 2013, at 11:43 AM, Mykhailo Stadnyk [email protected] wrote:
|
Got these changes pulled in. Thanks for pointing them out. |
It gives an ability to new browsers perform better on array
search operations, and provides a fallback to the browsers
which lacks this function support
which is a good-practice
browsers which do support it. Algorithm improved also, it now
takes into account that className of an element could have same
class name included several times, and as result removes all of them.