TDOMElement.IsEmpty implementation is wrong
Original Reporter info from Mantis: dsiders @dsiders
-
Reporter name: Don Siders
Original Reporter info from Mantis: dsiders @dsiders
- Reporter name: Don Siders
Description:
In unit components/lazutils/laz2_dom.pas.
TDOMElemen.IsEmpty seems to have an invalid implementation. The existing code checks for the presence of Attributes on the element.
The method is not part of the DOM specification. So I am assuming it is a convenience method.
And, according to the XML 1.0 specification, this implementation is not correct. XML defines an empty element as one with no content, as in child elements or text nodes, not Attributes. It explicitly allows attributes in an empty tag.
See: https://www.w3.org/TR/1998/REC-xml-19980210#sec-starttags
In other words, both of the following qualify as empty elements:
<foo/>
<foo bar="42"/>
It seems the correct logical test should be:
Result := not HasChildNodes;
Mantis conversion info:
- Mantis ID: 35308
- OS: 64-bit
- OS Build: 8.1
- Platform: WIndows
- Version: 2.1 (SVN)