File tree Expand file tree Collapse file tree 3 files changed +34
-15
lines changed
Expand file tree Collapse file tree 3 files changed +34
-15
lines changed Original file line number Diff line number Diff line change 1- using System . Xml ;
2- using AngleSharp . Xml . Parser ;
1+ using AngleSharp . Dom ;
32using AngleSharp . Html . Parser ;
3+ using AngleSharp . Xml . Parser ;
44using NUnit . Framework ;
55using System . Threading . Tasks ;
6+ using System . Xml ;
67using System . Xml . XPath ;
7- using AngleSharp . Dom ;
88
99namespace AngleSharp . XPath . Tests
1010{
@@ -173,5 +173,29 @@ public void MoveToParent_CallWhenCurrentNodeIsAttr_ShouldBeMovedToAttrOwnerEleme
173173 // Assert
174174 Assert . AreEqual ( nav . Name , "root" ) ;
175175 }
176+
177+ [ Test ]
178+ public void SelectSingleNodeTest_AttributesOrder ( )
179+ {
180+ // Arrange
181+ const string html =
182+ @"<body>
183+ <div id='div1'>First</div>
184+ <div id='div2' class='mydiv'>Second</div>
185+ <div class='mydiv' id='div3'>Third</div>
186+ </body>" ;
187+ var parser = new HtmlParser ( ) ;
188+ var document = parser . ParseDocument ( html ) ;
189+
190+ // Act
191+ var div1 = document . DocumentElement . SelectSingleNode ( "//div[@id='div1']" ) ;
192+ var div2 = document . DocumentElement . SelectSingleNode ( "//div[@id='div2']" ) ;
193+ var div3 = document . DocumentElement . SelectSingleNode ( "//div[@id='div3']" ) ;
194+
195+ // Assert
196+ Assert . That ( div1 , Is . Not . Null ) ;
197+ Assert . That ( div2 , Is . Not . Null ) ;
198+ Assert . That ( div3 , Is . Not . Null ) ; // currently fails
199+ }
176200 }
177201}
Original file line number Diff line number Diff line change 11<Project Sdk =" Microsoft.NET.Sdk" >
22 <PropertyGroup >
3- <Version >2.0.0 </Version >
4- <AssemblyVersion >2.0.0 </AssemblyVersion >
5- <FileVersion >2.0.0 </FileVersion >
3+ <Version >2.0.1 </Version >
4+ <AssemblyVersion >2.0.1 </AssemblyVersion >
5+ <FileVersion >2.0.1 </FileVersion >
66 <Authors >Denis Ivanov</Authors >
77 <PackageId >AngleSharp.XPath</PackageId >
88 <AssemblyName >AngleSharp.XPath</AssemblyName >
2020 </PropertyGroup >
2121
2222 <ItemGroup >
23- <PackageReference Include =" AngleSharp" Version =" 0.17.0 " />
23+ <PackageReference Include =" AngleSharp" Version =" 0.17.1 " />
2424 </ItemGroup >
2525
2626 <ItemGroup Condition =" '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'net472' or '$(TargetFramework)' == 'net6.0' " >
Original file line number Diff line number Diff line change @@ -283,11 +283,6 @@ public override bool MoveToNext()
283283 /// <inheritdoc />
284284 public override bool MoveToNextAttribute ( )
285285 {
286- if ( CurrentElement == null )
287- {
288- return false ;
289- }
290-
291286 if ( ! ( CurrentNode is IAttr attr ) )
292287 {
293288 return false ;
@@ -300,10 +295,10 @@ public override bool MoveToNextAttribute()
300295
301296 var attrIndex = attr . OwnerElement . Attributes . Index ( attr ) ;
302297
303- if ( attrIndex >= CurrentElement . Attributes . Length - 1 )
304- {
298+ if ( attrIndex == attr . OwnerElement . Attributes . Length - 1 )
299+ {
305300 return false ;
306- }
301+ }
307302
308303 _currentNode = attr . OwnerElement . Attributes [ attrIndex + 1 ] ;
309304 return true ;
You can’t perform that action at this time.
0 commit comments