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

Side by Side Diff: lib/scoped_css.dart

Issue 22962005: Merge pull request #581 from kevmoo/polymer (Closed) Base URL: https://github.com/dart-lang/web-ui.git@polymer
Patch Set: Created 7 years, 4 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
« no previous file with comments | « lib/safe_html.dart ('k') | lib/shadowdom.debug.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * This library contains support for scoped CSS that uses the compilation
7 * strategy of WebUI. This will likely become deprecated as we migrate over to
8 * use runtime mechanisms to enforce scoped css rules.
9 */
10 library scoped_css;
11
12 /**
13 * Maps CSS selectors (class and) to a mangled name and maps x-component name
14 * to [is='x-component'].
15 */
16 class ScopedCssMapper {
17 final Map<String, String> _mapping;
18
19 ScopedCssMapper(this._mapping);
20
21 /** Returns mangled name of selector sans . or # character. */
22 String operator [](String selector) => _mapping[selector];
23
24 /** Returns mangled name of selector w/ . or # character. */
25 String getSelector(String selector) {
26 var prefixedName = this[selector];
27 var selectorType = selector[0];
28 if (selectorType == '.' || selectorType == '#') {
29 return '$selectorType${prefixedName}';
30 }
31
32 return prefixedName;
33 }
34 }
35
36 /** Any CSS selector (class, id or element) defined name to mangled name. */
37 Map<String, ScopedCssMapper> _mappers = {};
38
39 ScopedCssMapper getScopedCss(String componentName) => _mappers[componentName];
40
41 void setScopedCss(String componentName, Map<String, String> mapping) {
42 _mappers.putIfAbsent(componentName, () => new ScopedCssMapper(mapping));
43 }
OLDNEW
« no previous file with comments | « lib/safe_html.dart ('k') | lib/shadowdom.debug.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698