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

Side by Side Diff: third_party/pkg/angular/lib/core_dom/compiler.dart

Issue 148453003: Updating Angular version (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 part of angular.core.dom; 1 part of angular.core.dom;
2 2
3 @NgInjectableService() 3 @NgInjectableService()
4 class Compiler { 4 class Compiler {
5 final DirectiveMap directives; 5 final DirectiveMap directives;
6 final Profiler _perf; 6 final Profiler _perf;
7 final Parser _parser; 7 final Parser _parser;
8 final Expando _expando; 8 final Expando _expando;
9 9
10 DirectiveSelector selector; 10 DirectiveSelector selector;
11 11
12 Compiler(this.directives, this._perf, this._parser, this._expando) { 12 Compiler(this.directives, this._perf, this._parser, this._expando) {
13 selector = directiveSelectorFactory(directives); 13 selector = directiveSelectorFactory(directives);
14 } 14 }
15 15
16 _compileBlock(NodeCursor domCursor, NodeCursor templateCursor, 16 _compileBlock(NodeCursor domCursor, NodeCursor templateCursor,
17 List<DirectiveRef> useExistingDirectiveRefs) { 17 List<DirectiveRef> useExistingDirectiveRefs) {
18 if (domCursor.nodeList().length == 0) return null; 18 if (domCursor.nodeList().length == 0) return null;
19 19
20 var directivePositions = null; // don't pre-create to create sparse tree and prevent GC pressure. 20 var directivePositions = null; // don't pre-create to create sparse tree and prevent GC pressure.
21 var cursorAlreadyAdvanced; 21 var cursorAlreadyAdvanced;
22 22
23 do { 23 do {
24 var declaredDirectiveRefs = useExistingDirectiveRefs == null 24 var declaredDirectiveRefs = useExistingDirectiveRefs == null
25 ? selector(domCursor.nodeList()[0]) 25 ? selector(domCursor.nodeList()[0])
26 : useExistingDirectiveRefs; 26 : useExistingDirectiveRefs;
27 var children = NgAnnotation.COMPILE_CHILDREN; 27 var children = NgAnnotation.COMPILE_CHILDREN;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 NgAnnotation annotation = ref.annotation; 134 NgAnnotation annotation = ref.annotation;
135 if (annotation.map != null) annotation.map.forEach((attrName, mapping) { 135 if (annotation.map != null) annotation.map.forEach((attrName, mapping) {
136 Match match = _MAPPING.firstMatch(mapping); 136 Match match = _MAPPING.firstMatch(mapping);
137 if (match == null) { 137 if (match == null) {
138 throw "Unknown mapping '$mapping' for attribute '$attrName'."; 138 throw "Unknown mapping '$mapping' for attribute '$attrName'.";
139 } 139 }
140 var mode = match[1]; 140 var mode = match[1];
141 var dstPath = match[2]; 141 var dstPath = match[2];
142 142
143 Expression dstPathFn = _parser(dstPath.isEmpty ? attrName : dstPath); 143 Expression dstPathFn = _parser(dstPath.isEmpty ? attrName : dstPath);
144 if (!dstPathFn.assignable) { 144 if (!dstPathFn.isAssignable) {
145 throw "Expression '$dstPath' is not assignable in mapping '$mapping' for attribute '$attrName'."; 145 throw "Expression '$dstPath' is not assignable in mapping '$mapping' for attribute '$attrName'.";
146 } 146 }
147 ApplyMapping mappingFn; 147 ApplyMapping mappingFn;
148 switch (mode) { 148 switch (mode) {
149 case '@': 149 case '@':
150 mappingFn = (NodeAttrs attrs, Scope scope, Object dst) { 150 mappingFn = (NodeAttrs attrs, Scope scope, Object dst) {
151 attrs.observe(attrName, (value) => dstPathFn.assign(dst, value)); 151 attrs.observe(attrName, (value) => dstPathFn.assign(dst, value));
152 }; 152 };
153 break; 153 break;
154 case '<=>': 154 case '<=>':
155 mappingFn = (NodeAttrs attrs, Scope scope, Object dst) { 155 mappingFn = (NodeAttrs attrs, Scope scope, Object dst) {
156 if (attrs[attrName] == null) return; 156 if (attrs[attrName] == null) return;
157 Expression attrExprFn = _parser(attrs[attrName]); 157 Expression attrExprFn = _parser(attrs[attrName]);
158 var shadowValue = null; 158 var shadowValue = null;
159 scope.$watch( 159 scope.$watch(
160 () => attrExprFn.eval(scope), 160 () => attrExprFn.eval(scope),
161 (v) => dstPathFn.assign(dst, shadowValue = v), 161 (v) => dstPathFn.assign(dst, shadowValue = v),
162 attrs[attrName]); 162 attrs[attrName]);
163 if (attrExprFn.assignable) { 163 if (attrExprFn.isAssignable) {
164 scope.$watch( 164 scope.$watch(
165 () => dstPathFn.eval(dst), 165 () => dstPathFn.eval(dst),
166 (v) { 166 (v) {
167 if (shadowValue != v) { 167 if (shadowValue != v) {
168 shadowValue = v; 168 shadowValue = v;
169 attrExprFn.assign(scope, v); 169 attrExprFn.assign(scope, v);
170 } 170 }
171 }, 171 },
172 dstPath); 172 dstPath);
173 } 173 }
(...skipping 29 matching lines...) Expand all
203 mappingFn = (NodeAttrs attrs, Scope scope, Object dst) { 203 mappingFn = (NodeAttrs attrs, Scope scope, Object dst) {
204 dstPathFn.assign(dst, _parser(attrs[attrName]).bind(scope, ScopeLoca ls.wrapper)); 204 dstPathFn.assign(dst, _parser(attrs[attrName]).bind(scope, ScopeLoca ls.wrapper));
205 }; 205 };
206 break; 206 break;
207 } 207 }
208 ref.mappings.add(mappingFn); 208 ref.mappings.add(mappingFn);
209 }); 209 });
210 } 210 }
211 } 211 }
212 212
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/core_dom/common.dart ('k') | third_party/pkg/angular/lib/core_dom/cookies.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698