Skip to content

Commit 46635ab

Browse files
committed
Fix nullable reference exception in CssOriginValue
1 parent 0652a66 commit 46635ab

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/AngleSharp.Css/Values/Composites/CssOriginValue.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace AngleSharp.Css.Values
22
{
33
using AngleSharp.Css.Dom;
44
using System;
5+
using System.Collections.Generic;
56

67
/// <summary>
78
/// Represents a CSS origin definition.
@@ -73,14 +74,17 @@ public String CssText
7374
/// <returns>True if both are equal, otherwise false.</returns>
7475
public Boolean Equals(CssOriginValue other)
7576
{
76-
return _x.Equals(other._x) && _y.Equals(other._y) && _z.Equals(other._z);
77+
return other is not null
78+
&& EqualityComparer<ICssValue>.Default.Equals(_x, other._x)
79+
&& EqualityComparer<ICssValue>.Default.Equals(_y, other._y)
80+
&& EqualityComparer<ICssValue>.Default.Equals(_z, other._z);
7781
}
7882

7983
ICssValue ICssValue.Compute(ICssComputeContext context)
8084
{
81-
var x = _x.Compute(context);
82-
var y = _y.Compute(context);
83-
var z = _z.Compute(context);
85+
var x = _x?.Compute(context);
86+
var y = _y?.Compute(context);
87+
var z = _z?.Compute(context);
8488

8589
if (x != _x || y != _y || z != _z)
8690
{

0 commit comments

Comments
 (0)