JSFunction allowInteropCaptureThis(Function f)

Returns a Function that when called from JavaScript captures its 'this' binding and calls f with the value of this passed as the first argument. When called from Dart, null will be passed as the first argument.

See the documention for allowInterop. This method should only be used with package:js Dart-JavaScript interop.

Source

JSFunction allowInteropCaptureThis(Function f) {
  if (f is JSFunction) {
    // Behavior when the function is already a JS function is unspecified.
    throw new ArgumentError(
        "Function is already a JS function so cannot capture this.");
    return f;
  } else {
    var ret = _interopCaptureThisExpando[f];
    if (ret == null) {
      // TODO(jacobr): we could optimize this.
      ret = JSFunction._createWithThis(f);
      _interopCaptureThisExpando[f] = ret;
    }
    return ret;
  }
}