getLinkElementByHREF function

LinkElement? getLinkElementByHREF(
  1. String href, [
  2. String? rel
])

Selects an LinkElement in DOM with href.

Implementation

LinkElement? getLinkElementByHREF(String href, [String? rel]) {
  if (href.isEmpty) return null;

  if (isNotEmptyString(rel)) {
    var resolvedURL = resolveUri(href).toString();
    return getElementByValues('link', getElementHREF, [href, resolvedURL],
        (e) => e.getAttribute('rel'), [rel]) as LinkElement?;
  } else {
    return getElementByHREF('link', href) as LinkElement?;
  }
}