Reviewed by Maciej.
authorrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2006 23:40:05 +0000 (23:40 +0000)
committerrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2006 23:40:05 +0000 (23:40 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=10188
        Form elements added via appendChild() are not accessible via form.element

        Make sure looking up form elements works when the form is not appended
        to the document.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@18090 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/forms/form-collection-lookup-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/form-collection-lookup.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLFormElement.cpp

index e0abf3d05c966fdbbcdd2c06026b5108796e2c8c..3f8f2d748ce3cab572a482eed369da641314b73c 100644 (file)
@@ -1,3 +1,25 @@
+2006-12-08  Rob Buis  <buis@kde.org>
+
+        Reviewed by Maciej.
+
+        Testcase for:
+        http://bugs.webkit.org/show_bug.cgi?id=10188
+        Form elements added via appendChild() are not accessible via form.element
+
+        * fast/forms/form-collection-lookup-expected.txt: Added.
+        * fast/forms/form-collection-lookup.html: Added.
+
+2006-12-08  Rob Buis  <buis@kde.org>
+
+        Reviewed by Maciej.
+
+        Testcase for:
+        http://bugs.webkit.org/show_bug.cgi?id=10188
+        Form elements added via appendChild() are not accessible via form.element
+
+        * fast/forms/form-collection-lookup-expected.txt: Added.
+        * fast/forms/form-collection-lookup.html: Added.
+
 2006-12-08  Rob Buis  <buis@kde.org>
 
         Reviewed by Adele.
diff --git a/LayoutTests/fast/forms/form-collection-lookup-expected.txt b/LayoutTests/fast/forms/form-collection-lookup-expected.txt
new file mode 100644 (file)
index 0000000..f03c566
--- /dev/null
@@ -0,0 +1,3 @@
+This tests looking up form elements from a form that is not yet appended to a document. See bug 10188.
+
+Passed
diff --git a/LayoutTests/fast/forms/form-collection-lookup.html b/LayoutTests/fast/forms/form-collection-lookup.html
new file mode 100644 (file)
index 0000000..7b4a24a
--- /dev/null
@@ -0,0 +1,25 @@
+<body onload="runTest()">
+<script>
+function runTest() {
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+}
+var form = document.createElement('form');
+var input = document.createElement('input');
+input.setAttribute("name", "test_field");
+form.appendChild(input);
+
+var message = "Failed";
+try{
+   if (form.test_field)
+       message = "Passed";
+}catch(e){
+}
+var console = document.getElementById("console");
+var text = document.createTextNode(message);
+console.appendChild(text);
+}
+</script>
+<p>This tests looking up form elements from a form that is not yet appended to a document. See bug 10188.</p>
+<div id="console"/>
+</body>
index 41b68fc900addacad1a4e5c9419a67057675f485..ae0d81e538522b06b1158e422dc650402d75b5c5 100644 (file)
@@ -1,3 +1,16 @@
+2006-12-08  Rob Buis  <buis@kde.org>
+
+        Reviewed by Maciej.
+
+        http://bugs.webkit.org/show_bug.cgi?id=10188
+        Form elements added via appendChild() are not accessible via form.element
+
+        Make sure looking up form elements works when the form is not appended
+        to the document.
+
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::registerFormElement):
+
 2006-12-08  Rob Buis  <buis@kde.org>
 
         Reviewed by Adele.
index 0fdea6bd1d8a8681abed1c4e06774f12b8536dbc..3a541e26d450efbb9ed4e4dd3db62cf4c70f4b16 100644 (file)
@@ -495,6 +495,7 @@ void HTMLFormElement::registerFormElement(HTMLGenericFormElement* e)
             doc->radioButtonChecked(static_cast<HTMLInputElement*>(e), this);
     }
     formElements.insert(formElementIndex(e), e);
+    doc->incDOMTreeVersion();
 }
 
 void HTMLFormElement::removeFormElement(HTMLGenericFormElement* e)
@@ -505,6 +506,7 @@ void HTMLFormElement::removeFormElement(HTMLGenericFormElement* e)
             document()->removeRadioButtonGroup(e->name().impl(), this);
     }
     removeFromVector(formElements, e);
+    document()->incDOMTreeVersion();
 }
 
 bool HTMLFormElement::isURLAttribute(Attribute *attr) const