Skip to content

Commit

Permalink
fix for #48 End tag removed when option tag found in html
Browse files Browse the repository at this point in the history
  • Loading branch information
waqasm78 committed Jul 31, 2017
1 parent f5a9108 commit bc0dd47
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/HtmlAgilityPack.Tests/HtmlDocumentTests.cs
Expand Up @@ -548,5 +548,15 @@ public void TestFormTag()
Assert.AreEqual(document.DocumentNode.OuterHtml, html);
Assert.AreEqual(result.Count(), 1);
}
[Test]
public void TestOptionTag()
{
var html = "<select><option>Select a cell</option><option>C1</option><option value='\"c2\"'></select>";

string output = "<select><option>Select a cell</option><option>C1</option><option value='\"c2\"'></option></select>";
var document = new HtmlDocument();
document.LoadHtml(html);
Assert.AreEqual(document.DocumentNode.OuterHtml, output);
}
}
}
2 changes: 2 additions & 0 deletions src/HtmlAgilityPack/HtmlDocument.cs
Expand Up @@ -1055,6 +1055,8 @@ private string[] GetResetters(string name)
case "td":
return new string[] {"tr", "table"};

case "option":
return new string[] { "select", "optgroup", "datalist" };
default:
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/HtmlAgilityPack/HtmlNode.cs
Expand Up @@ -109,7 +109,7 @@ static HtmlNode()
ElementsFlags.Add("form", HtmlElementFlag.CanOverlap);

// they sometimes contain, and sometimes they don 't...
ElementsFlags.Add("option", HtmlElementFlag.Empty);
//ElementsFlags.Add("option", HtmlElementFlag.Empty);

// tag whose closing tag is equivalent to open tag:
// <p>bla</p>bla will be transformed into <p>bla</p>bla
Expand Down

0 comments on commit bc0dd47

Please sign in to comment.