about summary refs log tree commit diff stats
path: root/src/html
diff options
context:
space:
mode:
Diffstat (limited to 'src/html')
-rw-r--r--src/html/dom.nim5
-rw-r--r--src/html/htmlparser.nim9
-rw-r--r--src/html/tags.nim5
3 files changed, 11 insertions, 8 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 109e5dc9..5dde41fa 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -497,9 +497,8 @@ func formmethod*(element: Element): FormMethod =
       of "dialog": FORM_METHOD_DIALOG
       else: FORM_METHOD_GET
 
-  # has form (TODO not only input should be included)
-  if element.tagType == TAG_INPUT:
-    let element = HTMLInputElement(element)
+  if element.tagType in SupportedFormAssociatedElements:
+    let element = FormAssociatedElement(element)
     if element.form != nil:
       if element.form.attrb("method"):
         return case element.form.attr("method").tolower()
diff --git a/src/html/htmlparser.nim b/src/html/htmlparser.nim
index e3c66f79..a8ea5458 100644
--- a/src/html/htmlparser.nim
+++ b/src/html/htmlparser.nim
@@ -198,14 +198,13 @@ func createElement(parser: HTML5Parser, token: Token, namespace: Namespace, inte
   if element.isResettable():
     element.resetElement()
 
-  if element.tagType in FormAssociatedElements and parser.form != nil and
+  if element.tagType in SupportedFormAssociatedElements and parser.form != nil and
       not parser.openElements.hasElement(TAG_TEMPLATE) and
       (element.tagType notin ListedElements or not element.attrb("form")) and
       intendedParent.inSameTree(parser.form):
-    if element.tagType in {TAG_SELECT, TAG_INPUT}: #TODO implement the other ones too
-      let element = FormAssociatedElement(element)
-      element.setForm(parser.form)
-      element.parserInserted = true
+    let element = FormAssociatedElement(element)
+    element.setForm(parser.form)
+    element.parserInserted = true
   return element
 
 proc insert(location: AdjustedInsertionLocation, node: Node) =
diff --git a/src/html/tags.nim b/src/html/tags.nim
index d3bd7f6b..c009b2a5 100644
--- a/src/html/tags.nim
+++ b/src/html/tags.nim
@@ -104,6 +104,11 @@ const FormAssociatedElements* = {
   TAG_BUTTON, TAG_FIELDSET, TAG_INPUT, TAG_OBJECT, TAG_OUTPUT, TAG_SELECT, TAG_TEXTAREA, TAG_IMG
 }
 
+#TODO support all the other ones
+const SupportedFormAssociatedElements* = {
+  TAG_SELECT, TAG_INPUT
+}
+
 const ListedElements* = {
   TAG_BUTTON, TAG_FIELDSET, TAG_INPUT, TAG_OBJECT, TAG_OUTPUT, TAG_SELECT, TAG_TEXTAREA
 }
2' href='#n202'>202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267