From d19c0ac6d32319200f0d94df9b07f63a39aecf70 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Wed, 9 Mar 2011 21:19:19 -0800
Subject: Changed the $browser.xhr parameter post from optional to required
---
CHANGELOG.md | 5 ++++-
src/Browser.js | 6 +-----
test/BrowserSpecs.js | 4 ++--
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 176a0d93..ab711085 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,10 @@
- Fixed cookies which contained unescaped '=' would not show up in cookie service.
- Consider all 2xx responses as OK, not just 200
-
+### Breaking changes
+- Changed the $browser.xhr parameter post from optional to required. Since everyone should be
+ using the $xhr instead of $browser.xhr, this should not break anyone. If you do use $browser.xhr
+ then just add null for the post value argument.
diff --git a/src/Browser.js b/src/Browser.js
index 446944eb..fe6220ed 100644
--- a/src/Browser.js
+++ b/src/Browser.js
@@ -70,17 +70,13 @@ function Browser(window, document, body, XHR, $log) {
*
* @param {string} method Requested method (get|post|put|delete|head|json)
* @param {string} url Requested url
- * @param {string=} post Post data to send
+ * @param {?string} post Post data to send (null if nothing to post)
* @param {function(number, string)} callback Function that will be called on response
*
* @description
* Send ajax request
*/
self.xhr = function(method, url, post, callback) {
- if (isFunction(post)) {
- callback = post;
- post = _null;
- }
outstandingRequestCount ++;
if (lowercase(method) == 'json') {
var callbackId = "angular_" + Math.random() + '_' + (idCounter++);
diff --git a/test/BrowserSpecs.js b/test/BrowserSpecs.js
index c4f49d37..180a7fa8 100644
--- a/test/BrowserSpecs.js
+++ b/test/BrowserSpecs.js
@@ -55,7 +55,7 @@ describe('browser', function(){
it('should queue callbacks with outstanding requests', function(){
var callback = jasmine.createSpy('callback');
- browser.xhr('GET', '/url', noop);
+ browser.xhr('GET', '/url', null, noop);
browser.notifyWhenNoOutstandingRequests(callback);
expect(callback).not.wasCalled();
@@ -70,7 +70,7 @@ describe('browser', function(){
it('should add script tag for request', function() {
var callback = jasmine.createSpy('callback');
var log = "";
- browser.xhr('JSON', 'http://example.org/path?cb=JSON_CALLBACK', function(code, data){
+ browser.xhr('JSON', 'http://example.org/path?cb=JSON_CALLBACK', null, function(code, data){
log += code + ':' + data + ';';
});
browser.notifyWhenNoOutstandingRequests(callback);
--
cgit v1.2.3