Skip to content

Commit c6cdc57

Browse files
authored
Merge pull request #153 from lee-m/busted-tests
Fix busted tests due to a bug in PeriodicValueConverter from Flexbox changes
2 parents b11b12e + 5fd3dcb commit c6cdc57

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/ExCSS/ValueConverters/PeriodicValueConverter.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal sealed class PeriodicValueConverter : IValueConverter
1111

1212
public PeriodicValueConverter(IValueConverter converter, string[] labels)
1313
{
14-
Debug.Assert(labels.Length == 4 || labels.Length == 2);
14+
Debug.Assert(labels.Length == 0 || labels.Length == 4 || labels.Length == 2);
1515

1616
_converter = converter;
1717
_labels = labels;
@@ -20,7 +20,7 @@ public PeriodicValueConverter(IValueConverter converter, string[] labels)
2020
public IPropertyValue Convert(IEnumerable<Token> value)
2121
{
2222
var list = new List<Token>(value);
23-
var options = new IPropertyValue[_labels.Length];
23+
var options = new IPropertyValue[_labels.Length == 0 ? 4 : _labels.Length];
2424

2525
if (list.Count == 0) return null;
2626

@@ -53,11 +53,11 @@ private sealed class PeriodicValue : IPropertyValue
5353

5454
public PeriodicValue(IPropertyValue[] options, IEnumerable<Token> tokens, string[] labels)
5555
{
56-
Debug.Assert(labels.Length == 2 || labels.Length == 4);
56+
Debug.Assert(labels.Length == 0 || labels.Length == 2 || labels.Length == 4);
5757

58-
_values = new IPropertyValue[labels.Length];
58+
_values = new IPropertyValue[labels.Length == 0 ? 4 : labels.Length];
5959

60-
if (labels.Length == 4)
60+
if (_values.Length == 0 || _values.Length == 4)
6161
{
6262
//Top, right, bottom, left
6363
_values[0] = options[0];
@@ -79,7 +79,7 @@ private string[] Values
7979
{
8080
get
8181
{
82-
if (_values.Length == 4)
82+
if (_values.Length == 0 || _values.Length == 4)
8383
{
8484
var top = _values[0].CssText;
8585
var right = _values[1].CssText;

0 commit comments

Comments
 (0)