parse<V extends CSSValue> static method

CSSEntry<V>? parse<V extends CSSValue>(
  1. String entry, [
  2. String? comment
])

Implementation

static CSSEntry<V>? parse<V extends CSSValue>(String entry,
    [String? comment]) {
  var idx = entry.indexOf(pairDelimiter);
  if (idx < 0) return null;

  var name = normalizeName(entry.substring(0, idx));
  if (name == null) return null;

  var value = entry.substring(idx + 1).trim();

  var cssValue = CSSValue.from(value, name) as V?;

  if (comment != null && comment.contains('DOMContext-original-value:')) {
    var idx = comment.indexOf('DOMContext-original-value:');
    var originalValueStr = comment.substring(idx + 26).trim();
    if (originalValueStr.endsWith('*/')) {
      originalValueStr =
          originalValueStr.substring(0, originalValueStr.length - 2).trim();
    }

    if (originalValueStr.isNotEmpty) {
      var originalValue = CSSValue.from(originalValueStr, name) as V;
      cssValue = originalValue;
      comment = null;
    }
  }

  return CSSEntry<V>._(name, cssValue, comment: comment);
}