Skip to content

Commit 7691f7f

Browse files
committed
Deferred: Deprecate deferred.pipe() method
Ref #89
1 parent 683b9b3 commit 7691f7f

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

Gruntfile.js

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module.exports = function(grunt) {
2727
"src/manipulation.js",
2828
"src/event.js",
2929
"src/traversing.js",
30+
"src/deferred.js",
3031
"src/outro.js"
3132
],
3233
tests: {

src/deferred.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
var oldDeferred = jQuery.Deferred;
3+
4+
jQuery.Deferred = function() {
5+
var deferred = oldDeferred.apply( this, arguments );
6+
7+
deferred.pipe = function() {
8+
migrateWarn( "deferred.pipe() is deprecated" );
9+
return deferred.then.apply( this, arguments );
10+
};
11+
12+
return deferred;
13+
};

test/deferred.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
module("deferred");
3+
4+
test( ".pipe()", function() {
5+
expect( 4 );
6+
7+
var d = jQuery.Deferred().resolve( 1 );
8+
9+
expectNoWarning( "then", function() {
10+
d.then(function( v ) {
11+
equal( v, 1, "got correct value" );
12+
}); });
13+
14+
expectWarning( "pipe", function() {
15+
d.pipe(function( v ) {
16+
equal( v, 1, "got correct value" );
17+
});
18+
});
19+
20+
});
21+

test/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<script src="ajax.js"></script>
4141
<script src="event.js"></script>
4242
<script src="traversing.js"></script>
43+
<script src="deferred.js"></script>
4344
</head>
4445
<body>
4546
<div id="qunit"></div>

warnings.md

+6
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ $(document).ajaxStart(function(){ $("#status").text("Ajax started"); });
148148

149149
**Solution**: Boolean properties should generally not be passed to `$().attr` at all; replace with `$().prop` unless you truly intend to update the underlying HTML *attribute*.
150150

151+
### JQMIGRATE: deferred.pipe() is deprecated
152+
153+
**Cause**: The `.pipe()` method on a `jQuery.Deferred` object was deprecated as of jQuery 1.8, when the `.then()` method was changed to perform the same function.
154+
155+
**Solution**: Change all occurrences of `.pipe()` to `.then()`.
156+
151157
### JQMIGRATE: jQuery.clean() is deprecated
152158

153159
**Cause**: `jQuery.buildFragment()` and `jQuery.clean()` are undocumented internal methods. The signature of `jQuery.buildFragment()` was changed in jQuery 1.8 and 1.9, and `jQuery.clean()` was removed in 1.9. However, we are aware of some plugins or other code that may be using them.

0 commit comments

Comments
 (0)