Skip to content

Docs: Add descriptions for .andSelf() and .size() deprecations #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ jQuery.sub = function() {

// The number of elements contained in the matched element set
jQuery.fn.size = function() {
migrateWarn( "jQuery.fn.size is deprecated; use the length property" );
migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );
return this.length;
};
12 changes: 12 additions & 0 deletions warnings.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,15 @@ $(document).ajaxStart(function(){ $("#status").text("Ajax started"); });

**Solution**: If you are creating HTML that absolutely requires leading text, use `$.parseHTML` and pass the results to `$()`.

### JQMIGRATE: jQuery.fn.andSelf() replaced by jQuery.fn.addBack()

**Cause**: The `.andSelf()` method has been renamed to `.addBack()` as of jQuery 1.9 to better reflect its purpose of adding back the previous set of results.

**Solution**: Replace any use of `.andSelf()` with `.addBack()`.

### JQMIGRATE: jQuery.fn.size() is deprecated; use the .length property

**Cause**: The `.size()` method returns the number of elements in the current jQuery object, but duplicates the more-efficient `.length` property which provides the same functionality. As of jQuery 1.9 the `.length` property is the preferred way to retrieve this value.

**Solution**: Replace any use of `.size()` with `.length`.