OLD | NEW |
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 src="packages/web_ui/testing/testing.js"></script> | 11 <script src="packages/web_ui/testing/testing.js"></script> |
12 </head> | 12 </head> |
13 <body> | 13 <body> |
14 <!-- Tests it is valid to switch text bindings by SafeHtml bindings and | 14 <!-- Tests it is valid to use existing nodes as SafeHtml. --> |
15 viceversa. --> | |
16 <div>text to text (expect <span>text1</span>): {{w}}</div> | 15 <div>text to text (expect <span>text1</span>): {{w}}</div> |
17 <div>text to html (expect html1 in a real span): {{x}}</div> | 16 <div>text to html (expect html1 in a real span): {{x}}</div> |
18 <div>html to text (expect <span>text2</span>): {{y}}</div> | 17 <div>html to text (expect <span>text2</span>): {{y}}</div> |
19 <div>html to html (expect html2 in a real span): {{z}}</div> | 18 <div>html to html (expect html2 in a real span): {{z}}</div> |
20 <script type="application/dart"> | 19 <script type="application/dart"> |
21 import 'dart:async'; | 20 import 'dart:async'; |
22 import 'dart:html'; | 21 import 'dart:html'; |
23 import 'package:unittest/unittest.dart'; | 22 import 'package:unittest/unittest.dart'; |
24 import 'package:web_ui/observe.dart'; | 23 import 'package:web_ui/observe.dart'; |
25 import 'package:web_ui/safe_html.dart'; | 24 import 'package:web_ui/safe_html.dart'; |
26 | 25 |
27 @observable var w = '<span>text0</span>'; | 26 @observable var w = '<span>text0</span>'; |
28 @observable var x = '<span>text0</span>'; | 27 @observable var x = '<span>text0</span>'; |
29 @observable var y = new SafeHtml.unsafe('<span>html0</span>'); | 28 @observable var y = new Element.html('<span>html0</span>'); |
30 @observable var z = new SafeHtml.unsafe('<span>html0</span>'); | 29 @observable var z = new Element.html('<span>html0</span>'); |
31 main() { | 30 main() { |
32 Timer.run(() { | 31 Timer.run(() { |
33 w = '<span>text1</span>'; | 32 w = '<span>text1</span>'; |
34 x = new SafeHtml.unsafe('<div>html1</div>'); | 33 x = new Element.html('<div>html1</div>'); |
35 y = '<span>text2</span>'; | 34 y = '<span>text2</span>'; |
36 z = new SafeHtml.unsafe('<div>html2</div>'); | 35 z = new Element.html('<div>html2</div>'); |
37 window.postMessage('done', '*'); | 36 window.postMessage('done', '*'); |
38 }); | 37 }); |
39 } | 38 } |
40 </script> | 39 </script> |
41 </body> | 40 </body> |
42 </html> | 41 </html> |
OLD | NEW |