Bug Tracker

Changeset 2784

Show
Ignore:
Timestamp:
08/20/07 02:51:57 (1 year ago)
Author:
jeresig
Message:

Implemented the new .slice() method (bug #1517).

Location:
trunk/jquery/src/jquery
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/jquery/src/jquery/coreTest.js

    r2783 r2784  
    921921    isSet( $("#foo a").contains("log").get(), q("anchor2", "simon"), "contains()" ); 
    922922}); 
     923 
     924test("slice()", function() { 
     925    expect(4); 
     926    isSet( $("#ap a").slice(1,2), q("groups"), "slice(1,2)" ); 
     927    isSet( $("#ap a").slice(1), q("groups", "anchor1", "mark"), "slice(1)" ); 
     928    isSet( $("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" ); 
     929    isSet( $("#ap a").slice(-1), q("mark"), "slice(-1)" ); 
     930}); 
  • trunk/jquery/src/jquery/jquery.js

    r2783 r2784  
    11611161            this.empty().append( val ); 
    11621162    }, 
     1163 
     1164    slice: function() { 
     1165        return this.pushStack( Array.prototype.slice.apply( this, arguments ) ); 
     1166    }, 
    11631167     
    11641168    /**