Fixed minor bug in jQuery.parse[1] expression.
[jquery.git] / src / jquery / jquery.js
index 3d2bf48..4e9f4ac 100644 (file)
@@ -1473,20 +1473,24 @@ jQuery.extend({
                        "^=": "z && !z.indexOf(m[4])",
                        "$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]",
                        "*=": "z && z.indexOf(m[4])>=0",
-                       "": "z"
+                       "": "z",
+                       _resort: function(m){
+                               return ["", m[1], m[3], m[2], m[5]];
+                       },
+                       _prefix: "z=jQuery.attr(a,m[3]);"
                },
                "[": "jQuery.find(m[2],a).length"
        },
 
-  /**
+       /**
         * All elements on a specified axis.
         *
         * @private
         * @name $.sibling
         * @type Array
         * @param Element elem The element to find all the siblings of (including itself).
-   * @cat DOM/Traversing
-   */
+        * @cat DOM/Traversing
+        */
        sibling: function( n, elem ) {
                var r = [];
 
@@ -1780,7 +1784,7 @@ jQuery.extend({
                "\\[ *(@)S *([!*$^=]*) *('?\"?)(.*?)\\4 *\\]",
 
                // Match: [div], [div p]
-               "(\\[)\s*(.*?)\s*\\]",
+               "(\\[)\\s*(.*?)\\s*\\]",
 
                // Match: :contains('foo')
                "(:)S\\(\"?'?([^\\)]*?)\"?'?\\)",
@@ -1806,8 +1810,8 @@ jQuery.extend({
 
                                if ( m ) {
                                        // Re-organize the first match
-                                       if ( !i )
-                                               m = ["",m[1], m[3], m[2], m[5]];
+                                       if ( jQuery.expr[ m[1] ]._resort )
+                                               m = jQuery.expr[ m[1] ]._resort( m );
 
                                        // Remove what we just matched
                                        t = t.replace( re, "" );
@@ -1838,7 +1842,7 @@ jQuery.extend({
 
                                // Build a custom macro to enclose it
                                eval("f = function(a,i){" +
-                                       ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) +
+                                       ( jQuery.expr[ m[1] ]._prefix || "" ) +
                                        "return " + f + "}");
 
                                // Execute it against the current filter
@@ -2086,7 +2090,9 @@ jQuery.extend({
                // Detach an event or set of events from an element
                remove: function(element, type, handler) {
                        if (element.events)
-                               if (type && element.events[type])
+                               if ( type && type.type )
+                                       delete element.events[ type.type ][ type.handler.guid ];
+                               else if (type && element.events[type])
                                        if ( handler )
                                                delete element.events[type][handler.guid];
                                        else
@@ -2131,6 +2137,10 @@ jQuery.extend({
                        args.unshift( event );
 
                        for ( var j in c ) {
+                               // Pass in a reference to the handler function itself
+                               // So that we can later remove it
+                               args[0].handler = c[j];
+
                                if ( c[j].apply( this, args ) === false ) {
                                        event.preventDefault();
                                        event.stopPropagation();
@@ -2839,35 +2849,7 @@ jQuery.macros = {
                 * Get a set of elements containing the unique ancestors of the matched
                 * set of elements (except for the root element).
                 *
-                * @example $("span").ancestors()
-                * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
-                * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
-                *
-                * @name ancestors
-                * @type jQuery
-                * @cat DOM/Traversing
-                */
-
-               /**
-                * Get a set of elements containing the unique ancestors of the matched
-                * set of elements, and filtered by an expression.
-                *
-                * @example $("span").ancestors("p")
-                * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
-                * @result [ <p><span>Hello</span></p> ]
-                *
-                * @name ancestors
-                * @type jQuery
-                * @param String expr An expression to filter the ancestors with
-                * @cat DOM/Traversing
-                */
-               ancestors: jQuery.parents,
-
-               /**
-                * Get a set of elements containing the unique ancestors of the matched
-                * set of elements (except for the root element).
-                *
-                * @example $("span").ancestors()
+                * @example $("span").parents()
                 * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
                 * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
                 *
@@ -2880,7 +2862,7 @@ jQuery.macros = {
                 * Get a set of elements containing the unique ancestors of the matched
                 * set of elements, and filtered by an expression.
                 *
-                * @example $("span").ancestors("p")
+                * @example $("span").parents("p")
                 * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
                 * @result [ <p><span>Hello</span></p> ]
                 *