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

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

Issue 184033007: Prototype of Dart proxies for JS objects. Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More tests. Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/element_created/lib/element_created.js » ('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 library element_created;
2
3 import 'dart:js' as js;
4 import 'dart:async';
5 import 'dart:html' as dom;
6
7 Stream<dom.Element> watch(String tagName, {String extendsTag}) {
8 var controller = new StreamController<dom.Element>(sync:true);
9 var params = {
10 'createdCallback': new js.JsFunction.withThis((self) {
11 controller.add(self);
12 }),
13 };
14 if (extendsTag != null) {
15 params['extends'] = extendsTag;
16 }
17 new js.JsObject.fromBrowserObject(dom.document)
18 .callMethod('registerElementCreatedWatcher', [
19 tagName, new js.JsObject.jsify(params)]);
20
21 return controller.stream;
22 }
23
24 bool get supported {
25 if (js.context == null) return true;
26
27 return new js.JsObject.fromBrowserObject(dom.document)
28 .hasProperty('registerElementCreatedWatcher');
29 }
30
31 Future ready = () {
32 if (supported) {
33 return new Future.value(true);
34 }
35 var script = new dom.ScriptElement()
36 ..src = '/packages/element_created/element_created.js';
37
38 var future = script.onLoad.first;
39 dom.document.head.append(script);
40 return future;
41 }();
OLDNEW
« no previous file with comments | « no previous file | pkg/element_created/lib/element_created.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698