Browse Source

Merge branch 'master' into patch-3

pull/1083/head
Jeremy Koritzinsky 9 years ago
committed by GitHub
parent
commit
a5bf341fe5
  1. 2
      src/Avalonia.Base/Collections/AvaloniaList.cs
  2. 14
      src/Avalonia.Controls/Classes.cs
  3. 12
      tests/Avalonia.Controls.UnitTests/ClassesTests.cs

2
src/Avalonia.Base/Collections/AvaloniaList.cs

@ -220,7 +220,7 @@ namespace Avalonia.Collections
/// <summary> /// <summary>
/// Removes all items from the collection. /// Removes all items from the collection.
/// </summary> /// </summary>
public void Clear() public virtual void Clear()
{ {
if (this.Count > 0) if (this.Count > 0)
{ {

14
src/Avalonia.Controls/Classes.cs

@ -86,6 +86,20 @@ namespace Avalonia.Controls
base.AddRange(c); base.AddRange(c);
} }
/// <summary>
/// Remvoes all non-pseudoclasses from the collection.
/// </summary>
public override void Clear()
{
for (var i = Count - 1; i >= 0; --i)
{
if (!this[i].StartsWith(":"))
{
RemoveAt(i);
}
}
}
/// <summary> /// <summary>
/// Inserts a style class into the collection. /// Inserts a style class into the collection.
/// </summary> /// </summary>

12
tests/Avalonia.Controls.UnitTests/ClassesTests.cs

@ -149,5 +149,17 @@ namespace Avalonia.Controls.UnitTests
Assert.Throws<ArgumentException>(() => target.Replace(new[] { ":qux" })); Assert.Throws<ArgumentException>(() => target.Replace(new[] { ":qux" }));
} }
[Fact]
public void Clear_Should_Not_Remove_Pseudoclasses()
{
var target = new Classes("foo", "bar");
((IPseudoClasses)target).Add(":baz");
target.Clear();
Assert.Equal(new[] { ":baz" }, target);
}
} }
} }

Loading…
Cancel
Save