OLD | NEW |
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 html_css_fixup; | 5 library html_css_fixup; |
6 | 6 |
7 import 'dart:json' as json; | 7 import 'dart:convert'; |
8 | 8 |
9 import 'package:csslib/parser.dart' as css; | 9 import 'package:csslib/parser.dart' as css; |
10 import 'package:csslib/visitor.dart'; | 10 import 'package:csslib/visitor.dart'; |
11 import 'package:html5lib/dom.dart'; | 11 import 'package:html5lib/dom.dart'; |
12 import 'package:html5lib/dom_parsing.dart'; | 12 import 'package:html5lib/dom_parsing.dart'; |
13 | 13 |
14 import 'compiler.dart'; | 14 import 'compiler.dart'; |
15 import 'emitters.dart'; | 15 import 'emitters.dart'; |
16 import 'info.dart'; | 16 import 'info.dart'; |
17 import 'messages.dart'; | 17 import 'messages.dart'; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 */ | 97 */ |
98 String createCssSelectorsExpression(ComponentInfo info, bool mangled) { | 98 String createCssSelectorsExpression(ComponentInfo info, bool mangled) { |
99 var cssVisited = new IdClassVisitor(); | 99 var cssVisited = new IdClassVisitor(); |
100 | 100 |
101 // For components only 1 stylesheet allowed. | 101 // For components only 1 stylesheet allowed. |
102 if (!info.styleSheets.isEmpty && info.styleSheets.length == 1) { | 102 if (!info.styleSheets.isEmpty && info.styleSheets.length == 1) { |
103 var styleSheet = info.styleSheets[0]; | 103 var styleSheet = info.styleSheets[0]; |
104 cssVisited..visitTree(styleSheet); | 104 cssVisited..visitTree(styleSheet); |
105 } | 105 } |
106 | 106 |
107 return json.stringify(_createCssSimpleSelectors(cssVisited, info, mangled)); | 107 return JSON.encode(_createCssSimpleSelectors(cssVisited, info, mangled)); |
108 } | 108 } |
109 | 109 |
110 // TODO(terry): Need to handle other selectors than IDs/classes like tag name | 110 // TODO(terry): Need to handle other selectors than IDs/classes like tag name |
111 // e.g., DIV { color: red; } | 111 // e.g., DIV { color: red; } |
112 // TODO(terry): Would be nice if we didn't need to mangle names; requires users | 112 // TODO(terry): Would be nice if we didn't need to mangle names; requires users |
113 // to be careful in their code and makes it more than a "polyfill". | 113 // to be careful in their code and makes it more than a "polyfill". |
114 // Maybe mechanism that generates CSS class name for scoping. This | 114 // Maybe mechanism that generates CSS class name for scoping. This |
115 // would solve tag name selectors (see above TODO). | 115 // would solve tag name selectors (see above TODO). |
116 /** | 116 /** |
117 * Fix a component's HTML to implement scoped stylesheets. | 117 * Fix a component's HTML to implement scoped stylesheets. |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 | 566 |
567 // Find all imports return list of @imports in this style tag. | 567 // Find all imports return list of @imports in this style tag. |
568 var urlInfos = findImportsInStyleSheet(styleSheet, _packageRoot, | 568 var urlInfos = findImportsInStyleSheet(styleSheet, _packageRoot, |
569 _inputUrl, _messages); | 569 _inputUrl, _messages); |
570 imports.addAll(urlInfos); | 570 imports.addAll(urlInfos); |
571 } | 571 } |
572 } | 572 } |
573 super.visitElement(node); | 573 super.visitElement(node); |
574 } | 574 } |
575 } | 575 } |
OLD | NEW |