diff --git a/src/Avalonia.Styling/Styling/Selector.cs b/src/Avalonia.Styling/Styling/Selector.cs
index af209ea970..b8a67e6d96 100644
--- a/src/Avalonia.Styling/Styling/Selector.cs
+++ b/src/Avalonia.Styling/Styling/Selector.cs
@@ -41,7 +41,9 @@ namespace Avalonia.Styling
/// A .
public SelectorMatch Match(IStyleable control, bool subscribe = true)
{
- var inputs = new List>();
+ List> inputs = null;
+ IObservable singleInput = null;
+
var selector = this;
var alwaysThisType = true;
var hitCombinator = false;
@@ -66,16 +68,37 @@ namespace Avalonia.Styling
}
else if (match.Result == SelectorMatchResult.Sometimes)
{
- inputs.Add(match.Activator);
+ if (inputs != null)
+ {
+ inputs.Add(match.Activator);
+ }
+ else
+ {
+ if (singleInput == null)
+ {
+ singleInput = match.Activator;
+ }
+ else
+ {
+ inputs = new List>();
+
+ inputs.Add(singleInput);
+ inputs.Add(match.Activator);
+ }
+ }
}
selector = selector.MovePrevious();
}
- if (inputs.Count > 0)
+ if (inputs != null)
{
return new SelectorMatch(StyleActivator.And(inputs));
}
+ else if (singleInput != null)
+ {
+ return new SelectorMatch(singleInput);
+ }
else
{
return alwaysThisType && !hitCombinator ?