Permalink
Browse files

Add test for non-last empty attribute

  • Loading branch information...
1 parent bd377a7 commit d097b1d55c3a0ff7ff78c2071bc3d3d4c4868caa @cdsmith cdsmith committed Feb 24, 2012
@@ -239,9 +239,10 @@ attrValue = quotedAttrValue <|> unquotedAttrValue
attribute :: Parser (Text, Text)
attribute = do
n <- attrName
- _ <- optional XML.whiteSpace
v <- optional $ do
- _ <- P.char '='
+ _ <- P.try $ do
+ _ <- optional XML.whiteSpace
+ P.char '='
_ <- optional XML.whiteSpace
attrValue
return $ maybe (n,"") (n,) v
@@ -0,0 +1 @@
+Dashes are allowed in HTML attribute names.
@@ -363,6 +363,7 @@ htmlParsingQuirkTests = [
testIt "laxAttrName " laxAttrName,
testCase "badAttrName " badAttrName,
testIt "emptyAttr " emptyAttr,
+ testIt "emptyAttr2 " emptyAttr2,
testIt "unquotedAttr " unquotedAttr,
testIt "laxAttrVal " laxAttrVal,
testIt "ampersandInText " ampersandInText,
@@ -439,6 +440,10 @@ emptyAttr :: Bool
emptyAttr = parseHTML "" "<test attr></test>"
== Right (HtmlDocument UTF8 Nothing [Element "test" [("attr", "")] []])
+emptyAttr2 :: Bool
+emptyAttr2 = parseHTML "" "<div itemscope itemtype=\"type\"></div>"
+ == Right (HtmlDocument UTF8 Nothing [Element "div" [("itemscope", ""), ("itemtype", "type")] []])
+
unquotedAttr :: Bool
unquotedAttr = parseHTML "" "<test attr=you&amp;me></test>"
== Right (HtmlDocument UTF8 Nothing [Element "test" [("attr", "you&me")] []])
@@ -9,7 +9,7 @@ Executable testsuite
build-depends:
HUnit == 1.2.*,
- directory == 1.0.*,
+ directory >= 1.0 && < 1.2,
QuickCheck >= 2.3.0.2,
base == 4.*,
blaze-builder >= 0.2 && < 0.4,

0 comments on commit d097b1d

Please sign in to comment.