jQuery under a different API

jQuery under a different API


Has there been any thought, discussion, or interest in providing
jQuery as a backend, or being able to provide another library as
another API to jQuery.
jQuery is quite mature (even though a bug I couldn't track down forced
us to discard use of it at work), but one of the things that has irked
me repeatedly is small commonly used parts of the API. Namely show/
hide, toggle, end, and sometimes I've thought the bind/live...
separation could be done better.
Of course even if the API could be done a little different in a way
that made sense a little more that's not a good reason to actually
change the jQuery API. One of the nice things of jQuery is that for
the most part the API has changed very little. The massive differences
of 3 versions of MooTools at work in the system built before I came in
were very annoying.
Beyond rolling a library as a modified API using jQuery as a backend
does have potential use elsewhere. One of the special things about the
system I have at work is that the JavaScript framework being used
(since it's part of the system) can do nice things like taking a
Widget object as input, and knowing how to handle the actual nodes
it's associated with.
If you were wondering what irked me a bit, it was primarily show/hide.
$('#foo').hide(); does have the connotation of hiding something.
However it always annoyed me how 'hide' was actually a very specific
"scale diagonally to the upper left, and disappear". Rather than a
simple 'hide me' like it implies.
And for just sliding something closed, $('#foo').slideUp(); is used,
even though 'slideUp' is basically a type of 'hide' with a different
animation. While over on the other hand to actually 'hide' something
without animation (I have had to do this many a time) I have to
verbosely type in $('#foo').css('display', 'none');
It honestly makes much more sense to me if:
$('#foo').hide(); just set display: none;
animating something to slide shut was $('#foo').hide
({animate:'slideup'});
and if you actually wanted .hide() to animate you would tell it to
have a default:
$.defaults.hide.animate = 'slideup';
Basically the thought I've had is. "Keeping code short and sweet is
nice, but only if you do it without losing information. Sometimes you
go to far in shortening the size of code, and end up losing
information that makes it readable."
Along with that 'toggle' irks me as well. For the very well integrated
jQuery user, "Huh, 'toggle', that just flips my visibility.", but for
anyone that is just looking at the code "Toggle? What does it
toggle?". Toggle could flip a checkbox, it could show or hide
something, if it shows or hides something then how does it do it? does
it slide, does it fade, or does it just disappear?
Honestly toggleVisibility working like the .hide I mentioned above
makes more sense to me.
The last one, not really an irk, but just something I've thought could
be cleaner. Rather than .bind, .live, and whatever for binding
different types of events. To me this makes more sense:
$('#foo').event('mouseover', function(e) {...}); // A mouseover event
bound to #foo
$('#foo').event({
mouseover: function(e) {...},
mouseout: function(e) {...}
}); // a mouseover and mouse out bound to '#foo'
$('#foo').event('a', 'click', function(e, elm) {...}); // A click
event bound to '#foo' that event delegates to anchors.
Ideally in an event delegation case 'this' would be a jQuery object
with the delegated target.
Thus: $('#foo').event('a', 'click', function(e, elm) {this.hide
({animate:'fade'});});