Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
allow None as an attribute value, for HTML boolean attributes #201
I was writing a script to convert some tags in Angular templates to a new API, and noticed that curiously lxml could parse and re-serialize boolean tags that have no value, but could not create new ones. It turns out libxml2 supports this by accepting NULL as the value for xmlSetNsProp(), creating an attribute node with NULL children instead of a text node.
This change allows None as a value for Element.set() so that those who value attributes with no value can create the same.
Note that lxml.etree.tostring() serializes these as