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

Side by Side Diff: test/data/input/mix_iterate_if_test.html

Issue 12225039: Support for observable models, fixes #259 (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: Created 7 years, 10 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 3 Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4 for details. All rights reserved. Use of this source code is governed by a 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. 5 BSD-style license that can be found in the LICENSE file.
6 --> 6 -->
7 <html lang="en"> 7 <html lang="en">
8 <head> 8 <head>
9 <meta charset="utf-8"> 9 <meta charset="utf-8">
10 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 10 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
11 <script type="application/javascript" src="testing.js"></script> 11 <script type="application/javascript" src="testing.js"></script>
12 </head> 12 </head>
13 <body> 13 <body>
14 <!-- Tests the correct interaction of iteration and conditionals. --> 14 <!-- Tests the correct interaction of iteration and conditionals. -->
15 <table> 15 <table>
16 <tbody id='test' template iterate="row in table"> 16 <tbody id='test' template iterate="row in table">
17 <tr template iterate="cell in row"> 17 <tr template iterate="cell in row">
18 <td template if="cell != 0">{{cell}}</td> 18 <td template if="cell != 0">{{cell}}</td>
19 </tr> 19 </tr>
20 </tbody></table> 20 </tbody></table>
21 <script type="application/dart"> 21 <script type="application/dart">
22 import 'dart:html'; 22 import 'dart:html';
23 import 'package:unittest/unittest.dart'; 23 import 'package:unittest/unittest.dart';
24 import 'package:web_ui/watcher.dart'; 24 import 'package:web_ui/observe.dart';
25 25
26 List<List> table = [[1, 2, 3], [4, 0, 5], [0, 2, 4]]; 26 _obs(list) => new ObservableList.from(list);
27
28 @observable
29 List<List> table = _obs([_obs([1, 2, 3]), _obs([4, 0, 5]), _obs([0, 2, 4])]);
27 main() { 30 main() {
28 window.setTimeout(() { 31 window.setTimeout(() {
29 table[1][1] = 9; 32 table[1][1] = 9;
30 dispatch(); 33 deliverChangesSync();
31 window.setTimeout(() { 34 window.setTimeout(() {
32 var test = document.query('#test'); 35 var test = document.query('#test');
33 expect(test.children.length, table.length); 36 expect(test.children.length, table.length);
34 for (int row = 0; row < table.length; row++) { 37 for (int row = 0; row < table.length; row++) {
35 var tr = test.children[row]; 38 var tr = test.children[row];
36 expect(tr.tagName, 'TR'); 39 expect(tr.tagName, 'TR');
37 int column = -1; 40 int column = -1;
38 for (var td in tr.children) { 41 for (var td in tr.children) {
39 expect(td.tagName, 'TD'); 42 expect(td.tagName, 'TD');
40 if (td.style.display == 'none') { 43 if (td.style.display == 'none') {
41 column++; 44 column++;
42 continue; 45 continue;
43 } 46 }
44 47
45 var value = table[row][column]; 48 var value = table[row][column];
46 expect(value, greaterThan(0)); 49 expect(value, greaterThan(0));
47 expect(td.innerHtml, value.toString()); 50 expect(td.innerHtml, value.toString());
48 } 51 }
49 } 52 }
50 window.setTimeout(() => window.postMessage('done', '*'), 0); 53 window.setImmediate(() => window.postMessage('done', '*'));
51 }, 0); 54 }, 0);
52 }, 0); 55 }, 0);
53 } 56 }
54 </script> 57 </script>
55 </body> 58 </body>
56 </html> 59 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698