OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <!-- |
| 3 Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 for details. All rights reserved. Use of this source code is governed by a |
| 5 BSD-style license that can be found in the LICENSE file. |
| 6 --> |
| 7 <html> |
| 8 <head> |
| 9 <title>bind simple</title> |
| 10 <script src="packages/polymer/boot.js"></script> |
| 11 <script src="packages/unittest/test_controller.js"></script> |
| 12 </head> |
| 13 <body> |
| 14 <x-foo></x-foo> |
| 15 |
| 16 <polymer-element name="x-bar" noscript> |
| 17 <template> |
| 18 x-bar |
| 19 </template> |
| 20 </polymer-element> |
| 21 |
| 22 <polymer-element name="x-foo"> |
| 23 <template> |
| 24 <div id="foo" foo="{{foo}}"></div> |
| 25 <div id="bool" foo?="{{foo}}"></div> |
| 26 <div id="content">{{foo}}</div> |
| 27 <x-bar id="bar" foo="{{foo}}" ></x-bar> |
| 28 <x-bar id="barBool" foo?="{{foo}}"></x-bar> |
| 29 <x-bar id="barContent">{{foo}}</x-bar> |
| 30 </template> |
| 31 <script type="application/dart"> |
| 32 import 'dart:async'; |
| 33 import 'package:polymer/polymer.dart'; |
| 34 import 'package:unittest/matcher.dart'; |
| 35 |
| 36 @CustomTag('x-foo') |
| 37 class XFoo extends PolymerElement { |
| 38 @observable var foo = 'foo!'; |
| 39 final _ready = new Completer(); |
| 40 Future onTestDone; |
| 41 |
| 42 created() { |
| 43 super.created(); |
| 44 onTestDone = _ready.future.then(_runTest); |
| 45 } |
| 46 |
| 47 _runTest(_) { |
| 48 expect(foo, $['foo'].attributes['foo']); |
| 49 expect($['bool'].attributes['foo'], ''); |
| 50 expect($['bool'].attributes, isNot(contains('foo?'))); |
| 51 expect($['content'].innerHtml, foo); |
| 52 // |
| 53 expect(foo, $['bar'].attributes['foo']); |
| 54 expect($['barBool'].attributes['foo'], ''); |
| 55 expect($['barBool'].attributes, isNot(contains('foo?'))); |
| 56 expect($['barContent'].innerHtml, foo); |
| 57 } |
| 58 |
| 59 ready() => _ready.complete(); |
| 60 } |
| 61 </script> |
| 62 </polymer-element> |
| 63 |
| 64 <script type="application/dart" src="bind_test.dart"></script> |
| 65 </body> |
| 66 </html> |
OLD | NEW |