Skip to content

Fix busted tests due to a bug in PeriodicValueConverter from Flexbox changes #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/ExCSS/ValueConverters/PeriodicValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal sealed class PeriodicValueConverter : IValueConverter

public PeriodicValueConverter(IValueConverter converter, string[] labels)
{
Debug.Assert(labels.Length == 4 || labels.Length == 2);
Debug.Assert(labels.Length == 0 || labels.Length == 4 || labels.Length == 2);

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

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

Expand Down Expand Up @@ -53,11 +53,11 @@ private sealed class PeriodicValue : IPropertyValue

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

_values = new IPropertyValue[labels.Length];
_values = new IPropertyValue[labels.Length == 0 ? 4 : labels.Length];

if (labels.Length == 4)
if (_values.Length == 0 || _values.Length == 4)
{
//Top, right, bottom, left
_values[0] = options[0];
Expand All @@ -79,7 +79,7 @@ private string[] Values
{
get
{
if (_values.Length == 4)
if (_values.Length == 0 || _values.Length == 4)
{
var top = _values[0].CssText;
var right = _values[1].CssText;
Expand Down