Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(709)

Side by Side Diff: pkg/js/lib/js.dart

Issue 1318043005: Support user generated custom native JS classes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: about to land Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/js/README.md ('k') | pkg/js/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * The js library allows Dart library authors to export their APIs to JavaScript
7 * and to define Dart interfaces for JavaScript objects.
8 */
9 library js;
10
11 export 'dart:js' show allowInterop, allowInteropCaptureThis;
12
13 /// A metadata annotation that indicates that a Library, Class, or member is
14 /// implemented directly in JavaScript. All external members of a class or
15 /// library with this annotation implicitly have it as well.
16 ///
17 /// Specifying [name] customizes the JavaScript name to use. By default the
18 /// dart name is used. It is not valid to specify a custom [name] for class
19 /// instance members.
20 ///
21 /// Example 1:
22 ///
23 /// @Js('google.maps')
24 /// library maps;
25 ///
26 /// external Map get map;
27 ///
28 /// @Js("LatLng")
29 /// class Location {
30 /// external Location(num lat, num lng);
31 /// }
32 ///
33 /// @Js()
34 /// class Map {
35 /// external Map(Location location);
36 /// external Location getLocation();
37 /// }
38 ///
39 /// In this example the top level map getter will invoke the JavaScript getter
40 /// google.maps.map
41 /// Calls to the Map constructor will be translated to calls to the JavaScript
42 /// new google.maps.Map(location)
43 /// Calls to the Location constructor willbe translated to calls to the
44 /// JavaScript
45 /// new google.maps.LatLng(lat, lng)
46 /// because a custom JavaScript name for the Location class.
47 /// In general, we recommend against using custom JavaScript names whenever
48 /// possible as it is easier for users if the JavaScript names and Dart names
49 /// are consistent.
50 ///
51 /// Example 2:
52 /// library utils;
53 ///
54 /// @Js("JSON.stringify")
55 /// external String stringify(obj);
56 ///
57 /// @Js()
58 /// void debugger();
59 ///
60 /// In this example no custom JavaScript namespace is specified.
61 /// Calls to debugger map to calls to JavaScript
62 /// self.debugger()
63 /// Calls to stringify map to calls to
64 /// JSON.stringify(obj)
65 class Js {
66 final String name;
67 const Js([this.name]);
68 }
OLDNEW
« no previous file with comments | « pkg/js/README.md ('k') | pkg/js/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698