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

Side by Side Diff: pkg/template_binding/test/utils.dart

Issue 34453003: Rename mdv -> template_binding, remove experiemntal apis from dart:html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library observe_utils; 5 library template_binding.test.utils;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'package:observe/observe.dart'; 8 import 'package:observe/observe.dart';
9 import 'package:template_binding/template_binding.dart';
9 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
10 11
11 import 'package:observe/src/microtask.dart'; 12 import 'package:observe/src/microtask.dart';
12 export 'package:observe/src/microtask.dart'; 13 export 'package:observe/src/microtask.dart';
13 14
14 final bool parserHasNativeTemplate = () { 15 final bool parserHasNativeTemplate = () {
15 var div = new DivElement()..innerHtml = '<table><template>'; 16 var div = new DivElement()..innerHtml = '<table><template>';
16 return div.firstChild.firstChild != null && 17 return div.firstChild.firstChild != null &&
17 div.firstChild.firstChild.tagName == 'TEMPLATE'; 18 div.firstChild.firstChild.tagName == 'TEMPLATE';
18 }(); 19 }();
19 20
20 recursivelySetTemplateModel(element, model, [delegate]) { 21 recursivelySetTemplateModel(element, model, [delegate]) {
21 for (var node in element.queryAll('*')) { 22 for (var node in element.queryAll('*')) {
22 if (node.isTemplate) { 23 if (isSemanticTemplate(node)) {
23 node.bindingDelegate = delegate; 24 templateBind(node)
24 node.model = model; 25 ..bindingDelegate = delegate
26 ..model = model;
25 } 27 }
26 } 28 }
27 } 29 }
28 30
29 dispatchEvent(type, target) { 31 dispatchEvent(type, target) {
30 target.dispatchEvent(new Event(type, cancelable: false)); 32 target.dispatchEvent(new Event(type, cancelable: false));
31 } 33 }
32 34
33 class FooBarModel extends Observable { 35 class FooBarModel extends Observable {
34 @observable var foo; 36 @observable var foo;
(...skipping 16 matching lines...) Expand all
51 53
52 get bar => _bar; 54 get bar => _bar;
53 set bar(value) { 55 set bar(value) {
54 _bar = notifyPropertyChange(#bar, _bar, value); 56 _bar = notifyPropertyChange(#bar, _bar, value);
55 } 57 }
56 } 58 }
57 59
58 observeTest(name, testCase) => test(name, wrapMicrotask(testCase)); 60 observeTest(name, testCase) => test(name, wrapMicrotask(testCase));
59 61
60 solo_observeTest(name, testCase) => solo_test(name, wrapMicrotask(testCase)); 62 solo_observeTest(name, testCase) => solo_test(name, wrapMicrotask(testCase));
63
64 DivElement testDiv;
65
66 createTestHtml(s) {
67 var div = new DivElement();
68 div.setInnerHtml(s, treeSanitizer: new NullTreeSanitizer());
69 testDiv.append(div);
70
71 for (var node in div.queryAll('*')) {
72 if (isSemanticTemplate(node)) TemplateBindExtension.decorate(node);
73 }
74
75 return div;
76 }
77
78 createShadowTestHtml(s) {
79 var div = new DivElement();
80 var root = div.createShadowRoot();
81 root.setInnerHtml(s, treeSanitizer: new NullTreeSanitizer());
82 testDiv.append(div);
83
84 for (var node in root.querySelectorAll('*')) {
85 if (isSemanticTemplate(node)) TemplateBindExtension.decorate(node);
86 }
87
88 return root;
89 }
90
91 /**
92 * Sanitizer which does nothing.
93 */
94 class NullTreeSanitizer implements NodeTreeSanitizer {
95 void sanitizeTree(Node node) {}
96 }
OLDNEW
« no previous file with comments | « pkg/template_binding/test/template_element_test.dart ('k') | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698