Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/utils.js

Issue 11015083: Merge labels and access keys into one string in locales (Closed)
Patch Set: Created July 9, 2013, 12:03 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« lib/ui.js ('K') | « lib/ui.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/utils.js
===================================================================
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -483,24 +483,34 @@ let Utils = exports.Utils =
}
},
/**
* Split all labels starting from a particular DOM node.
*/
splitAllLabels: function(/**DOMNode*/ root)
{
- let elements = root.querySelectorAll("*[label], label[value]");
+ let attrMap = {
+ __proto__: null,
+ "label": "value",
+ "setting": "title"
+ };
+
+ let elements = root.querySelectorAll("*[label], label[value], setting[title]");
for (let i = 0; i < elements.length; i++)
{
let element = elements[i];
- let attr = (element.localName == "label" ? "value" : "label");
- let [label, accesskey] = this.splitLabel(element.getAttribute(attr));
- element.setAttribute(attr, label);
- element.setAttribute("accesskey", accesskey);
+ let attr = (element.localName in attrMap ? attrMap[element.localName] : "label");
+ let origLabel = element.getAttribute(attr);
+
+ let [label, accesskey] = this.splitLabel(origLabel);
+ if (label != origLabel)
+ element.setAttribute(attr, label);
+ if (accesskey != "")
Wladimir Palant 2013/07/09 12:10:59 The added checks here aren't strictly necessary bu
+ element.setAttribute("accesskey", accesskey);
// Labels forward changes of the accessKey property to their control, only
// set it for actual controls.
if (element.localName != "label")
element.accessKey = accesskey;
}
}
};
« lib/ui.js ('K') | « lib/ui.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld