Index: extensions/renderer/resources/binding.js |
diff --git a/extensions/renderer/resources/binding.js b/extensions/renderer/resources/binding.js |
index d40b18f6a26a17741df7e41df1112f4466c39800..31abbb4386b719fce09afd8afc1c494b96c5762b 100644 |
--- a/extensions/renderer/resources/binding.js |
+++ b/extensions/renderer/resources/binding.js |
@@ -138,7 +138,7 @@ function getPlatform() { |
]; |
for (var i = 0; i < platforms.length; i++) { |
- if ($RegExp.test(platforms[i][0], navigator.appVersion)) { |
+ if ($RegExp.exec(platforms[i][0], navigator.appVersion)) { |
return platforms[i][1]; |
} |
} |
@@ -302,15 +302,22 @@ Binding.prototype = { |
enumValue.name : enumValue; |
if (enumValue) { // Avoid setting any empty enums. |
// Make all properties in ALL_CAPS_STYLE. |
- // Replace myEnum-Foo with my_Enum-Foo: |
- var propertyName = |
- $String.replace(enumValue, /([a-z])([A-Z])/g, '$1_$2'); |
- // Replace my_Enum-Foo with my_Enum_Foo: |
- propertyName = $String.replace(propertyName, /\W/g, '_'); |
// If the first character is a digit (we know it must be one of |
Devlin
2016/04/05 19:15:50
We should add a new comment here explaining why th
Dan Ehrenberg
2016/04/05 20:20:57
Done
|
// a digit, a letter, or an underscore), precede it with an |
// underscore. |
- propertyName = $String.replace(propertyName, /^(\d)/g, '_$1'); |
+ var propertyName = ($RegExp.exec(/\d/, enumValue[0])) ? '_' : ''; |
+ for (var i = 0; i < enumValue.length; i++) { |
Devlin
2016/04/05 19:15:50
++i
Dan Ehrenberg
2016/04/05 20:20:57
Done
|
+ if (i > 0 && $RegExp.exec(/[a-z]/, enumValue[i-1]) && |
Devlin
2016/04/05 19:15:50
I think this block would be a little easier to rea
Dan Ehrenberg
2016/04/05 20:20:57
Done
|
+ $RegExp.exec(/[A-Z]/, enumValue[i])) { |
+ // Replace myEnum-Foo with my_Enum-Foo: |
+ propertyName = propertyName + '_' + enumValue[i]; |
+ } else if ($RegExp.exec(/\W/, enumValue[i])) { |
+ // Replace my_Enum-Foo with my_Enum_Foo: |
+ propertyName = propertyName + '_'; |
+ } else { |
+ propertyName = propertyName + enumValue[i]; |
+ } |
+ } |
// Uppercase (replace my_Enum_Foo with MY_ENUM_FOO): |
propertyName = $String.toUpperCase(propertyName); |
mod[id][propertyName] = enumValue; |