Skip to content

CPLAT-12665 Remove Synthetic Event Wrappers #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4bf7a6a
Merge cherry-pick
greglittlefield-wf Sep 11, 2020
3f7c662
Remove anonymous annotations from event wrappers
sydneyjodon-wk Oct 27, 2020
8d35e58
Merge in cherry-pick
sydneyjodon-wk Nov 2, 2020
e0bbf95
Merge branch '6.0.0-wip' of github.com:cleandart/react-dart into CPLA…
joebingham-wk Nov 9, 2020
887077a
Add new event creators
joebingham-wk Nov 9, 2020
90bf4b7
Add some type checking utils
joebingham-wk Nov 9, 2020
25fdee7
Finish adding doc comments
joebingham-wk Nov 10, 2020
132ef6a
Remove default constructors
joebingham-wk Nov 10, 2020
502c6ca
More strongly type dataTransfer
joebingham-wk Nov 10, 2020
65a7ad5
Adjust test
joebingham-wk Nov 10, 2020
e4ee896
Format
joebingham-wk Nov 10, 2020
d5af6de
Clean up
joebingham-wk Nov 10, 2020
3b672a7
Use 'hasProperty'
joebingham-wk Nov 11, 2020
a3aaa07
Add doc comments
joebingham-wk Nov 16, 2020
7699f8f
Add deprecations
joebingham-wk Nov 16, 2020
59b702c
Add back SyntheticDataTransfer
joebingham-wk Nov 16, 2020
a1436c7
Add a comment for SyntheticFormEvent
joebingham-wk Nov 16, 2020
54af213
Add tests for data transfer helper
joebingham-wk Nov 16, 2020
fff5582
Change helper method name
joebingham-wk Nov 16, 2020
8063199
Remove unnecessary import
joebingham-wk Nov 16, 2020
c149188
Address misc feedback
joebingham-wk Nov 18, 2020
067e282
Remove isFormEvent
joebingham-wk Nov 18, 2020
2bc5ffa
Update doc comments
joebingham-wk Nov 18, 2020
215d9ec
Tweak a couple more comments
joebingham-wk Nov 18, 2020
dc72ba9
Make isPersistent an extension
joebingham-wk Nov 18, 2020
85ddcfc
Rename helper extension
joebingham-wk Nov 18, 2020
9aa536f
Undo renaming
joebingham-wk Nov 18, 2020
7d1bc70
Clean up cast
joebingham-wk Nov 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
562 changes: 3 additions & 559 deletions lib/react.dart

Large diffs are not rendered by default.

16 changes: 0 additions & 16 deletions lib/react_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,6 @@ export 'package:react/react_client/component_factory.dart'
JsBackedMapComponentFactoryMixin;
export 'package:react/react_client/zone.dart' show componentZone;
export 'package:react/src/react_client/chain_refs.dart' show chainRefs, chainRefList;
export 'package:react/src/react_client/event_factory.dart'
show
syntheticEventFactory,
syntheticClipboardEventFactory,
syntheticCompositionEventFactory,
syntheticKeyboardEventFactory,
syntheticFocusEventFactory,
syntheticFormEventFactory,
syntheticDataTransferFactory,
syntheticPointerEventFactory,
syntheticMouseEventFactory,
syntheticTouchEventFactory,
syntheticTransitionEventFactory,
syntheticAnimationEventFactory,
syntheticUIEventFactory,
syntheticWheelEventFactory;
export 'package:react/src/typedefs.dart' show JsFunctionComponent;

/// Method used to initialize the React environment.
Expand Down
25 changes: 5 additions & 20 deletions lib/react_client/component_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import 'package:react/src/context.dart';
import 'package:react/src/ddc_emulated_function_name_bug.dart' as ddc_emulated_function_name_bug;
import 'package:react/src/js_interop_util.dart';
import 'package:react/src/typedefs.dart';
import 'package:react/src/react_client/event_prop_key_to_event_factory.dart';
import 'package:react/src/react_client/factory_util.dart';

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

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

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

eventPropKeyToEventFactory.keys.forEach((key) {
if (props.containsKey(key)) {
props[key] = unconvertJsEventHandler(props[key]) ?? props[key];
}
});

// Convert the nested style map so it can be read by Dart code.
var style = props['style'];
if (style != null) {
Expand All @@ -82,8 +72,7 @@ mixin JsBackedMapComponentFactoryMixin on ReactComponentFactoryProxy {
return React.createElement(type, convertedProps, children);
}

static JsMap generateExtendedJsProps(Map props) =>
generateJsProps(props, shouldConvertEventHandlers: false, wrapWithJsify: false);
static JsMap generateExtendedJsProps(Map props) => generateJsProps(props, wrapWithJsify: false);
}

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

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

/// Creates ReactJS [ReactElement] instances for `JSContext` components.
Expand Down Expand Up @@ -287,10 +275,8 @@ class ReactJsComponentFactoryProxy extends ReactComponentFactoryProxy {
@override
ReactElement build(Map props, [List childrenArgs]) {
dynamic children = generateChildren(childrenArgs, shouldAlwaysBeList: alwaysReturnChildrenAsList);
JsMap convertedProps = generateJsProps(props,
shouldConvertEventHandlers: shouldConvertDomProps,
convertCallbackRefValue: false,
additionalRefPropKeys: _additionalRefPropKeys);
JsMap convertedProps =
generateJsProps(props, convertCallbackRefValue: false, additionalRefPropKeys: _additionalRefPropKeys);
return React.createElement(type, convertedProps, children);
}
}
Expand Down Expand Up @@ -321,7 +307,6 @@ class ReactDomComponentFactoryProxy extends ReactComponentFactoryProxy {

/// Performs special handling of certain props for consumption by ReactJS DOM components.
static void convertProps(Map props) {
convertEventHandlers(props);
convertRefValue(props);
}
}
Expand Down
Loading