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

Side by Side Diff: pkg/mdv/lib/src/template.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, 5 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
« no previous file with comments | « pkg/mdv/lib/src/element.dart ('k') | pkg/mdv/test/binding_syntax_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of mdv; 5 part of mdv;
6 6
7 /** Extensions to [Element]s that behave as templates. */ 7 /** Extensions to [Element]s that behave as templates. */
8 class _TemplateExtension extends _ElementExtension { 8 class _TemplateExtension extends _ElementExtension {
9 var _model; 9 var _model;
10 _TemplateIterator _templateIterator; 10 _TemplateIterator _templateIterator;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 void unbindAll() { 43 void unbindAll() {
44 unbind('bind'); 44 unbind('bind');
45 unbind('repeat'); 45 unbind('repeat');
46 unbind('if'); 46 unbind('if');
47 super.unbindAll(); 47 super.unbindAll();
48 } 48 }
49 49
50 /** 50 /**
51 * Creates an instance of the template. 51 * Creates an instance of the template.
52 */ 52 */
53 DocumentFragment createInstance() { 53 DocumentFragment createInstance(model, String syntax) {
54 var template = node.ref; 54 var template = node.ref;
55 if (template == null) template = node; 55 if (template == null) template = node;
56 56
57 var instance = _Bindings._createDeepCloneAndDecorateTemplates( 57 var instance = _createDeepCloneAndDecorateTemplates(
58 template.content, node.attributes['syntax']); 58 template.content, syntax);
59 59
60 if (_instanceCreated != null) { 60 if (_instanceCreated != null) _instanceCreated.add(instance);
61 _instanceCreated.add(instance); 61
62 } 62 _addBindings(instance, model, TemplateElement.syntax[syntax]);
63 _addTemplateInstanceRecord(instance, model);
63 return instance; 64 return instance;
64 } 65 }
65 66
66 /** 67 /**
67 * The data model which is inherited through the tree. 68 * The data model which is inherited through the tree.
68 */ 69 */
69 get model => _model; 70 get model => _model;
70 71
71 void set model(value) { 72 void set model(value) {
72 var syntax = TemplateElement.syntax[node.attributes['syntax']]; 73 var syntax = TemplateElement.syntax[node.attributes['syntax']];
73 _model = value; 74 _model = value;
74 _Bindings._addBindings(node, model, syntax); 75 _addBindings(node, model, syntax);
75 } 76 }
76 } 77 }
OLDNEW
« no previous file with comments | « pkg/mdv/lib/src/element.dart ('k') | pkg/mdv/test/binding_syntax_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698