about summary refs log tree commit diff stats
path: root/src/html
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-07-30 19:31:42 +0200
committerbptato <nincsnevem662@gmail.com>2022-07-30 19:31:42 +0200
commit14900f15118f79b841a17d4b0d817a60a551f2f3 (patch)
tree18e02868198e0c720b98a1b26aee82b21ee02af0 /src/html
parented7afdbfd3686babaa81b4a9f169ba5d60178200 (diff)
downloadchawan-14900f15118f79b841a17d4b0d817a60a551f2f3.tar.gz
Add SupportedFormAssociatedElements
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
 }