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

Unified Diff: tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate

Issue 448413002: Do regular expression for camelCase CSS processing in JS. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate
diff --git a/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate b/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate
index ce96ec89471f1d2c5963e2543a03dc1d0a03baa1..a32d903be8c722ce9131dbc2b12d0a5134a24ffa 100644
--- a/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate
+++ b/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate
@@ -76,10 +76,18 @@ $endif
}
static String _camelCase(String hyphenated) {
+$if DART2JS
+ var replacedMs = JS('String', r'#.replace(/^-ms-/, "ms-")', hyphenated);
+
+ var fToUpper = const JS_CONST(
+ r'function(_, letter) { return letter.toUpperCase(); }');
+ return JS('String', r'#.replace(/-([\da-z])/ig, #)', replacedMs, fToUpper);
+$else
// The "ms" prefix is always lowercased.
return hyphenated.replaceFirst(new RegExp('^-ms-'), 'ms-').replaceAllMapped(
new RegExp('-([a-z]+)', caseSensitive: false),
(match) => match[0][1].toUpperCase() + match[0].substring(2));
+$endif
}
$if DART2JS

Powered by Google App Engine
This is Rietveld 408576698