Commits

Mike Orr committed 1c7d5f3

image(alt=None) now does the same as image(alt="").

Comments (0)

Files changed (2)

tests/test_tags.py

                          image('/images/xml.png', alt="Xml"))
         self.assertEqual('<img alt="" src="/images/xml.png" />',
                          image('/images/xml.png', ""))
-        self.assertEqual('<img src="/images/xml.png" />',
+        self.assertEqual('<img alt="" src="/images/xml.png" />',
                          image('/images/xml.png', None))
         self.assertEqual('<img alt="rss syndication" src="/images/rss.png" />',
                          image('/images/rss.png', 'rss syndication'))

webhelpers/html/tags.py

         literal(u'<img alt="Icon" height="16" src="/icons/icon.gif" width="16" />')
 
         >>> image("/icons/icon.gif", None, width=16)
-        literal(u'<img src="/icons/icon.gif" width="16" />')
+        literal(u'<img alt="" src="/icons/icon.gif" width="16" />')
         
     """
-    if alt is not None:
-        attrs['alt'] = alt
+    if not alt:
+        alt = ""
     if width is not None:
         attrs['width'] = width
     if height is not None:
         attrs['height'] = height
-    return HTML.img(src=url, **attrs)
+    return HTML.img(src=url, alt=alt, **attrs)
 
 #### Tags for the HTML head