diff --git a/build.json b/build.json index 639f1b8..d12915c 100644 --- a/build.json +++ b/build.json @@ -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" ] diff --git a/shadowdom.js b/shadowdom.js index 432fd45..069b5d7 100644 --- a/shadowdom.js +++ b/shadowdom.js @@ -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(''); diff --git a/src/wrappers/FormData.js b/src/wrappers/FormData.js new file mode 100644 index 0000000..4848648 --- /dev/null +++ b/src/wrappers/FormData.js @@ -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); diff --git a/test/js/FormData.js b/test/js/FormData.js new file mode 100644 index 0000000..e909bcb --- /dev/null +++ b/test/js/FormData.js @@ -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); + }); + +}); diff --git a/test/test.main.js b/test/test.main.js index cbc62f0..ae70fdc 100644 --- a/test/test.main.js +++ b/test/test.main.js @@ -78,6 +78,7 @@ var modules = [ 'DOMTokenList.js', 'Document.js', 'Element.js', + 'FormData.js', 'HTMLAudioElement.js', 'HTMLBodyElement.js', 'HTMLButtonElement.js',