Workiva / react-dart

Dart Bindings for React JS
BSD 2-Clause "Simplified" License
413 stars 67 forks source link

CPLAT-13185 Fix JsBackedMap for Dart 2.12 #305

Closed sydneyjodon-wk closed 3 years ago

sydneyjodon-wk commented 3 years ago

Motivation

Dart 2.12 includes changes to setProperty that disallow passing in Dart functions, since they are not callable by JS code. https://github.com/dart-lang/sdk/commit/d683f33f5bfefe92ea1a590a800c7e41b213f69c

This breaks passing function props to Dart components, since JsBackedMap stores those values using setProperty under the hood.

  Assertion failed: org-dartlang-sdk:///lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart:166:7
  _isJsObject(f) ||
            !JS<bool>('bool', '# instanceof #.Function', f, global_)
  "Dart function requires `allowInterop` to be passed to JavaScript."
  dart:sdk_internal                                        setProperty
  package:react/react_client/js_backed_map.dart 66:5       _set
  dart:sdk_internal                                        addAll
  package:react/react_client/js_backed_map.dart 96:13      addAll
  package:react/react_client/js_backed_map.dart 34:61      <fn>
  package:react/react_client/js_backed_map.dart 34:73      from
  package:react/src/react_client/factory_util.dart 167:34  generateJsProps
  package:react/react_client/component_factory.dart 86:7   generateExtendedJsProps

This is the reason that react-dart dev builds are currently failing.

We can work around this issue by wrapping Dart functions in an object, which can be passed through without issue.

Changes

QA Steps

aviary3-wk commented 3 years ago

Security Insights

The items listed below may not capture all security relevant changes. Before providing a security review, be sure to review the entire PR for security impact.

(1) Security relevant changes were detected
  • Watched file lib/src/react_client/private_utils.dart modified
  • Action Items

    semveraudit-wf commented 3 years ago

    Public API Changes

    No changes to the public API found for commit 32b58a7a363d7e9b944b8f5984c0243c04a7cdeb

    Showing results for 32b58a7a363d7e9b944b8f5984c0243c04a7cdeb

    Powered by semver-audit-service. Please report any problems by filing an issue. Reported by the dart semver audit client 2.2.0 Browse public API.

    Last edited UTC Feb 17 at 19:59:18

    evanweible-wf commented 3 years ago

    +1 security