attrHandler function
Implementation
Object? attrHandler(
Parser parser,
Element source, {
required String selectr,
required String attr,
}) {
if (parser.multiple) {
List<Element> selector = source.querySelectorAll(selectr);
if (selector.isNotEmpty) {
List<String> result = [];
for (final sel in selector) {
String? attribute = sel.attributes[attr];
if (attribute != null) {
result.add(attribute.toString());
}
}
return result;
}
} else {
Element? selector = source.querySelector(selectr);
if (selector != null) {
String? attribute = selector.attributes[attr];
if (attribute != null) {
return attribute.toString();
}
}
}
return null;
}