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.
fixes Polymer/polymer#725, unwrap FormData in XHR.send if needed
- Loading branch information
John Messerly
committed
Sep 9, 2014
1 parent
740d3d3
commit 467a422
Showing
5 changed files
with
49 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,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. | ||
*/ | ||
|
||
(function(scope) { | ||
'use strict'; | ||
|
||
var unwrapIfNeeded = scope.unwrapIfNeeded; | ||
var XMLHttpRequest = window.XMLHttpRequest; | ||
|
||
var originalSend = XMLHttpRequest && XMLHttpRequest.prototype.send; | ||
if (!originalSend) return; | ||
|
||
// Note: since we only need to adjust XHR.send, we just patch it instead of | ||
// wrapping the entire object. | ||
XMLHttpRequest.prototype.send = function(obj) { | ||
// Unwrap FormData if needed | ||
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