getAllCssRuleBySelector function

List<CssRule> getAllCssRuleBySelector(
  1. Pattern targetSelector,
  2. CssStyleSheet? sheet
)

Returns a List<CssRule> for targetSelector.

Implementation

List<CssRule> getAllCssRuleBySelector(
    Pattern targetSelector, CssStyleSheet? sheet) {
  if (sheet == null) return [];

  if (targetSelector is String) {
    var s = targetSelector.trim().toLowerCase();
    if (s.isEmpty) return [];
    return _getAllCssRuleBySelectorString(s, sheet);
  } else if (targetSelector is RegExp) {
    return _getAllCssRuleBySelectorRegExp(targetSelector, sheet);
  } else {
    throw StateError('Invalid targetSelector: $targetSelector');
  }
}