Spec-Zone.ru › Dart 1

dart:js

Функция allowInteropCaptureThis

JSFunction allowInteropCaptureThis(Function f)

Возвращает Function, которая при вызове из JavaScript сохраняет привязку 'this' и вызывает f, передавая значение this в качестве первого аргумента. При вызове из Dart, null будет передано в качестве первого аргумента.

См. документацию для allowInterop. Этот метод следует использовать только с пакетом:js Dart-JavaScript interop.

Исходный код

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;
  }
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-js/allowInteropCaptureThis.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API