readClasses 方法

Set<String> readClasses()

从 Element 类属性中读取类名,并将它们放入一个集合(重复项将被丢弃)。此方法旨在由特定实现覆盖。

实现

Set<String> readClasses() {
  var classname = _element.attributes['class'];
  if (classname is AnimatedString) {
    classname = (classname as AnimatedString).baseVal;
  }

  Set<String> s = new LinkedHashSet<String>();
  if (classname == null) {
    return s;
  }
  for (String name in classname.split(' ')) {
    String trimmed = name.trim();
    if (!trimmed.isEmpty) {
      s.add(trimmed);
    }
  }
  return s;
}