haskell/xhtml — Issue #2: duplicate attributes 
Author: Mistuke
Created: 2011-11-07 08:52:40+00:00
State: open

The way (!) is currently implemented allows duplicate attributes to occur inside an element. You won't notice a problem with most browsers since they are rather forgiving on these types of things.

instance ADDATTRS Html where
(Html htmls) ! attr = Html (map addAttrs htmls)
where
addAttrs (html@(HtmlTag { markupAttrs = attrs }) )
= html { markupAttrs = attrs ++ attr }
addAttrs html = html

The problem is that when duplicate attributes occur, it in turn makes tools like haddock generate invalid xhtml.
According to [1] duplicate attributes are not allowed.
Or in a more specific case, haddock generates duplicate class
attributes `

` which according to
[2] should instead be `

`.

I'm reporting this to you rather than the haddock people because the
Html type is abstract. There's no way to modify existing attributes or
test for the existence of one. For the case of classes you can
probably solve it quite easily by just grouping them, but I'm not sure
if this is in general the case.

[1] http://www.w3.org/WAI/GL/WCAG20-TECHS/H94.html
[2] http://www.w3.org/TR/html4/struct/global.html#h-7.5.2