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

Unified Diff: pkg/mdv/test/template_element_test.dart

Issue 18162004: [package:mdv] port createInstance change (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged Created 7 years, 6 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
« no previous file with comments | « pkg/mdv/test/binding_syntax_test.dart ('k') | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/mdv/test/template_element_test.dart
diff --git a/pkg/mdv/test/template_element_test.dart b/pkg/mdv/test/template_element_test.dart
index 10b39e1618e7f0c5d9fdddae740324384e78b684..d645a425d3659d76723977311ca30ebaf2f70a68 100644
--- a/pkg/mdv/test/template_element_test.dart
+++ b/pkg/mdv/test/template_element_test.dart
@@ -1542,19 +1542,28 @@ templateElementTests() {
});
test('CreateInstance', () {
- var div = createTestHtml(
- '<template bind="{{a}}">'
- '<template bind="{{b}}">'
- '{{text}}'
- '</template>'
- '</template>');
- var outer = div.nodes.first;
+ TemplateElement.syntax['Test'] = new TestBindingSyntax();
+ try {
+ var div = createTestHtml(
+ '<template bind="{{a}}">'
+ '<template bind="{{b}}">'
+ '{{ foo }}:{{ replaceme }}'
+ '</template>'
+ '</template>');
+ var outer = div.nodes.first;
+ var model = toSymbolMap({'b': {'foo': 'bar'}});
- var instance = outer.createInstance();
- expect(outer.content.nodes.first, instance.nodes.first.ref);
+ var host = new DivElement();
+ var instance = outer.createInstance(model, 'Test');
+ expect(outer.content.nodes.first, instance.nodes.first.ref);
+ expect(instance.firstChild.attributes['syntax'], 'Test');
- var instance2 = outer.createInstance();
- expect(instance2.nodes.first.ref, instance.nodes.first.ref);
+ host.append(instance);
+ deliverChangeRecords();
+ expect(host.firstChild.nextNode.text, 'bar:replaced');
+ } finally {
+ TemplateElement.syntax.remove('Test');
+ }
});
test('Bootstrap', () {
@@ -1609,6 +1618,13 @@ templateElementTests() {
});
}
+class TestBindingSyntax extends CustomBindingSyntax {
+ getBinding(model, String path, name, node) {
+ if (path.trim() == 'replaceme') return new ObservableBox('replaced');
+ return null;
+ }
+}
+
class UnbindingInNestedBindSyntax extends CustomBindingSyntax {
int expectedAge = 42;
int count = 0;
@@ -1666,4 +1682,3 @@ _deepToSymbol(value) {
}
return value;
}
-
« no previous file with comments | « pkg/mdv/test/binding_syntax_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