Skip to content

Commit 052c5b6

Browse files
Merge pull request #284 from cleandart/CPLAT-12470-remove-synthetic-event-wrappers
CPLAT-12665 Remove Synthetic Event Wrappers
2 parents bc328de + 7d1bc70 commit 052c5b6

14 files changed

+1726
-1436
lines changed

lib/react.dart

Lines changed: 3 additions & 559 deletions
Large diffs are not rendered by default.

lib/react_client.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,6 @@ export 'package:react/react_client/component_factory.dart'
2121
JsBackedMapComponentFactoryMixin;
2222
export 'package:react/react_client/zone.dart' show componentZone;
2323
export 'package:react/src/react_client/chain_refs.dart' show chainRefs, chainRefList;
24-
export 'package:react/src/react_client/event_factory.dart'
25-
show
26-
syntheticEventFactory,
27-
syntheticClipboardEventFactory,
28-
syntheticCompositionEventFactory,
29-
syntheticKeyboardEventFactory,
30-
syntheticFocusEventFactory,
31-
syntheticFormEventFactory,
32-
syntheticDataTransferFactory,
33-
syntheticPointerEventFactory,
34-
syntheticMouseEventFactory,
35-
syntheticTouchEventFactory,
36-
syntheticTransitionEventFactory,
37-
syntheticAnimationEventFactory,
38-
syntheticUIEventFactory,
39-
syntheticWheelEventFactory;
4024
export 'package:react/src/typedefs.dart' show JsFunctionComponent;
4125

4226
/// Method used to initialize the React environment.

lib/react_client/component_factory.dart

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import 'package:react/src/context.dart';
1414
import 'package:react/src/ddc_emulated_function_name_bug.dart' as ddc_emulated_function_name_bug;
1515
import 'package:react/src/js_interop_util.dart';
1616
import 'package:react/src/typedefs.dart';
17-
import 'package:react/src/react_client/event_prop_key_to_event_factory.dart';
1817
import 'package:react/src/react_client/factory_util.dart';
1918

19+
// ignore: deprecated_member_use_from_same_package
2020
export 'package:react/src/react_client/factory_util.dart' show unconvertJsEventHandler;
2121

2222
/// Prepares [children] to be passed to the ReactJS [React.createElement] and
@@ -42,10 +42,6 @@ dynamic listifyChildren(dynamic children) {
4242
///
4343
/// If `style` is specified in props, then it too is shallow-converted and included
4444
/// in the returned Map.
45-
///
46-
/// Any JS event handlers included in the props for the given [instance] will be
47-
/// unconverted such that the original JS handlers are returned instead of their
48-
/// Dart synthetic counterparts.
4945
Map unconvertJsProps(/* ReactElement|ReactComponent */ instance) {
5046
var props = Map.from(JsBackedMap.backedBy(instance.props));
5147

@@ -58,12 +54,6 @@ Map unconvertJsProps(/* ReactElement|ReactComponent */ instance) {
5854
throw new ArgumentError('A Dart Component cannot be passed into unconvertJsProps.');
5955
}
6056

61-
eventPropKeyToEventFactory.keys.forEach((key) {
62-
if (props.containsKey(key)) {
63-
props[key] = unconvertJsEventHandler(props[key]) ?? props[key];
64-
}
65-
});
66-
6757
// Convert the nested style map so it can be read by Dart code.
6858
var style = props['style'];
6959
if (style != null) {
@@ -82,8 +72,7 @@ mixin JsBackedMapComponentFactoryMixin on ReactComponentFactoryProxy {
8272
return React.createElement(type, convertedProps, children);
8373
}
8474

85-
static JsMap generateExtendedJsProps(Map props) =>
86-
generateJsProps(props, shouldConvertEventHandlers: false, wrapWithJsify: false);
75+
static JsMap generateExtendedJsProps(Map props) => generateJsProps(props, wrapWithJsify: false);
8776
}
8877

8978
/// Use [ReactDartComponentFactoryProxy2] instead by calling [registerComponent2].
@@ -199,8 +188,7 @@ class ReactDartComponentFactoryProxy2<TComponent extends Component2> extends Rea
199188

200189
/// Returns a JavaScript version of the specified [props], preprocessed for consumption by ReactJS and prepared for
201190
/// consumption by the `react` library internals.
202-
static JsMap generateExtendedJsProps(Map props) =>
203-
generateJsProps(props, shouldConvertEventHandlers: false, wrapWithJsify: false);
191+
static JsMap generateExtendedJsProps(Map props) => generateJsProps(props, wrapWithJsify: false);
204192
}
205193

206194
/// Creates ReactJS [ReactElement] instances for `JSContext` components.
@@ -287,10 +275,8 @@ class ReactJsComponentFactoryProxy extends ReactComponentFactoryProxy {
287275
@override
288276
ReactElement build(Map props, [List childrenArgs]) {
289277
dynamic children = generateChildren(childrenArgs, shouldAlwaysBeList: alwaysReturnChildrenAsList);
290-
JsMap convertedProps = generateJsProps(props,
291-
shouldConvertEventHandlers: shouldConvertDomProps,
292-
convertCallbackRefValue: false,
293-
additionalRefPropKeys: _additionalRefPropKeys);
278+
JsMap convertedProps =
279+
generateJsProps(props, convertCallbackRefValue: false, additionalRefPropKeys: _additionalRefPropKeys);
294280
return React.createElement(type, convertedProps, children);
295281
}
296282
}
@@ -321,7 +307,6 @@ class ReactDomComponentFactoryProxy extends ReactComponentFactoryProxy {
321307

322308
/// Performs special handling of certain props for consumption by ReactJS DOM components.
323309
static void convertProps(Map props) {
324-
convertEventHandlers(props);
325310
convertRefValue(props);
326311
}
327312
}

0 commit comments

Comments
 (0)