ariaAttributeName static method

String ariaAttributeName(
  1. String key
)

The aria-* attribute name of key: hidden, aria-hidden, ariaHidden and aria_hidden are aria-hidden. Throws an ArgumentError for an empty key.

Implementation

static String ariaAttributeName(String key) {
  var name = key.trim().toLowerCase();
  if (name.startsWith('aria')) {
    var start = 4;
    if (name.length > start) {
      var c = name.codeUnitAt(start);
      if (c == 0x2D || c == 0x5F) start++; // `-` or `_`
    }
    name = name.substring(start);
  }
  if (name.isEmpty) {
    throw ArgumentError.value(key, 'key', 'Empty `aria-*` attribute name');
  }
  return 'aria-$name';
}