Closed coel closed 8 years ago
I seem to get a NullReferenceException on a document using and matching the :first-child selector.
NullReferenceException
:first-child
Debugging into it, it seems like the cause is ChildMatches() in FirstChild.cs returning null.
ChildMatches()
null
public override IEnumerable<IDomObject> ChildMatches(IDomContainer element) { IDomObject child = element.FirstChild; if (child != null) { yield return element.FirstElementChild; } }
For example, null is returned on a p tag with text where element.FirstChild returns the text, but element.FirstElementChild is null.
element.FirstChild
element.FirstElementChild
Looking at LastChild.cs, it uses element.LastElementChild for both the check and to return.
element.LastElementChild
Is the handling for FirstChild intentionally different, or is this likely a bug?
Looks like a bug. IIRC ChildMatches should never return null.
I seem to get a
NullReferenceException
on a document using and matching the:first-child
selector.Debugging into it, it seems like the cause is
ChildMatches()
in FirstChild.cs returningnull
.For example,
null
is returned on a p tag with text whereelement.FirstChild
returns the text, butelement.FirstElementChild
isnull
.Looking at LastChild.cs, it uses
element.LastElementChild
for both the check and to return.Is the handling for FirstChild intentionally different, or is this likely a bug?