Skip to content

Commit 4cccb13

Browse files
authored
Merge pull request #74 from campersau/getinnertextcomment
Don't throw in GetInnerText if there is no element style. e.g. for co…
2 parents 133c64d + 3ce9350 commit 4cccb13

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/AngleSharp.Css.Tests/Extensions/InnerText.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public void SetInnerText(String fixture, String expectedInnerText, String expect
7171
[TestCase("<textarea>test</textarea>", "")]
7272
[TestCase("<script>test</noscript>", "")]
7373
[TestCase("<style>test</style>", "")]
74+
[TestCase("<!-- comment -->Text<!-- comment --> with <!-- comment -->comments<!-- comment -->", "Text with comments")]
7475
public void GetInnerText(String fixture, String expected)
7576
{
7677
var defaultSheet = new CssDefaultStyleSheetProvider();

src/AngleSharp.Css/Extensions/ElementExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private static void ItcInCssBox(ICssStyleDeclaration elementStyle, ICssStyleDecl
202202
{
203203
sb.Append(Symbols.LineFeed);
204204
}
205-
else if ((node is IHtmlTableCellElement && String.IsNullOrEmpty(elementStyle.GetDisplay())) || elementStyle.GetDisplay() == CssKeywords.TableCell)
205+
else if (elementStyle != null && ((node is IHtmlTableCellElement && String.IsNullOrEmpty(elementStyle.GetDisplay())) || elementStyle.GetDisplay() == CssKeywords.TableCell))
206206
{
207207
if (node.NextSibling is IElement nextSibling)
208208
{
@@ -214,7 +214,7 @@ private static void ItcInCssBox(ICssStyleDeclaration elementStyle, ICssStyleDecl
214214
}
215215
}
216216
}
217-
else if ((node is IHtmlTableRowElement && String.IsNullOrEmpty(elementStyle.GetDisplay())) || elementStyle.GetDisplay() == CssKeywords.TableRow)
217+
else if (elementStyle != null && ((node is IHtmlTableRowElement && String.IsNullOrEmpty(elementStyle.GetDisplay())) || elementStyle.GetDisplay() == CssKeywords.TableRow))
218218
{
219219
if (node.NextSibling is IElement nextSibling)
220220
{

0 commit comments

Comments
 (0)