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

Unified Diff: extensions/renderer/resources/binding.js

Issue 1107223002: [Extensions] Precede api enums with an '_' if the first character is a digit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/resources/binding.js
diff --git a/extensions/renderer/resources/binding.js b/extensions/renderer/resources/binding.js
index 2c6b76a269d0cd3aba6a579b30645ee60f21ad65..cf671cbcab4edb6ce3de4b414e562f76a32c67ba 100644
--- a/extensions/renderer/resources/binding.js
+++ b/extensions/renderer/resources/binding.js
@@ -307,6 +307,10 @@ Binding.prototype = {
$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
+ // a digit, a letter, or an underscore), precede it with an
+ // underscore.
+ propertyName = $String.replace(propertyName, /^(\d)/g, '_$1');
// Uppercase (replace my_Enum_Foo with MY_ENUM_FOO):
propertyName = $String.toUpperCase(propertyName);
mod[id][propertyName] = enumValue;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698