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

fix form.elements -- this is used by NodeBind getAssociatedRadioButtons #462

Merged
merged 1 commit into from
Jun 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"src/wrappers/HTMLElement.js",
"src/wrappers/HTMLCanvasElement.js",
"src/wrappers/HTMLContentElement.js",
"src/wrappers/HTMLFormElement.js",
"src/wrappers/HTMLImageElement.js",
"src/wrappers/HTMLShadowElement.js",
"src/wrappers/HTMLTemplateElement.js",
Expand Down
1 change: 1 addition & 0 deletions shadowdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
'src/wrappers/HTMLElement.js',
'src/wrappers/HTMLCanvasElement.js',
'src/wrappers/HTMLContentElement.js',
'src/wrappers/HTMLFormElement.js',
'src/wrappers/HTMLImageElement.js',
'src/wrappers/HTMLShadowElement.js',
'src/wrappers/HTMLTemplateElement.js',
Expand Down
35 changes: 35 additions & 0 deletions src/wrappers/HTMLFormElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2014 The Polymer Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/

(function(scope) {
'use strict';

var HTMLElement = scope.wrappers.HTMLElement;
var mixin = scope.mixin;
var registerWrapper = scope.registerWrapper;
var wrapHTMLCollection = scope.wrapHTMLCollection;
var unwrap = scope.unwrap;

var OriginalHTMLFormElement = window.HTMLFormElement;

function HTMLFormElement(node) {
HTMLElement.call(this, node);
}
HTMLFormElement.prototype = Object.create(HTMLElement.prototype);
mixin(HTMLFormElement.prototype, {
get elements() {
// Note: technically this should be an HTMLFormControlsCollection, but
// that inherits from HTMLCollection, so should be good enough. Spec:
// http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#htmlformcontrolscollection
return wrapHTMLCollection(unwrap(this).elements);
}
});

registerWrapper(OriginalHTMLFormElement, HTMLFormElement,
document.createElement('form'));

scope.wrappers.HTMLFormElement = HTMLFormElement;
})(window.ShadowDOMPolyfill);
17 changes: 17 additions & 0 deletions test/js/HTMLFormElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2014 The Polymer Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/

suite('HTMLFormElement', function() {

test('elements', function() {
var form = document.createElement('form');
var input = document.createElement('input');
form.appendChild(input);
assert.instanceOf(form.elements, HTMLCollection);
assert.equal(form.elements.length, 1);
});

});
1 change: 1 addition & 0 deletions test/test.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ var modules = [
'HTMLContentElement.js',
'HTMLElement.js',
'HTMLFieldSetElement.js',
'HTMLFormElement.js',
'HTMLHeadElement.js',
'HTMLHtmlElement.js',
'HTMLImageElement.js',
Expand Down