File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ namespace AngleSharp.XPath.Tests
8
8
public class HtmlDocumentNavigatorTests
9
9
{
10
10
[ Test , Retry ( 5 ) ]
11
- public async Task SelectSinleNodeTest ( )
11
+ public async Task SelectSingleNodeTest ( )
12
12
{
13
13
// Arrange
14
14
const string address = "https://stackoverflow.com/questions/39471800/is-anglesharps-htmlparser-threadsafe" ;
@@ -41,5 +41,25 @@ public void SelectNodes_SelectList_ShouldReturnList()
41
41
// Assert
42
42
Assert . That ( nodes , Has . Count . EqualTo ( 3 ) ) ;
43
43
}
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
+ }
44
64
}
45
65
}
Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ public override XPathNodeType NodeType
91
91
92
92
case Dom . NodeType . Document :
93
93
return XPathNodeType . Element ;
94
+
95
+ case Dom . NodeType . DocumentType :
96
+ return XPathNodeType . Element ;
94
97
95
98
case Dom . NodeType . Element :
96
99
if ( _attrIndex != - 1 )
@@ -110,7 +113,6 @@ public override XPathNodeType NodeType
110
113
case Dom . NodeType . EntityReference :
111
114
case Dom . NodeType . Notation :
112
115
case Dom . NodeType . DocumentFragment :
113
- case Dom . NodeType . DocumentType :
114
116
default :
115
117
throw new NotImplementedException ( ) ;
116
118
}
You can’t perform that action at this time.
0 commit comments