Support <optgroup> tags in <select> forms.
authorKenjiro NAKAYAMA <nakayamakenjiro@gmail.com>
Sun, 1 Dec 2013 13:21:53 +0000 (14:21 +0100)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Sun, 1 Dec 2013 13:21:53 +0000 (14:21 +0100)
* net/eww.el (eww-tag-select): Support <optgroup> tags in <select>
forms.

Test case:

<html>
<head><title>SELECT TEST</title></head>
<body>

<form method="POST" action="./dummy.php">
<input type="text" name="text1">
<input type="submit" name="btn1" value="val1">

<select>
<optgroup label="group 1">
<option value="a">Value A</option>
<option value="b">Value B</option>
</optgroup>
<optgroup label="group 2">
<option value="c">Value C</option>
<option value="d">Value D</option>
</optgroup>
</select>

</form>
</body>
</html>

Fixes: debbugs:15860

lisp/ChangeLog
lisp/net/eww.el

index e9c8b52..11c3ae4 100644 (file)
@@ -1,3 +1,8 @@
+2013-12-01  Kenjiro NAKAYAMA  <nakayamakenjiro@gmail.com>
+
+       * net/eww.el (eww-tag-select): Support <optgroup> tags in <select>
+       forms.
+
 2013-12-01  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * net/eww.el (eww-restore-history): Update the window title after
index 70fd564..5b1fc08 100644 (file)
@@ -737,8 +737,14 @@ appears in a <link> or <a> tag."
                    :eww-form eww-form))
        (options nil)
        (start (point))
-       (max 0))
-    (dolist (elem cont)
+       (max 0)
+       opelem)
+    (if (eq (car (car cont)) 'optgroup)
+       (dolist (groupelem cont)
+         (unless (cdr (assq :disabled (cdr groupelem)))
+           (setq opelem (append opelem (cdr (cdr groupelem))))))
+      (setq opelem cont))
+    (dolist (elem opelem)
       (when (eq (car elem) 'option)
        (when (cdr (assq :selected (cdr elem)))
          (nconc menu (list :value