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 1b47c7dc69dddd0a34c678ead2b1ef50ebd90735..c1b2ab28e6351bc550dd20b056d4d6dbd6c89e8f 100644 |
--- a/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate |
+++ b/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate |
@@ -67,14 +67,34 @@ $endif |
@DomName('CSSStyleDeclaration.setProperty') |
void setProperty(String propertyName, String value, [String priority]) { |
+ return _setPropertyHelper(_browserPropertyName(propertyName), |
+ value, priority); |
+ } |
+ |
+ String _browserPropertyName(String propertyName) { |
+ String name = _readCache(propertyName); |
+ if (name is String) return name; |
if (_supportsProperty(_camelCase(propertyName))) { |
- return _setPropertyHelper(propertyName, value, priority); |
+ name = propertyName; |
} else { |
- return _setPropertyHelper(Device.cssPrefix + propertyName, value, |
- priority); |
+ name = Device.cssPrefix + propertyName; |
} |
+ _writeCache(propertyName, name); |
+ return name; |
} |
+$if DART2JS |
+ static final _propertyCache = JS('', '{}'); |
+ static String _readCache(String key) => |
+ JS('String|Null', '#[#]', _propertyCache, key); |
+ static void _writeCache(String key, String value) { |
+ JS('void', '#[#] = #', _propertyCache, key, value); |
+ } |
+$else |
+ static String _readCache(String key) => null; |
+ static void _writeCache(String key, value) {} |
+$endif |
+ |
static String _camelCase(String hyphenated) { |
$if DART2JS |
var replacedMs = JS('String', r'#.replace(/^-ms-/, "ms-")', hyphenated); |
@@ -92,18 +112,9 @@ $endif |
$if DART2JS |
void _setPropertyHelper(String propertyName, String value, [String priority]) { |
- // try/catch for IE9 which throws on unsupported values. |
- try { |
- if (value == null) value = ''; |
- if (priority == null) { |
- priority = ''; |
- } |
- JS('void', '#.setProperty(#, #, #)', this, propertyName, value, priority); |
- // Bug #2772, IE9 requires a poke to actually apply the value. |
- if (JS('bool', '!!#.setAttribute', this)) { |
- JS('void', '#.setAttribute(#, #)', this, propertyName, value); |
- } |
- } catch (e) {} |
+ if (value == null) value = ''; |
+ if (priority == null) priority = ''; |
+ JS('void', '#.setProperty(#, #, #)', this, propertyName, value, priority); |
} |
/** |