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

Unified Diff: test/src/common/behavior_test.html

Issue 1290643006: First cut at behaviors. This just implements the lifecycle methodsportion. We may get the rest for … (Closed) Base URL: git@github.com:dart-lang/polymer-dart.git@master
Patch Set: Created 5 years, 4 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: test/src/common/behavior_test.html
diff --git a/test/src/common/behavior_test.html b/test/src/common/behavior_test.html
new file mode 100644
index 0000000000000000000000000000000000000000..827db2e993897959e425ff68f2806a6ff718bb70
--- /dev/null
+++ b/test/src/common/behavior_test.html
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<!--
+Copyright (c) 2014, 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.
+-->
+<html>
+<head>
+ <script src="packages/web_components/webcomponents.min.js"></script>
+ <link rel="x-dart-test" href="behavior_test.dart">
+ <!--<script type="application/dart" src="behavior_test.dart"></script>-->
+ <script src="packages/test/dart.js"></script>
+</head>
+<body>
+<dom-module id="my-element">
+ <template>
+ <div id="jsBehaviorString">{{jsBehaviorString}}</div>
+ <div id="dartBehaviorString">{{dartBehaviorString}}</div>
+ </template>
+</dom-module>
+<script>
+ window.JsBehavior = {
+ // Lifecycle methods
+ created: function() {
+ // Internal bookkeeping for tests.
+ this.jsInvocations = {
+ 'created': [],
+ 'attached': [],
+ 'detached': [],
+ 'attributeChanged': [],
+ 'jsBehaviorStringChanged': [],
+ 'jsBehaviorNumChanged': [],
+ 'onJsBehaviorEvent': []
+ };
+
+ this.jsInvocations['created'].push([this]);
+ },
+ attached: function() {
+ this.jsInvocations['attached'].push([this]);
+ },
+ detached: function() {
+ this.jsInvocations['detached'].push([this]);
+ },
+ attributeChanged: function(name, type, value) {
+ this.jsInvocations['attributeChanged'].push([this, name, type, value]);
+ },
+
+ // Properties
+ properties: {
+ jsBehaviorString: {
+ type: String,
+ observer: 'jsBehaviorStringChanged'
+ },
+ jsBehaviorNum: Number
+ },
+ jsBehaviorStringChanged: function(newValue, oldValue) {
+ this.jsInvocations['jsBehaviorStringChanged'].push([newValue, oldValue]);
+ },
+
+ // Observers
+ observers: [
+ 'jsBehaviorNumChanged(jsBehaviorNum)'
+ ],
+ jsBehaviorNumChanged: function(jsBehaviorNum) {
+ this.jsInvocations['jsBehaviorNumChanged'].push([jsBehaviorNum]);
+ },
+
+ // Listeners
+ listeners: {
+ 'js-behavior-event': 'onJsBehaviorEvent'
+ },
+ onJsBehaviorEvent: function(e, detail) {
+ this.jsInvocations['onJsBehaviorEvent'].push([e, detail]);
+ }
+ }
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698