matchingTarget 属性

Element matchingTarget
继承自

指向触发事件的元素,该事件的CSS选择器被匹配。如果这个事件未与任何事件委托相关联,访问这个值将会抛出 UnsupportedError

实现

Element get matchingTarget {
  if (_selector == null) {
    throw new UnsupportedError('Cannot call matchingTarget if this Event did'
        ' not arise as a result of event delegation.');
  }
  Element? currentTarget = this.currentTarget as Element?;
  Element? target = this.target as Element?;
  do {
    if (target!.matches(_selector!)) return target;
    target = target.parent;
  } while (target != null && target != currentTarget!.parent);
  throw new StateError('No selector matched for populating matchedTarget.');
}