File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ namespace AngleSharp.XPath.Tests
88 public class HtmlDocumentNavigatorTests
99 {
1010 [ Test , Retry ( 5 ) ]
11- public async Task SelectSinleNodeTest ( )
11+ public async Task SelectSingleNodeTest ( )
1212 {
1313 // Arrange
1414 const string address = "https://stackoverflow.com/questions/39471800/is-anglesharps-htmlparser-threadsafe" ;
@@ -41,5 +41,25 @@ public void SelectNodes_SelectList_ShouldReturnList()
4141 // Assert
4242 Assert . That ( nodes , Has . Count . EqualTo ( 3 ) ) ;
4343 }
44+
45+ [ Test ]
46+ public void SelectPrecedingNodeInDocumentWithDoctype_ShouldReturnNode ( )
47+ {
48+ // Arrange
49+ const string html =
50+ @"<!DOCTYPE html>
51+ <body>
52+ <span></span>
53+ <div></div>
54+ </body>" ;
55+ var parser = new HtmlParser ( ) ;
56+ var document = parser . ParseDocument ( html ) ;
57+
58+ // Act
59+ var node = document . DocumentElement . SelectSingleNode ( "//div/preceding::span" ) ;
60+
61+ // Assert
62+ Assert . That ( node , Is . Not . Null ) ;
63+ }
4464 }
4565}
Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ public override XPathNodeType NodeType
9191
9292 case Dom . NodeType . Document :
9393 return XPathNodeType . Element ;
94+
95+ case Dom . NodeType . DocumentType :
96+ return XPathNodeType . Element ;
9497
9598 case Dom . NodeType . Element :
9699 if ( _attrIndex != - 1 )
@@ -110,7 +113,6 @@ public override XPathNodeType NodeType
110113 case Dom . NodeType . EntityReference :
111114 case Dom . NodeType . Notation :
112115 case Dom . NodeType . DocumentFragment :
113- case Dom . NodeType . DocumentType :
114116 default :
115117 throw new NotImplementedException ( ) ;
116118 }
You can’t perform that action at this time.
0 commit comments