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

Unified Diff: tests/html/simple_dom.dart

Issue 1583773003: Support JS$ prefix for dart and fix bug where _operator_getter and the [] operator were used incons… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: tests/html/simple_dom.dart
diff --git a/tests/html/simple_dom.dart b/tests/html/simple_dom.dart
new file mode 100644
index 0000000000000000000000000000000000000000..20764deeb9b70059ae843f85c9c2e2b55ac20e47
--- /dev/null
+++ b/tests/html/simple_dom.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+@JS("")
+library json_helper;
+
+import 'package:js/js.dart';
+
+// This is a minimal and intentionally hacky raw DOM API built with typed JS
+// interop.
+@JS()
+class EventTarget {
+ external void addEventListener(String type, Function listener, [bool useCapture]);
+ external void removeEventListener(String type, Function listener, [bool useCapture]);
+ external void dispatchEvent(Event event);
+
+ // The dart:html and simple_dom versions of addEventListener are generally
+ // compatible except for behavior capturing this and throwing when passed
+ // event listeners that have not had allowInterop called.
+ external void JS$addEventListener(String type, Function listener, [bool useCapture]);
+ external void JS$removeEventListener(String type, Function listener, [bool useCapture]);
+}
+
+// Example showing addEventListener as a top level memthod
+@JS("document.addEventListener")
+external void documentAddEventListener(String type, Function listener, [bool useCapture]);
+
+@JS()
+@anonymous
+class EventInit {
+ external factory EventInit({bool bubbles, bool cancelable});
+ external bool get bubbles;
+ external bool get cancelable;
+}
+
+@JS()
+class Event {
+ external Event(String type, [EventInit eventInit]);
+ /// This is also defined in dart:html but that is fine as the
+ /// is consistent.
+ external String get type;
+
+ external String get exampleEventExpando;
+ external set exampleEventExpando(String v);
+}
+
+@JS()
+class Window extends EventTarget {
+ external Node get document;
+}
+
+@JS()
+class Node extends EventTarget {
+ external String get textContent;
+
+ external get exampleNodeExpando;
+ external set exampleNodeExpando(v);
+}
+
+@JS()
+class Document extends Node {
+ external Node getElementById(String id);
+}
+
+@JS()
+external Window get window;
+
+@JS()
+external Document get document;

Powered by Google App Engine
This is Rietveld 408576698