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