Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

form element accessed by index #11657

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

form element accessed by index

  • Loading branch information
mrmiywj committed Jun 7, 2016
commit 6759949042eea10e05d941783e7e556227f074ee
@@ -7,6 +7,7 @@ use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use dom::bindings::codegen::Bindings::HTMLButtonElementBinding::HTMLButtonElementMethods;
use dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding::HTMLFormControlsCollectionMethods;
use dom::bindings::codegen::Bindings::HTMLFormElementBinding;
use dom::bindings::codegen::Bindings::HTMLFormElementBinding::HTMLFormElementMethods;
use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
@@ -229,6 +230,12 @@ impl HTMLFormElementMethods for HTMLFormElement {
fn Length(&self) -> u32 {
self.Elements().Length() as u32
}

// https://html.spec.whatwg.org/multipage/#dom-form-item
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Root<Element>> {
let elements = self.Elements();
(*elements).IndexedGetter(index, found)
}
}

#[derive(Copy, Clone, HeapSizeOf, PartialEq)]
@@ -17,7 +17,7 @@ interface HTMLFormElement : HTMLElement {

[SameObject] readonly attribute HTMLFormControlsCollection elements;
readonly attribute unsigned long length;
//getter Element (unsigned long index);
getter Element? (unsigned long index);
//getter (RadioNodeList or Element) (DOMString name);

void submit();
"deleted_reftests": {},
"items": {
"testharness": {
"html/semantics/forms/the-form-element/form-indexed-element.html": [
{
"path": "html/semantics/forms/the-form-element/form-indexed-element.html",
"url": "/html/semantics/forms/the-form-element/form-indexed-element.html"
}
],
"url/url-domainToUnicode.html": [
{
"path": "url/url-domainToUnicode.html",
@@ -0,0 +1,24 @@
<!doctype html>
<meta charset="utf-8">
<title>form.elements: indexed</title>
<link rel="author" title="Ivan.Yang" href="mailto:jsyangwenjie@gmail.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<form id=form>
<table>
<tr>
<td><input type="radio" name="radio1" id="r1" value=1></td>
<td><input type="radio" name="radio2" id="r2" value=2></td>
</tr>
</table>
</form>
</div>
<script>
test(function() {
var form = document.getElementById("form");
assert_equals(form[0], document.getElementById("r1"));
assert_equals(form[1], document.getElementById("r2"));
}, "form.elements should be accessed correctly by index")
</script>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.