Chromium Code Reviews| 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..b3fa15eac942e680ae501aebeb6462cd19e58a8f 100644 |
| --- a/ui/webui/resources/js/i18n_template.js |
| +++ b/ui/webui/resources/js/i18n_template.js |
| @@ -25,12 +25,15 @@ |
| * }); |
| */ |
| +/** @typedef {function(!Element, string, Object)} */ |
| +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 +82,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 +104,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); |
|
arv (Not doing code reviews)
2014/07/16 18:33:03
Node does not have querySelectorAll. Do you want t
Dan Beam
2014/07/19 02:28:40
MDN says it's on Element...
https://developer.mozi
arv (Not doing code reviews)
2014/07/21 18:25:31
MDN is wrong. Shocking!
classList is part of Elem
|
| @@ -109,9 +113,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); |
| - } |
| } |
| } |
| } |