Skip to content

Commit

Permalink
Update fireEventByName
Browse files Browse the repository at this point in the history
  • Loading branch information
sydneyjodon-wk committed Nov 16, 2023
1 parent a02b547 commit 951a135
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/src/dom/async/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import 'package:meta/meta.dart';
/// Returns either an `Error` or a `TestFailure` when provided with the [originalError].
typedef QueryTimeoutFn = /*Error || TestFailure*/ Object Function(/*Error*/ Object originalError);

// todo should all these be optional / nullable?
@JS()
@anonymous
class SharedJsWaitForOptions {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/dom/config/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ class JsConfig {
external bool get throwSuggestions;
external set throwSuggestions(bool value);

external /*JsError*/ dynamic Function(String message, Element container) get getElementError;
external set getElementError(/*JsError*/ dynamic Function(String message, Element container) value);
external /*JsError*/ dynamic Function(String? message, Element container) get getElementError;
external set getElementError(/*JsError*/ dynamic Function(String? message, Element container) value);
}
11 changes: 4 additions & 7 deletions lib/src/dom/fire_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,16 @@ external JsMap get _fireEventObj;
///
/// {@category UserActions}
bool fireEventByName(String eventName, Element element, [Map? eventProperties]) {
if (!JsBackedMap.fromJs(_jsEventMap).keys.contains(eventName)) {
if (!JsBackedMap.fromJs(_fireEventObj).keys.contains(eventName)) {
throw ArgumentError.value(eventName, 'eventName');
}

final jsFireEventByNameFn =
JsBackedMap.fromJs(_fireEventObj)[eventName] as bool Function(Element, [/*JsObject*/ dynamic])?;
JsBackedMap.fromJs(_fireEventObj)[eventName] as bool Function(Element, [/*JsObject*/ dynamic]);

if (eventProperties == null) {
return eventHandlerErrorCatcher(() => jsFireEventByNameFn!(element));
return eventHandlerErrorCatcher(() => jsFireEventByNameFn(element));
}

return eventHandlerErrorCatcher(() => jsFireEventByNameFn!(element, jsifyAndAllowInterop(eventProperties)));
return eventHandlerErrorCatcher(() => jsFireEventByNameFn(element, jsifyAndAllowInterop(eventProperties)));
}

@JS('rtl.eventMap')
external JsMap get _jsEventMap;

0 comments on commit 951a135

Please sign in to comment.