View Issue Details

IDProjectCategoryView StatusLast Update
0035308LazarusLazUtilspublic2020-06-01 23:47
ReporterDon Siders Assigned ToMattias Gaertner  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
PlatformWIndowsOS64-bit 
Product Version2.1 (SVN) 
Summary0035308: TDOMElement.IsEmpty implementation is wrong
DescriptionIn 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;
TagsNo tags attached.
Fixed in Revision
LazTarget
Widgetset
Attached Files

Activities

Juha Manninen

2019-04-03 19:21

developer   ~0115199

Does the change break lots of existing code?

Don Siders

2019-04-03 22:32

reporter   ~0115205

It's not used internally.

It is used in TXMLConfig.InternalCleanNode. Affects TXMLConfig.DeletePath and TXMLConfig.DeleteValue.

I see no other usage of IsEmpty in LCL or LazUtils.

This should not break anything unless the code should have been using "not HasAttibutes" all along.

Don Siders

2020-06-01 00:49

reporter   ~0123156

Obviously, this is not going to be fixed. Just close it,

Maxim Ganetsky

2020-06-01 23:47

developer   ~0123172

Mattias, can you look at this report?

Issue History

Date Modified Username Field Change
2019-04-02 01:45 Don Siders New Issue
2019-04-03 19:21 Juha Manninen Note Added: 0115199
2019-04-03 22:32 Don Siders Note Added: 0115205
2020-06-01 00:49 Don Siders Note Added: 0123156
2020-06-01 23:46 Maxim Ganetsky Assigned To => Mattias Gaertner
2020-06-01 23:46 Maxim Ganetsky Status new => assigned
2020-06-01 23:47 Maxim Ganetsky Note Added: 0123172