remove disable_with if not needed

This commit is contained in:
niphlod
2014-01-23 21:59:43 +01:00
parent 4cbdf612af
commit 341a5e0c40
2 changed files with 51 additions and 6 deletions
+6 -3
View File
@@ -1482,8 +1482,11 @@ class A(DIV):
def xml(self):
if not self.components and self['_href']:
self.append(self['_href'])
if not self['_disable_with']:
self['_data-w2p_disable_with'] = 'default'
disable_needed = ['callback', 'cid', 'delete', 'component', 'target']
disable_needed = any((self[attr] for attr in disable_needed))
if disable_needed:
self['_data-w2p_disable_with'] = self['_disable_with'] or 'default'
self['_disable_with'] = None
if self['callback'] and not self['_id']:
self['_id'] = web2py_uuid()
if self['delete']:
@@ -2518,7 +2521,7 @@ def test():
>>> from validators import *
>>> print DIV(A('click me', _href=URL(a='a', c='b', f='c')), BR(), HR(), DIV(SPAN("World"), _class='unknown')).xml()
<div><a data-w2p_disable_with="default" href="/a/b/c">click me</a><br /><hr /><div class=\"unknown\"><span>World</span></div></div>
<div><a href="/a/b/c">click me</a><br /><hr /><div class=\"unknown\"><span>World</span></div></div>
>>> print DIV(UL("doc","cat","mouse")).xml()
<div><ul><li>doc</li><li>cat</li><li>mouse</li></ul></div>
>>> print DIV(UL("doc", LI("cat", _class='feline'), 18)).xml()