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

Side by Side Diff: third_party/pkg/angular/lib/tools/html_extractor.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 library angular.html_parser; 1 library angular.html_parser;
2 2
3 import 'package:html5lib/parser.dart'; 3 import 'package:html5lib/parser.dart';
4 import 'package:html5lib/dom.dart'; 4 import 'package:html5lib/dom.dart';
5 5
6 import 'package:angular/tools/selector.dart'; 6 import 'package:angular/tools/selector.dart';
7 import 'package:angular/tools/io.dart'; 7 import 'package:angular/tools/io.dart';
8 import 'package:angular/tools/common.dart'; 8 import 'package:angular/tools/common.dart';
9 9
10 typedef NodeVisitor(Node node); 10 typedef NodeVisitor(Node node);
11 11
12 RegExp _MUSTACHE_REGEXP = new RegExp(r'{{([^}]*)}}'); 12 RegExp _MUSTACHE_REGEXP = new RegExp(r'{{([^}]*)}}');
13 RegExp _NG_REPEAT_SYNTAX = new RegExp(r'^\s*(.+)\s+in\s+(.*?)\s*(\s+track\s+by\s +(.+)\s*)?$'); 13 RegExp _NG_REPEAT_SYNTAX = new RegExp(r'^\s*(.+)\s+in\s+(.*?)\s*(\s+track\s+by\s +(.+)\s*)?$');
14 14
15 class HtmlExpressionExtractor { 15 class HtmlExpressionExtractor {
16 List<DirectiveInfo> directiveInfos; 16 Iterable<DirectiveInfo> directiveInfos;
17 17
18 HtmlExpressionExtractor(this.directiveInfos) { 18 HtmlExpressionExtractor(this.directiveInfos) {
19 for (DirectiveInfo directiveInfo in directiveInfos) { 19 for (DirectiveInfo directiveInfo in directiveInfos) {
20 expressions.addAll(directiveInfo.expressions); 20 expressions.addAll(directiveInfo.expressions);
21 if (directiveInfo.template != null) { 21 if (directiveInfo.template != null) {
22 parseHtml(directiveInfo.template); 22 parseHtml(directiveInfo.template);
23 } 23 }
24 } 24 }
25 } 25 }
26 26
(...skipping 10 matching lines...) Expand all
37 var document = parse(html); 37 var document = parse(html);
38 visitNodes([document], (Node node) { 38 visitNodes([document], (Node node) {
39 if (matchesNode(node, r'[*=/{{.*}}/]')) { 39 if (matchesNode(node, r'[*=/{{.*}}/]')) {
40 node.attributes.forEach((attrName, attrValue) { 40 node.attributes.forEach((attrName, attrValue) {
41 _MUSTACHE_REGEXP.allMatches(attrValue).forEach((match) { 41 _MUSTACHE_REGEXP.allMatches(attrValue).forEach((match) {
42 expressions.add(match.group(1)); 42 expressions.add(match.group(1));
43 }); 43 });
44 }); 44 });
45 } 45 }
46 if (matchesNode(node, r':contains(/{{.*}}/)')) { 46 if (matchesNode(node, r':contains(/{{.*}}/)')) {
47 _MUSTACHE_REGEXP.allMatches(node.value).forEach((match) { 47 _MUSTACHE_REGEXP.allMatches(node.text).forEach((match) {
48 expressions.add(match.group(1)); 48 expressions.add(match.group(1));
49 }); 49 });
50 } 50 }
51 if (matchesNode(node, r'[ng-repeat]')) { 51 if (matchesNode(node, r'[ng-repeat]')) {
52 var expr = _NG_REPEAT_SYNTAX. 52 var expr = _NG_REPEAT_SYNTAX.
53 firstMatch(node.attributes['ng-repeat']).group(2); 53 firstMatch(node.attributes['ng-repeat']).group(2);
54 expressions.add(expr); 54 expressions.add(expr);
55 } 55 }
56 56
57 for (DirectiveInfo directiveInfo in directiveInfos) { 57 for (DirectiveInfo directiveInfo in directiveInfos) {
58 if (matchesNode(node, directiveInfo.selector)) { 58 if (directiveInfo.selector != null &&
59 matchesNode(node, directiveInfo.selector)) {
59 directiveInfo.expressionAttrs.forEach((attr) { 60 directiveInfo.expressionAttrs.forEach((attr) {
60 if (node.attributes[attr] != null && attr != 'ng-repeat') { 61 if (node.attributes[attr] != null && attr != 'ng-repeat') {
61 expressions.add(node.attributes[attr]); 62 expressions.add(node.attributes[attr]);
62 } 63 }
63 }); 64 });
64 } 65 }
65 } 66 }
66 }); 67 });
67 } 68 }
68 69
69 visitNodes(List<Node> nodes, NodeVisitor visitor) { 70 visitNodes(List<Node> nodes, NodeVisitor visitor) {
70 for (Node node in nodes) { 71 for (Node node in nodes) {
71 visitor(node); 72 visitor(node);
72 if (node.nodes.length > 0) { 73 if (node.nodes.isNotEmpty) {
73 visitNodes(node.nodes, visitor); 74 visitNodes(node.nodes, visitor);
74 } 75 }
75 } 76 }
76 } 77 }
77 } 78 }
78 79
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/tools/expression_extractor.dart ('k') | third_party/pkg/angular/lib/tools/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698