buildMatchedStyle static method

CSSStyle? buildMatchedStyle(
  1. Element element
)

Implementation

static CSSStyle? buildMatchedStyle(Element element) {
  List<CSSProperty> cssProperties = [];
  String cssText = '';
  for (MapEntry<String, CSSPropertyValue> entry in element.style) {
    String kebabName = kebabize(entry.key);
    String propertyValue = entry.value.toString();
    String _cssText = '$kebabName: $propertyValue';
    CSSProperty cssProperty = CSSProperty(
      name: kebabName,
      value: entry.value.value,
      range: SourceRange(
        startLine: 0,
        startColumn: cssText.length,
        endLine: 0,
        endColumn: cssText.length + _cssText.length + 1,
      ),
    );
    cssText += '$_cssText; ';
    cssProperties.add(cssProperty);
  }

  return CSSStyle(
      // Absent for user agent stylesheet and user-specified stylesheet rules.
      // Use hash code id to identity which element the rule belongs to.
      styleSheetId: element.ownerView.forDevtoolsNodeId(element),
      cssProperties: cssProperties,
      shorthandEntries: <ShorthandEntry>[],
      cssText: cssText,
      range: SourceRange(startLine: 0, startColumn: 0, endLine: 0, endColumn: cssText.length));
}