Skip to content

Commit 57d34d5

Browse files
committed
Core, Traversing: Add size & andSelf methods
Fixes jquerygh-60 Closes jquerygh-62
1 parent 46741ca commit 57d34d5

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

src/core.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,9 @@ jQuery.sub = function() {
111111
migrateWarn( "jQuery.sub() is deprecated" );
112112
return jQuerySub;
113113
};
114+
115+
// The number of elements contained in the matched element set
116+
jQuery.fn.size = function() {
117+
migrateWarn( "jQuery.fn.size is deprecated; use the length property" );
118+
return this.length;
119+
};

src/traversing.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
jQuery.fn.andSelf = function() {
2+
migrateWarn( "jQuery.fn.andSelf is deprecated; use jQuery.fn.addBack" );
3+
return jQuery.fn.addBack.apply( this, arguments );
4+
};

test/core.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,11 @@ test( "jQuery.sub() - .fn Methods", function(){
253253
});
254254
});
255255
});
256+
257+
test( ".size", function(){
258+
expect( 1 );
259+
260+
expectWarning( "size", function() {
261+
jQuery( "<div />" ).size();
262+
});
263+
});

test/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<script src="manipulation.js"></script>
4040
<script src="ajax.js"></script>
4141
<script src="event.js"></script>
42+
<script src="traversing.js"></script>
4243
</head>
4344
<body>
4445
<div id="qunit"></div>

test/traversing.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
module( "traversing" );
3+
4+
test( ".andSelf", function(){
5+
expect( 1 );
6+
7+
expectWarning( "andSelf", function() {
8+
jQuery( "<div id='outer'><div id='inner'></div></div>").find( ".inner").andSelf();
9+
});
10+
});

0 commit comments

Comments
 (0)