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;

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ public Boolean IsNotation
2929
set;
3030
}
3131

32-
public List<String> Names
33-
{
34-
get { return _names; }
35-
}
32+
public List<String> Names => _names;
3633

3734
#endregion
3835

src/AngleSharp.Xml/Dtd/Declaration/AttributeDeclaration.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ public AttributeDeclarationEntry this[Int32 index]
2929
get { return _attrs[index]; }
3030
}
3131

32-
public Int32 Count
33-
{
34-
get { return _attrs.Count; }
35-
}
32+
public Int32 Count => _attrs.Count;
3633

3734
public IEnumerable<AttributeDeclarationEntry> Declarations
3835
{

src/AngleSharp.Xml/Dtd/Declaration/Element/ElementChoiceDeclarationEntry.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ sealed class ElementChoiceDeclarationEntry : ElementChildrenDeclarationEntry
77
{
88
#region Properties
99

10-
public List<ElementQuantifiedDeclarationEntry> Choice
11-
{
12-
get { return _children; }
13-
}
10+
public List<ElementQuantifiedDeclarationEntry> Choice => _children;
1411

1512
#endregion
1613

src/AngleSharp.Xml/Dtd/Declaration/Element/ElementDeclarationEntry.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,11 @@ abstract class ElementDeclarationEntry
1616

1717
#region Properties
1818

19-
public ElementContentType Type
20-
{
21-
get { return _type; }
22-
}
19+
public ElementContentType Type => _type;
2320

24-
public static ElementAnyDeclarationEntry Any
25-
{
26-
get { return _any ?? (_any = new ElementAnyDeclarationEntry()); }
27-
}
21+
public static ElementAnyDeclarationEntry Any => _any ?? (_any = new ElementAnyDeclarationEntry());
2822

29-
public static ElementEmptyDeclarationEntry Empty
30-
{
31-
get { return _empty ?? (_empty = new ElementEmptyDeclarationEntry()); }
32-
}
23+
public static ElementEmptyDeclarationEntry Empty => _empty ?? (_empty = new ElementEmptyDeclarationEntry());
3324

3425
#endregion
3526

@@ -46,8 +37,8 @@ abstract class ElementQuantifiedDeclarationEntry : ElementDeclarationEntry
4637

4738
public ElementQuantifier Quantifier
4839
{
49-
get { return _quantifier; }
50-
set { _quantifier = value; }
40+
get => _quantifier;
41+
set => _quantifier = value;
5142
}
5243
}
5344

src/AngleSharp.Xml/Dtd/Declaration/Element/ElementMixedDeclarationEntry.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ public ElementMixedDeclarationEntry()
2424

2525
#region Properties
2626

27-
public List<String> Names
28-
{
29-
get { return _names; }
30-
}
27+
public List<String> Names => _names;
3128

3229
#endregion
3330

src/AngleSharp.Xml/Dtd/Declaration/Element/ElementSequenceDeclarationEntry.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ namespace AngleSharp.Xml.Dtd.Declaration
55

66
sealed class ElementSequenceDeclarationEntry : ElementChildrenDeclarationEntry
77
{
8-
public List<ElementQuantifiedDeclarationEntry> Sequence
9-
{
10-
get { return _children; }
11-
}
8+
public List<ElementQuantifiedDeclarationEntry> Sequence => _children;
129

1310
public override Boolean Check(NodeInspector inspector)
1411
{

src/AngleSharp.Xml/Dtd/Declaration/Element/NodeInspector.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,18 @@ public NodeInspector(IElement element)
2121
}
2222
}
2323

24-
public List<INode> Children
25-
{
26-
get { return nodes; }
27-
}
24+
public List<INode> Children => nodes;
2825

29-
public INode Current
30-
{
31-
get { return Children[Index]; }
32-
}
26+
public INode Current => Children[Index];
3327

34-
public Int32 Length
35-
{
36-
get { return Children.Count; }
37-
}
28+
public Int32 Length => Children.Count;
3829

3930
public Int32 Index
4031
{
4132
get;
4233
set;
4334
}
4435

45-
public Boolean IsCompleted
46-
{
47-
get { return Children.Count == Index; }
48-
}
36+
public Boolean IsCompleted => Children.Count == Index;
4937
}
5038
}

0 commit comments

Comments
 (0)