3232 * - [after()](http://api.jquery.com/after/)
3333 * - [append()](http://api.jquery.com/append/)
3434 * - [attr()](http://api.jquery.com/attr/)
35- * - [bind()](http://api.jquery.com/bind /) - Does not support namespaces
35+ * - [bind()](http://api.jquery.com/on /) - Does not support namespaces, selectors or eventData
3636 * - [children()](http://api.jquery.com/children/) - Does not support selectors
3737 * - [clone()](http://api.jquery.com/clone/)
3838 * - [contents()](http://api.jquery.com/contents/)
4343 * - [hasClass()](http://api.jquery.com/hasClass/)
4444 * - [html()](http://api.jquery.com/html/)
4545 * - [next()](http://api.jquery.com/next/) - Does not support selectors
46+ * - [on()](http://api.jquery.com/on/) - Does not support namespaces, selectors or eventData
47+ * - [off()](http://api.jquery.com/off/) - Does not support namespaces or selectors
4648 * - [parent()](http://api.jquery.com/parent/) - Does not support selectors
4749 * - [prepend()](http://api.jquery.com/prepend/)
4850 * - [prop()](http://api.jquery.com/prop/)
5557 * - [text()](http://api.jquery.com/text/)
5658 * - [toggleClass()](http://api.jquery.com/toggleClass/)
5759 * - [triggerHandler()](http://api.jquery.com/triggerHandler/) - Passes a dummy event object to handlers.
58- * - [unbind()](http://api.jquery.com/unbind /) - Does not support namespaces
60+ * - [unbind()](http://api.jquery.com/off /) - Does not support namespaces
5961 * - [val()](http://api.jquery.com/val/)
6062 * - [wrap()](http://api.jquery.com/wrap/)
6163 *
@@ -90,6 +92,7 @@ function jqNextId() { return ++jqId; }
9092
9193var SPECIAL_CHARS_REGEXP = / ( [ \: \- \_ ] + ( .) ) / g;
9294var MOZ_HACK_REGEXP = / ^ m o z ( [ A - Z ] ) / ;
95+ var jqLiteError = minErr ( 'jqLite' ) ;
9396
9497/**
9598 * Converts snake_case to camelCase.
@@ -153,7 +156,7 @@ function JQLite(element) {
153156 }
154157 if ( ! ( this instanceof JQLite ) ) {
155158 if ( isString ( element ) && element . charAt ( 0 ) != '<' ) {
156- throw minErr ( 'jqLite' ) ( 'nosel' , 'Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element' ) ;
159+ throw jqLiteError ( 'nosel' , 'Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element' ) ;
157160 }
158161 return new JQLite ( element ) ;
159162 }
@@ -183,7 +186,9 @@ function JQLiteDealoc(element){
183186 }
184187}
185188
186- function JQLiteUnbind ( element , type , fn ) {
189+ function JQLiteOff ( element , type , fn ) {
190+ if ( arguments . length > 4 ) throw jqLiteError ( 'off_args' , 'jqLite#off() does not support the `selector` parameter' ) ;
191+
187192 var events = JQLiteExpandoStore ( element , 'events' ) ,
188193 handle = JQLiteExpandoStore ( element , 'handle' ) ;
189194
@@ -216,7 +221,7 @@ function JQLiteRemoveData(element, name) {
216221
217222 if ( expandoStore . handle ) {
218223 expandoStore . events . $destroy && expandoStore . handle ( { } , '$destroy' ) ;
219- JQLiteUnbind ( element ) ;
224+ JQLiteOff ( element ) ;
220225 }
221226 delete jqCache [ expandoId ] ;
222227 element [ jqName ] = undefined ; // ie does not allow deletion of attributes on elements.
@@ -338,9 +343,9 @@ var JQLitePrototype = JQLite.prototype = {
338343 if ( document . readyState === 'complete' ) {
339344 setTimeout ( trigger ) ;
340345 } else {
341- this . bind ( 'DOMContentLoaded' , trigger ) ; // works for modern browsers and IE9
346+ this . on ( 'DOMContentLoaded' , trigger ) ; // works for modern browsers and IE9
342347 // we can not use jqLite since we are not done loading and jQuery could be loaded later.
343- JQLite ( window ) . bind ( 'load' , trigger ) ; // fallback to window.onload for others
348+ JQLite ( window ) . on ( 'load' , trigger ) ; // fallback to window.onload for others
344349 }
345350 } ,
346351 toString : function ( ) {
@@ -609,7 +614,9 @@ forEach({
609614
610615 dealoc : JQLiteDealoc ,
611616
612- bind : function bindFn ( element , type , fn ) {
617+ on : function onFn ( element , type , fn , other1 ) {
618+ if ( isDefined ( other1 ) ) throw jqLiteError ( 'on_args' , 'jqLite#on() does not support the `selector` or `eventData` parameters' ) ;
619+
613620 var events = JQLiteExpandoStore ( element , 'events' ) ,
614621 handle = JQLiteExpandoStore ( element , 'handle' ) ;
615622
@@ -649,8 +656,8 @@ forEach({
649656 // http://www.quirksmode.org/js/events_mouse.html#link8
650657 var eventmap = { mouseleave : "mouseout" , mouseenter : "mouseover" } ;
651658
652- bindFn ( element , eventmap [ type ] , function ( event ) {
653- var ret , target = this , related = event . relatedTarget ;
659+ onFn ( element , eventmap [ type ] , function ( event ) {
660+ var target = this , related = event . relatedTarget ;
654661 // For mousenter/leave call the handler if related is outside the target.
655662 // NB: No relatedTarget if the mouse left/entered the browser window
656663 if ( ! related || ( related !== target && ! contains ( target , related ) ) ) {
@@ -668,7 +675,7 @@ forEach({
668675 } ) ;
669676 } ,
670677
671- unbind : JQLiteUnbind ,
678+ off : JQLiteOff ,
672679
673680 replaceWith : function ( element , replaceNode ) {
674681 var index , parent = element . parentNode ;
@@ -790,19 +797,23 @@ forEach({
790797 /**
791798 * chaining functions
792799 */
793- JQLite . prototype [ name ] = function ( arg1 , arg2 ) {
800+ JQLite . prototype [ name ] = function ( arg1 , arg2 , arg3 ) {
794801 var value ;
795802 for ( var i = 0 ; i < this . length ; i ++ ) {
796803 if ( value == undefined ) {
797- value = fn ( this [ i ] , arg1 , arg2 ) ;
804+ value = fn ( this [ i ] , arg1 , arg2 , arg3 ) ;
798805 if ( value !== undefined ) {
799806 // any function which returns a value needs to be wrapped
800807 value = jqLite ( value ) ;
801808 }
802809 } else {
803- JQLiteAddNodes ( value , fn ( this [ i ] , arg1 , arg2 ) ) ;
810+ JQLiteAddNodes ( value , fn ( this [ i ] , arg1 , arg2 , arg3 ) ) ;
804811 }
805812 }
806813 return value == undefined ? this : value ;
807814 } ;
815+
816+ // bind legacy bind/unbind to on/off
817+ JQLite . prototype . bind = JQLite . prototype . on ;
818+ JQLite . prototype . unbind = JQLite . prototype . off ;
808819} ) ;
0 commit comments