handleEventDefault method
Called by EventTarget when default behavior of an event should occur.
In other words:
- Capturing and bubbling phases of event handling are already done when this method is invoked.
- This method is not invoked if Event.preventDefault was called by an event handler.
The default implementation handles the following events:
- InputElement clicks
Implementation
@protected
void handleEventDefault(EventTarget eventTarget, Event event) {
switch (event.type) {
case 'click':
if (eventTarget is InputElement) {
final type = eventTarget.type;
if (type == null) {
return;
}
switch (type.toLowerCase()) {
case 'file':
handleFileUploadInputElementClick(eventTarget, event);
break;
case 'reset':
eventTarget.form?.reset();
break;
case 'radio':
final name = eventTarget.name;
final form = eventTarget.form!;
final length = form.length!;
for (var i = 0; i < length; i++) {
final item = form.item(i);
if (item is InputElement && item.name == name) {
item.checked = false;
}
}
eventTarget.checked = true;
break;
case 'checkbox':
eventTarget.checked = !eventTarget.checked!;
break;
default:
eventTarget.focus();
break;
}
}
break;
}
}