computeUnit method

  1. @override
CSSUnit? computeUnit([
  1. DOMContext? domContext
])
override

Implementation

@override
CSSUnit? computeUnit([DOMContext? domContext]) {
  var valA = CSSValue.from(a);
  if (valA == null) return null;
  var compA = CSSFunction.computeValue(valA);
  if (compA == null) return null;

  if (operation != null) {
    var valB = CSSValue.from(b!);
    if (valB == null) return null;
    var compB = CSSFunction.computeValue(valB);
    if (compB == null) return null;

    if (compA is CSSLength && compB is CSSLength) {
      if (compA.unit == compB.unit) {
        return compA.unit;
      } else {
        return null;
      }
    } else {
      return null;
    }
  } else if (compA is CSSLength) {
    return compA.unit;
  }

  return null;
}