]> git.dolda2000.com Git - wrw.git/commitdiff
Allow setting attributes to None as a noop, for convenience.
authorFredrik Tolf <fredrik@dolda2000.com>
Sun, 15 Sep 2013 22:40:02 +0000 (00:40 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Sun, 15 Sep 2013 22:40:02 +0000 (00:40 +0200)
wrw/sp/cons.py
wrw/sp/xhtml.py

index ce258c65325b3318c6b66b636f1ca35f05586403..4052dce03344e06ee3c00c31b255461f0664cd4e 100644 (file)
@@ -60,7 +60,8 @@ class context(object):
         node.children.append(self.nodefrom(child))
 
     def addattr(self, node, k, v):
-        node.attrs[unicode(k)] = unicode(v)
+        if v is not None:
+            node.attrs[unicode(k)] = unicode(v)
 
 class constructor(object):
     def __init__(self, ns, elcls=element, ctx=None):
index e78d1972da005d7fca4d47bc6daa045d14bd6f3a..f10d3158fe53fdc2eb8e5c6140b8e9feb53fef72 100644 (file)
@@ -19,7 +19,7 @@ class xhtmlcontext(_cons.context):
 
     def addattr(self, node, k, v):
         k = unicode(k)
-        node.attrs[self.attrmap.get(k, k)] = unicode(v)
+        super(xhtmlcontext, self).addattr(node, self.attrmap.get(k, k), v)
 
 def cons(ctx=None):
     if ctx is None: ctx = xhtmlcontext()