Skip to content

Commit a7c9f50

Browse files
authored
Merge pull request #3 from AngleSharp/devel
Published v0.12
2 parents 59293c4 + 77d3925 commit a7c9f50

37 files changed

+195
-216
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 0.12.0
2+
3+
Released on Thursday, May 2 2019.
4+
5+
- Reference latest AngleSharp
6+
- Improved `InnerHtml` / XML fragment parsing (#1)
7+
18
# 0.11.0
29

310
Released on Tuesday, February 12 2019.

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[![GitHub Tag](https://img.shields.io/github/tag/AngleSharp/AngleSharp.Xml.svg?style=flat-square)](https://github.com/AngleSharp/AngleSharp.Xml/releases)
77
[![NuGet Count](https://img.shields.io/nuget/dt/AngleSharp.Xml.svg?style=flat-square)](https://www.nuget.org/packages/AngleSharp.Xml/)
88
[![Issues Open](https://img.shields.io/github/issues/AngleSharp/AngleSharp.Xml.svg?style=flat-square)](https://github.com/AngleSharp/AngleSharp.Xml/issues)
9+
[![Gitter Chat](http://img.shields.io/badge/gitter-AngleSharp/AngleSharp-blue.svg?style=flat-square)](https://gitter.im/AngleSharp/AngleSharp)
910
[![StackOverflow Questions](https://img.shields.io/stackexchange/stackoverflow/t/anglesharp.svg?style=flat-square)](https://stackoverflow.com/tags/anglesharp)
1011
[![CLA Assistant](https://cla-assistant.io/readme/badge/AngleSharp/AngleSharp.Xml?style=flat-square)](https://cla-assistant.io/AngleSharp/AngleSharp.Xml)
1112

@@ -41,6 +42,16 @@ Participation in the project is highly welcome. For this project the same rules
4142

4243
If you have any question, concern, or spot an issue then please report it before opening a pull request. An initial discussion is appreciated regardless of the nature of the problem.
4344

45+
Live discussions can take place in our [Gitter chat](https://gitter.im/AngleSharp/AngleSharp), which supports using GitHub accounts.
46+
47+
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community.
48+
49+
For more information see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct).
50+
51+
## .NET Foundation
52+
53+
This project is supported by the [.NET Foundation](https://dotnetfoundation.org).
54+
4455
## License
4556

4657
The MIT License (MIT)

src/AngleSharp.Xml.Tests/Dom/XmlTree.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,17 @@ public void XmlValidDocumentBooksTree()
7070
//Assert.AreEqual(12, xml.DocumentElement.ChildElementCount);
7171
//Assert.AreEqual(6, xml.DocumentElement.Children[2].ChildElementCount);
7272
}
73+
74+
[Test]
75+
public void FragmentParsing_Issue1()
76+
{
77+
var xmlParser = new XmlParser();
78+
var xmlDocument = xmlParser.ParseDocument("<div></div>");
79+
var querySelector = xmlDocument.QuerySelector("div");
80+
81+
querySelector.InnerHtml = "<a></a>";
82+
83+
Assert.AreEqual("<div><a></a></div>", xmlDocument.ToHtml());
84+
}
7385
}
7486
}

src/AngleSharp.Xml.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<copyright>Copyright 2016-2019, AngleSharp</copyright>
1515
<tags>html html5 css css3 dom requester http https xml dtd</tags>
1616
<dependencies>
17-
<dependency id="AngleSharp" version="0.11.0" />
17+
<dependency id="AngleSharp" version="0.12.0" />
1818
</dependencies>
1919
</metadata>
2020
</package>

src/AngleSharp.Xml/AngleSharp.Xml.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="AngleSharp" Version="0.11.0" />
12+
<PackageReference Include="AngleSharp" Version="0.12.0" />
1313
</ItemGroup>
1414

1515
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">

src/AngleSharp.Xml/AutoSelectedMarkupFormatter.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ private IMarkupFormatter ChildFormatter
5353

5454
return childFormatter ?? HtmlMarkupFormatter.Instance;
5555
}
56-
set
57-
{
58-
childFormatter = value;
59-
}
56+
set => childFormatter = value;
6057
}
6158

6259
#endregion
@@ -68,10 +65,7 @@ private IMarkupFormatter ChildFormatter
6865
/// </summary>
6966
/// <param name="attribute">The attribute to serialize.</param>
7067
/// <returns>The formatted attribute.</returns>
71-
public String Attribute(IAttr attribute)
72-
{
73-
return ChildFormatter.Attribute(attribute);
74-
}
68+
public String Attribute(IAttr attribute) => ChildFormatter.Attribute(attribute);
7569

7670
/// <summary>
7771
/// Formats opening a tag with the given name.
@@ -143,10 +137,7 @@ public String Processing(IProcessingInstruction processing)
143137
/// </summary>
144138
/// <param name="text">The text to sanatize.</param>
145139
/// <returns>The formatted text.</returns>
146-
public String Text(ICharacterData text)
147-
{
148-
return ChildFormatter.Text(text);
149-
}
140+
public String Text(ICharacterData text) => ChildFormatter.Text(text);
150141

151142
#endregion
152143

src/AngleSharp.Xml/Dom/Internal/SvgDocument.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,11 @@ internal SvgDocument(IBrowsingContext context = null)
3535

3636
#region Properties
3737

38-
public override IElement DocumentElement
39-
{
40-
get { return RootElement; }
41-
}
38+
public override IElement DocumentElement => RootElement;
4239

43-
public ISvgSvgElement RootElement
44-
{
45-
get { return this.FindChild<ISvgSvgElement>(); }
46-
}
40+
public ISvgSvgElement RootElement => this.FindChild<ISvgSvgElement>();
4741

48-
public override IEntityProvider Entities
49-
{
50-
get { return Context.GetProvider<IEntityProvider>() ?? XmlEntityProvider.Resolver; }
51-
}
42+
public override IEntityProvider Entities => Context.GetProvider<IEntityProvider>() ?? XmlEntityProvider.Resolver;
5243

5344
#endregion
5445

src/AngleSharp.Xml/Dom/Internal/XmlDocument.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,17 @@ internal XmlDocument(IBrowsingContext context = null)
2727

2828
#region Properties
2929

30-
public override IElement DocumentElement
31-
{
32-
get { return this.FindChild<IElement>(); }
33-
}
30+
public override IElement DocumentElement => this.FindChild<IElement>();
3431

35-
public override IEntityProvider Entities
36-
{
37-
get { return Context.GetProvider<IEntityProvider>() ?? XmlEntityProvider.Resolver; }
38-
}
32+
public override IEntityProvider Entities => Context.GetProvider<IEntityProvider>() ?? XmlEntityProvider.Resolver;
3933

4034
public Boolean IsValid => true;
4135

4236
#endregion
4337

4438
#region Methods
4539

46-
public override Element CreateElementFrom(String name, String prefix)
47-
{
48-
return new XmlElement(this, name, prefix);
49-
}
40+
public override Element CreateElementFrom(String name, String prefix) => new XmlElement(this, name, prefix);
5041

5142
public override Node Clone(Document owner, Boolean deep)
5243
{

src/AngleSharp.Xml/Dom/Internal/XmlElement.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
namespace AngleSharp.Xml.Dom
22
{
33
using AngleSharp.Dom;
4+
using AngleSharp.Text;
5+
using AngleSharp.Xml.Parser;
46
using System;
57

68
/// <summary>
@@ -29,6 +31,21 @@ internal String IdAttribute
2931

3032
#region Methods
3133

34+
/// <inheritdoc />
35+
public override IElement ParseSubtree(String html)
36+
{
37+
var context = ((IElement)this).Owner?.Context;
38+
var source = new TextSource(html);
39+
var document = new XmlDocument(context, source);
40+
var parser = new XmlDomBuilder(document);
41+
var options = new XmlParserOptions
42+
{
43+
IsSuppressingErrors = true,
44+
};
45+
return parser.ParseFragment(options, this).DocumentElement;
46+
}
47+
48+
/// <inheritdoc />
3249
public override Node Clone(Document owner, Boolean deep)
3350
{
3451
var node = new XmlElement(owner, LocalName, Prefix);

src/AngleSharp.Xml/Dtd/Declaration/Attribute/AttributeDeclarationEntry.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public String Name
2222

2323
public AttributeTypeDeclaration Type
2424
{
25-
get { return _type; }
25+
get => _type;
2626
set
2727
{
2828
_type = value;
@@ -32,7 +32,7 @@ public AttributeTypeDeclaration Type
3232

3333
public AttributeValueDeclaration Default
3434
{
35-
get { return _value; }
35+
get => _value;
3636
set
3737
{
3838
_value = value;

0 commit comments

Comments
 (0)