This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #507 from Polymer/xhr_formdata
unwrap FormData in XMLHttpRequest.send if needed
- Loading branch information
Showing
5 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright 2014 The Polymer Authors. All rights reserved. | ||
* Use of this source code is goverened by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
|
||
(function(scope) { | ||
'use strict'; | ||
|
||
var unwrapIfNeeded = scope.unwrapIfNeeded; | ||
var originalSend = XMLHttpRequest.prototype.send; | ||
|
||
// Since we only need to adjust XHR.send, we just patch it instead of wrapping | ||
// the entire object. This happens when FormData is passed. | ||
XMLHttpRequest.prototype.send = function(obj) { | ||
return originalSend.call(this, unwrapIfNeeded(obj)); | ||
}; | ||
|
||
})(window.ShadowDOMPolyfill); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2014 The Polymer Authors. All rights reserved. | ||
* Use of this source code is goverened by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
|
||
suite('XMLHttpRequest', function() { | ||
|
||
var wrap = ShadowDOMPolyfill.wrap; | ||
var unwrap = ShadowDOMPolyfill.unwrap; | ||
|
||
test('instanceof', function() { | ||
var xhr = new XMLHttpRequest(); | ||
assert.instanceOf(xhr, XMLHttpRequest); | ||
}); | ||
|
||
test('send', function() { | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open('POST', location.href); | ||
xhr.send(new FormData()); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters