Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit db17a73

Browse files
committed
fix($http): replace delete() with del()
In some browsers, like IE8 and android ones, calling delete as a method causes parse error Closes #1265
1 parent cab5e1d commit db17a73

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/ng/http.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,11 @@ function $HttpProvider() {
544544

545545
/**
546546
* @ngdoc method
547-
* @name ng.$http#delete
547+
* @name ng.$http#head
548548
* @methodOf ng.$http
549549
*
550550
* @description
551-
* Shortcut method to perform `DELETE` request
551+
* Shortcut method to perform `HEAD` request
552552
*
553553
* @param {string} url Relative or absolute URL specifying the destination of the request
554554
* @param {Object=} config Optional configuration object
@@ -557,31 +557,39 @@ function $HttpProvider() {
557557

558558
/**
559559
* @ngdoc method
560-
* @name ng.$http#head
560+
* @name ng.$http#jsonp
561561
* @methodOf ng.$http
562562
*
563563
* @description
564-
* Shortcut method to perform `HEAD` request
564+
* Shortcut method to perform `JSONP` request
565565
*
566-
* @param {string} url Relative or absolute URL specifying the destination of the request
566+
* @param {string} url Relative or absolute URL specifying the destination of the request.
567+
* Should contain `JSON_CALLBACK` string.
567568
* @param {Object=} config Optional configuration object
568569
* @returns {HttpPromise} Future object
569570
*/
571+
createShortMethods('get', 'head', 'jsonp');
572+
570573

571574
/**
572575
* @ngdoc method
573-
* @name ng.$http#jsonp
576+
* @name ng.$http#del
574577
* @methodOf ng.$http
575578
*
576579
* @description
577-
* Shortcut method to perform `JSONP` request
580+
* Shortcut method to perform `DELETE` request
578581
*
579-
* @param {string} url Relative or absolute URL specifying the destination of the request.
580-
* Should contain `JSON_CALLBACK` string.
582+
* @param {string} url Relative or absolute URL specifying the destination of the request
581583
* @param {Object=} config Optional configuration object
582584
* @returns {HttpPromise} Future object
583585
*/
584-
createShortMethods('get', 'delete', 'head', 'jsonp');
586+
$http.del = function(url, config) {
587+
return $http(extend(config || {}, {
588+
method: 'DELETE',
589+
url: url
590+
}));
591+
}
592+
585593

586594
/**
587595
* @ngdoc method

test/ng/httpSpec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,15 +483,15 @@ describe('$http', function() {
483483
});
484484

485485

486-
it('should have delete()', function() {
486+
it('should have del()', function() {
487487
$httpBackend.expect('DELETE', '/url').respond('');
488-
$http['delete']('/url');
488+
$http['del']('/url');
489489
});
490490

491491

492-
it('delete() should allow config param', function() {
492+
it('del() should allow config param', function() {
493493
$httpBackend.expect('DELETE', '/url', undefined, checkHeader('Custom', 'Header')).respond('');
494-
$http['delete']('/url', {headers: {'Custom': 'Header'}});
494+
$http['del']('/url', {headers: {'Custom': 'Header'}});
495495
});
496496

497497

0 commit comments

Comments
 (0)