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

Unified Diff: chrome/browser/resources/shared/js/cr.js

Issue 8341081: Add icon-visibility attribute to cr.ui.Tree. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use simple regex. Created 9 years, 2 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 | « chrome/browser/resources/shared/css/tree.css ('k') | chrome/browser/resources/shared/js/cr/ui/tree.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/shared/js/cr.js
diff --git a/chrome/browser/resources/shared/js/cr.js b/chrome/browser/resources/shared/js/cr.js
index 2a370a1c0ab5f2b3a9d5d75cbc21c42c51f459b2..fb47a8aae9dacca9838f1a5dcc729ea7eaccddb7 100644
--- a/chrome/browser/resources/shared/js/cr.js
+++ b/chrome/browser/resources/shared/js/cr.js
@@ -134,6 +134,16 @@ const cr = (function() {
}
/**
+ * Converts a camelCase javascript property name to a hyphenated-lower-case
+ * attribute name.
+ * @param {string} jsName The javascript camelCase property name.
+ * @return {string} The equivalent hyphenated-lower-case attribute name.
+ */
+ function getAttributeName(jsName) {
+ return jsName.replace(/([A-Z])/g, '-$1').toLowerCase();
+ }
+
+ /**
* The kind of property to define in {@code defineProperty}.
* @enum {number}
*/
@@ -171,12 +181,14 @@ const cr = (function() {
return this[privateName];
};
case PropertyKind.ATTR:
+ var attributeName = getAttributeName(name);
return function() {
- return this.getAttribute(name);
+ return this.getAttribute(attributeName);
};
case PropertyKind.BOOL_ATTR:
+ var attributeName = getAttributeName(name);
return function() {
- return this.hasAttribute(name);
+ return this.hasAttribute(attributeName);
};
}
}
@@ -207,13 +219,14 @@ const cr = (function() {
};
case PropertyKind.ATTR:
+ var attributeName = getAttributeName(name);
return function(value) {
- var oldValue = this[name];
+ var oldValue = this[attributeName];
if (value !== oldValue) {
if (value == undefined)
- this.removeAttribute(name);
+ this.removeAttribute(attributeName);
else
- this.setAttribute(name, value);
+ this.setAttribute(attributeName, value);
if (opt_setHook)
opt_setHook.call(this, value, oldValue);
dispatchPropertyChange(this, name, value, oldValue);
@@ -221,13 +234,14 @@ const cr = (function() {
};
case PropertyKind.BOOL_ATTR:
+ var attributeName = getAttributeName(name);
return function(value) {
- var oldValue = this[name];
+ var oldValue = this[attributeName];
if (value !== oldValue) {
if (value)
- this.setAttribute(name, name);
+ this.setAttribute(attributeName, name);
else
- this.removeAttribute(name);
+ this.removeAttribute(attributeName);
if (opt_setHook)
opt_setHook.call(this, value, oldValue);
dispatchPropertyChange(this, name, value, oldValue);
« no previous file with comments | « chrome/browser/resources/shared/css/tree.css ('k') | chrome/browser/resources/shared/js/cr/ui/tree.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698