fix readme for pkg/js and prepare another release

Update SDK changelog to mention improved JS interop

R=jacobr@google.com

Review URL: https://codereview.chromium.org/1438003002 .
This commit is contained in:
Kevin Moore 2015-11-11 12:19:43 -08:00
parent 291befa1cd
commit e7e012e386
3 changed files with 23 additions and 14 deletions

View file

@ -32,7 +32,7 @@
* `dart:developer`
* Added `Timeline` class for interacting with Observatory's timeline feature.
* Added `ServiceExtensionHandler`, `ServiceExtensionResponse`, and `registerExtension` which enable developers to provide their own VM service protocol extensions.
* `dart:io`
* **Breaking:** Secure networking has changed, replacing the NSS library
with the BoringSSL library. `SecureSocket`, `SecureServerSocket`,
@ -63,7 +63,10 @@
### Tool changes
* `docgen` and 'dartdocgen' no longer ship in the sdk. The `docgen` sources have
* `dart2js` and Dartium now support improved Javascript Interoperability via the
[js package](https://pub.dartlang.org/packages/js).
* `docgen` and `dartdocgen` no longer ship in the SDK. The `docgen` sources have
been removed from the repository.
* This is the last release to ship the VM's "legacy debug protocol".

View file

@ -26,21 +26,21 @@ There is a [full example](https://github.com/dart-lang/sdk/tree/master/pkg/js/ex
```dart
// Calls invoke JavaScript `JSON.stringify(obj)`.
@Js("JSON.stringify")
@JS("JSON.stringify")
external String stringify(obj);
```
#### Classes and Namespaces
```dart
@Js('google.maps')
@JS('google.maps')
library maps;
// Invokes the JavaScript getter `google.maps.map`.
external Map get map;
// `new Map` invokes JavaScript `new google.maps.Map(location)`
@Js()
@JS()
class Map {
external Map(Location location);
external Location getLocation();
@ -51,32 +51,38 @@ class Map {
// We recommend against using custom JavaScript names whenever
// possible. It is easier for users if the JavaScript names and Dart names
// are consistent.
@Js("LatLng")
@JS("LatLng")
class Location {
external Location(num lat, num lng);
}
```
#### Maps
Dart `Map` objects, including literals, are "opaque" in JavaScript.
You must create Dart classes for each of these.
#### JavaScript object literals
Many JavaScript APIs take an object literal as an argument. For example:
```js
// JavaScript
printOptions({responsive: true});
```
If you want to use `printOptions` from Dart, you cannot simply pass a Dart `Map`
object  they are are "opaque" in JavaScript.
Instead, create a Dart class with both the `@JS()` and
`@anonymous` annotations.
```dart
// Dart
void main() {
printOptions(new Options(responsive: true));
}
@Js()
@JS()
external printOptions(Options options);
@Js()
@JS()
@anonymous
class Options {
external bool get responsive;
@ -86,7 +92,7 @@ class Options {
## Contributing and Filing Bugs
Please file bugs and features requests on the [Github issue tracker](https://github.com/dart-lang/js-interop/issues).
Please file bugs and features requests on the [Github issue tracker](https://github.com/dart-lang/sdk/issues).
We also love and accept community contributions, from API suggestions to pull requests.
Please file an issue before beginning work so we can discuss the design and implementation.

View file

@ -1,5 +1,5 @@
name: js
version: 0.6.0-beta.8
version: 0.6.0-beta.9
authors:
- Dart Team <misc@dartlang.org>
description: Access JavaScript from Dart.