From 57d34d5f3ef2bc9ece3316c79e3d29d75b661c76 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski?=
Date: Mon, 5 May 2014 18:10:38 +0200
Subject: [PATCH] Core, Traversing: Add size & andSelf methods
Fixes gh-60
Closes gh-62
---
src/core.js | 6 ++++++
src/traversing.js | 4 ++++
test/core.js | 8 ++++++++
test/index.html | 1 +
test/traversing.js | 10 ++++++++++
5 files changed, 29 insertions(+)
create mode 100644 src/traversing.js
create mode 100644 test/traversing.js
diff --git a/src/core.js b/src/core.js
index 41d9b43a..83406181 100644
--- a/src/core.js
+++ b/src/core.js
@@ -111,3 +111,9 @@ jQuery.sub = function() {
migrateWarn( "jQuery.sub() is deprecated" );
return jQuerySub;
};
+
+// The number of elements contained in the matched element set
+jQuery.fn.size = function() {
+ migrateWarn( "jQuery.fn.size is deprecated; use the length property" );
+ return this.length;
+};
diff --git a/src/traversing.js b/src/traversing.js
new file mode 100644
index 00000000..c0a6d3b1
--- /dev/null
+++ b/src/traversing.js
@@ -0,0 +1,4 @@
+jQuery.fn.andSelf = function() {
+ migrateWarn( "jQuery.fn.andSelf is deprecated; use jQuery.fn.addBack" );
+ return jQuery.fn.addBack.apply( this, arguments );
+};
diff --git a/test/core.js b/test/core.js
index ffa6908b..91a4851c 100644
--- a/test/core.js
+++ b/test/core.js
@@ -253,3 +253,11 @@ test( "jQuery.sub() - .fn Methods", function(){
});
});
});
+
+test( ".size", function(){
+ expect( 1 );
+
+ expectWarning( "size", function() {
+ jQuery( "" ).size();
+ });
+});
diff --git a/test/index.html b/test/index.html
index dc98d50c..74ae4d05 100644
--- a/test/index.html
+++ b/test/index.html
@@ -39,6 +39,7 @@
+
diff --git a/test/traversing.js b/test/traversing.js
new file mode 100644
index 00000000..9dab8b09
--- /dev/null
+++ b/test/traversing.js
@@ -0,0 +1,10 @@
+
+module( "traversing" );
+
+test( ".andSelf", function(){
+ expect( 1 );
+
+ expectWarning( "andSelf", function() {
+ jQuery( "").find( ".inner").andSelf();
+ });
+});