@@ 195,7 195,21 @@ clickEl' session (XML.Element (XML.Name name _ _) attrs _) cursor
| name == "input", Just "checkbox" <- "type" `M.lookup` attrs',
Just name <- "name" `M.lookup` attrs', Just value <- "value" `M.lookup` attrs' =
modifyForm (toggleOption value) name cursor session
- -- TODO implement datalists...
+ | name == "option", Just value <- "value" `M.lookup` attrs',
+ (datalist:_) <- (XC.checkName (== "datalist") XC.>=> XC.ancestor) cursor,
+ XML.NodeElement (XML.Element "datalist" attrs2 _) <- XC.node datalist,
+ Just id <- "id" `M.lookup` M.mapKeys XML.nameLocalName attrs2 = do
+ root <- withMVar session (\session' -> return . XC.fromDocument $ document session')
+ let refsList (XML.Element _ attrs3 _) = M.lookup "list" (M.mapKeys XML.nameLocalName attrs3) == Just id
+ let input = XC.checkElement refsList XC.>=> XC.checkName (== "input") XC.>=> XC.descendant
+ let (input', attrs4') = case input root of {
+ (input':_) | XML.NodeElement (XML.Element "input" attrs4 _) <- XC.node input' ->
+ (input', M.mapKeys XML.nameLocalName attrs4);
+ _ -> (root, M.empty)
+ }
+ case "name" `M.lookup` attrs4' of
+ Just name -> modifyForm (const [value]) name input' session
+ Nothing -> return ()
| name == "option", (select:_) <- XC.parent cursor,
XML.NodeElement select'@(XML.Element "select" attrs2 _) <- XC.node select,
let attrs2' = M.mapKeys XML.nameLocalName attrs2,
@@ 203,6 217,9 @@ clickEl' session (XML.Element (XML.Name name _ _) attrs _) cursor
if "multiple" `M.member` attrs2'
then modifyForm (toggleOption value) name cursor session
else modifyForm (const [value]) name cursor session
+ | name == "label", Just for <- "for" `M.lookup` attrs' = do
+ input <- withMVar session (return . HM.lookup for . id2els)
+ case input of { Just input' -> clickEl session input'; Nothing -> return () }
| otherwise = return ()
where
attrs' = M.mapKeys XML.nameLocalName attrs