Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Merge pull request #463 from arv/form-data
Browse files Browse the repository at this point in the history
Add FormData wrapper
  • Loading branch information
dfreedm committed Jul 7, 2014
2 parents b2c730a + 50449e5 commit 8972d7c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@
"src/wrappers/Document.js",
"src/wrappers/Window.js",
"src/wrappers/DataTransfer.js",
"src/wrappers/FormData.js",
"src/wrappers/override-constructors.js"
]
1 change: 1 addition & 0 deletions shadowdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
'src/wrappers/Document.js',
'src/wrappers/Window.js',
'src/wrappers/DataTransfer.js',
'src/wrappers/FormData.js',
'src/wrappers/override-constructors.js'
].forEach(function(src) {
document.write('<script src="' + base + src + '"></script>');
Expand Down
23 changes: 23 additions & 0 deletions src/wrappers/FormData.js
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 registerWrapper = scope.registerWrapper;
var unwrap = scope.unwrap;

var OriginalFormData = window.FormData;

function FormData(formElement) {
this.impl = new OriginalFormData(formElement && unwrap(formElement));
}

registerWrapper(OriginalFormData, FormData, new OriginalFormData());

scope.wrappers.FormData = FormData;

})(window.ShadowDOMPolyfill);
20 changes: 20 additions & 0 deletions test/js/FormData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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('FormData', function() {

test('instanceof', function() {
var fd = new FormData();
assert.instanceOf(fd, FormData);
});

test('form element', function() {
var formElement = document.createElement('form');
var fd = new FormData(formElement)
assert.instanceOf(fd, FormData);
});

});
1 change: 1 addition & 0 deletions test/test.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ var modules = [
'DOMTokenList.js',
'Document.js',
'Element.js',
'FormData.js',
'HTMLAudioElement.js',
'HTMLBodyElement.js',
'HTMLButtonElement.js',
Expand Down

0 comments on commit 8972d7c

Please sign in to comment.