getAttribute method

String? getAttribute(
  1. Pointer<NativeType> selfPtr,
  2. String key
)

Implementation

String? getAttribute(Pointer selfPtr, String key) {
  Node? target = getBindingObject<Node>(selfPtr);
  if (target == null) return null;

  if (target is Element) {
    // Only element has attributes.
    return target.getAttribute(key);
  } else if (target is TextNode && (key == 'data' || key == 'nodeValue')) {
    // @TODO: property is not attribute.
    return target.data;
  } else {
    return null;
  }
}