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

Unified Diff: ui/webui/resources/js/i18n_template.js

Issue 405743002: Typecheck some of ui/webui/resources/js/ with Closure compiler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cr.isMac fix Created 6 years, 4 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 | « ui/webui/resources/js/event_tracker.js ('k') | ui/webui/resources/js/i18n_template_no_process.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/js/i18n_template.js
diff --git a/ui/webui/resources/js/i18n_template.js b/ui/webui/resources/js/i18n_template.js
index ba41aee41bacda589bdf36743e15faf03a547520..87ba808ef31c9c13c42785f6faf1bbd432301314 100644
--- a/ui/webui/resources/js/i18n_template.js
+++ b/ui/webui/resources/js/i18n_template.js
@@ -25,12 +25,19 @@
* });
*/
+/**
+ * @typedef {function(!Element, string, Object)}
+ * TODO(dbeam): move inside (function() {...})() after
+ * https://github.com/google/closure-compiler/issues/544 is fixed.
+ */
+var Handler;
+
var i18nTemplate = (function() {
/**
* This provides the handlers for the templating engine. The key is used as
* the attribute name and the value is the function that gets called for every
* single node that has this attribute.
- * @type {Object}
+ * @type {Object.<Handler>}
*/
var handlers = {
/**
@@ -79,9 +86,8 @@ var i18nTemplate = (function() {
object[path] = value;
// In case we set innerHTML (ignoring others) we need to
// recursively check the content
- if (path == 'innerHTML') {
+ if (path == 'innerHTML')
process(element, obj);
- }
}
} else {
element.setAttribute(propName, value);
@@ -102,6 +108,8 @@ var i18nTemplate = (function() {
/**
* Processes a DOM tree with the {@code obj} map.
+ * @param {Node} node A node to process.
+ * @param {Object} obj Values to process |node| with.
*/
function process(node, obj) {
var elements = node.querySelectorAll(selector);
@@ -109,9 +117,8 @@ var i18nTemplate = (function() {
for (var j = 0; j < attributeNames.length; j++) {
var name = attributeNames[j];
var att = element.getAttribute(name);
- if (att != null) {
+ if (att != null)
handlers[name](element, att, obj);
- }
}
}
}
« no previous file with comments | « ui/webui/resources/js/event_tracker.js ('k') | ui/webui/resources/js/i18n_template_no_process.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698