.load() overloaded with completely different behavior depending on the arguments passed
.toggle() overloaded with completely different behavior depending on the arguments passed
jQuery() function overload is probably too big.
the .attr() you mentioned. The difference from the properties was to be an immediate IMO.
.map( key,val ) , but $.map( val,key ) , and this values ​​are different.
non-standard selectors should be excluded from Sizzle IMO. Javascript-based selector mechanisms should be obsolete for several years, and people connected to proprietary selectors will have a more complex transition
bad name method of methods like .closest() or .live() . What exactly are they doing?
I recently discovered that you cannot set the standard width and height attributes through the props argument when creating a new element. Instead, jQuery runs its own width and height methods. IMO, spec attributes should be given priority value, especially since width and height can be set via css .
$('<img/>', { css:{width:100, height:100}, width:100, // <-- calls method, why? height:100, // <-- calls method, why? });
$.get() and .get() completely different.
.get() and .toArray() identical when passing arguments
toArray() and $.makeArray() do the same. Why didn't they give them the same name as .each() and $.each() ?
two different methods of delegating events. .delegate() reasonable, and .live() magic "wow, it just works!" one.
.index() overloaded with three behaviors, but their differences can be confusing
// v---get index v---from collection (siblings is implied) $('selector').index(); // v---from collection v---get index $('selector').index(element); // v---get index v---from collection $('selector').index('selector');
The first is understandable if you remember that it only works with the first element
The second method makes the most sense, since jQuery methods usually work with the entire collection.
The third is completely confused. This method does not indicate which selector is the collection and which selector represents the element whose index you want to get from the collection.
Why not just eliminate the third one and ask people to use the second one like this:
// v---from collection v---get index $('selector').index( $('selector') );
Thus, it is more closely related to the rest of jQuery, where .index() works with the entire collection.
Or at least change the meaning of the selectors so that they fit better:
// v---from collection v---get index $('selector').index('selector');
There is still something to think about.
I have some problems with jQuery event handling / storage. It is praised because it does not add functions to the on[event] properties, which can close around other elements, creating memory leaks in IE. Instead, it places the easy expando property, which maps to a jQuery.cache that contains handlers and other data.
I believe that it then attaches the handler, which in turn calls the handler that you assigned. Or something like that.
No matter which system does not matter. The thing is, the connection between the element (s) and jQuery.cache is that expando.
Why is this so important? Well philosophically jQuery is not the foundation; this is a library. It looks like you can use or not use jQuery functions as a library without worrying about negative effects. However, if you go beyond jQuery when deleting elements from the DOM, you dispute any handlers and other data associated with these elements through the extension, creating a pleasant and completely cross-browser memory leak.
So, for example, something as simple as el.innerHTML = '' can be very dangerous.
Mix this with the jQuery.noConflict() function. This allows developers to use jQuery with other libraries using the global $ namespace. Well, if one of these libraries removes some items? Same problem. I get the feeling that a developer who needs to use a library like Prototypejs along side jQuery probably doesn’t know enough JavaScript to make the right design decisions and will be prone to such a problem as I described.
As for the improvements in the framework of the supposed library philosophy, as far as I know, their philosophy is “Do more, write less” or something like that. I think they do it very well. You can write very concise but expressive code that will do a great job.
While this is very good, I think of it as something negative. You can do so much, so easily, it’s very easy for beginners to write very bad code. It would be nice if there was a “developer build” that logged warnings about misuse of the library.
A common example is running a selector in a loop. Choosing a DOM is very easy to use, it seems that you can just run the selector every time you need an element, even if you just ran this selector. An improvement, I think, would be for the jQuery() function to register reuse of the selector and give a console note that the selector can be cached.
Since jQuery is so dominant, I think it would be nice if they not only simplified the work with JavaScript / DOM, but also helped you become the best.