OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <!-- |
| 3 Copyright (c) 2014, 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 <script src="packages/web_components/webcomponents.min.js"></script> |
| 10 <link rel="x-dart-test" href="behavior_test.dart"> |
| 11 <!--<script type="application/dart" src="behavior_test.dart"></script>--> |
| 12 <script src="packages/test/dart.js"></script> |
| 13 </head> |
| 14 <body> |
| 15 <dom-module id="my-element"> |
| 16 <template> |
| 17 <div id="jsBehaviorString">{{jsBehaviorString}}</div> |
| 18 <div id="dartBehaviorString">{{dartBehaviorString}}</div> |
| 19 </template> |
| 20 </dom-module> |
| 21 <script> |
| 22 window.JsBehavior = { |
| 23 // Lifecycle methods |
| 24 created: function() { |
| 25 // Internal bookkeeping for tests. |
| 26 this.jsInvocations = { |
| 27 'created': [], |
| 28 'attached': [], |
| 29 'detached': [], |
| 30 'attributeChanged': [], |
| 31 'jsBehaviorStringChanged': [], |
| 32 'jsBehaviorNumChanged': [], |
| 33 'onJsBehaviorEvent': [] |
| 34 }; |
| 35 |
| 36 this.jsInvocations['created'].push([this]); |
| 37 }, |
| 38 attached: function() { |
| 39 this.jsInvocations['attached'].push([this]); |
| 40 }, |
| 41 detached: function() { |
| 42 this.jsInvocations['detached'].push([this]); |
| 43 }, |
| 44 attributeChanged: function(name, type, value) { |
| 45 this.jsInvocations['attributeChanged'].push([this, name, type, value]); |
| 46 }, |
| 47 |
| 48 // Properties |
| 49 properties: { |
| 50 jsBehaviorString: { |
| 51 type: String, |
| 52 observer: 'jsBehaviorStringChanged' |
| 53 }, |
| 54 jsBehaviorNum: Number |
| 55 }, |
| 56 jsBehaviorStringChanged: function(newValue, oldValue) { |
| 57 this.jsInvocations['jsBehaviorStringChanged'].push([newValue, oldValue]); |
| 58 }, |
| 59 |
| 60 // Observers |
| 61 observers: [ |
| 62 'jsBehaviorNumChanged(jsBehaviorNum)' |
| 63 ], |
| 64 jsBehaviorNumChanged: function(jsBehaviorNum) { |
| 65 this.jsInvocations['jsBehaviorNumChanged'].push([jsBehaviorNum]); |
| 66 }, |
| 67 |
| 68 // Listeners |
| 69 listeners: { |
| 70 'js-behavior-event': 'onJsBehaviorEvent' |
| 71 }, |
| 72 onJsBehaviorEvent: function(e, detail) { |
| 73 this.jsInvocations['onJsBehaviorEvent'].push([e, detail]); |
| 74 } |
| 75 } |
| 76 </script> |
| 77 </body> |
| 78 </html> |
OLD | NEW |