Mercurial > genshi > genshi-test
diff genshi/core.py @ 907:bb813ef5fe25 experimental-inline
inline branch: merged r1129 from trunk.
author | cmlenz |
---|---|
date | Wed, 28 Apr 2010 21:36:59 +0000 |
parents | 09cc3627654c |
children |
line wrap: on
line diff
--- a/genshi/core.py +++ b/genshi/core.py @@ -379,14 +379,19 @@ def __or__(self, attrs): """Return a new instance that contains the attributes in `attrs` in - addition to any already existing attributes. + addition to any already existing attributes. Any attributes in the new + set that have a value of `None` are removed. :return: a new instance with the merged attributes :rtype: `Attrs` """ - repl = dict([(an, av) for an, av in attrs if an in self]) - return Attrs([(sn, repl.get(sn, sv)) for sn, sv in self] + - [(an, av) for an, av in attrs if an not in self]) + remove = set([an for an, av in attrs if av is None]) + replace = dict([(an, av) for an, av in attrs + if an in self and av is not None]) + return Attrs([(sn, replace.get(sn, sv)) for sn, sv in self + if sn not in remove] + + [(an, av) for an, av in attrs + if an not in self and an not in remove]) def __repr__(self): if not self: @@ -507,7 +512,7 @@ if type(text) is cls: return text if hasattr(text, '__html__'): - return Markup(text.__html__()) + return cls(text.__html__()) text = text.replace('&', '&') \ .replace('<', '<') \