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

Side by Side Diff: ui/webui/resources/js/i18n_template_no_process.js

Issue 1246633007: Check that processed i18n nodes are defined before marking them. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** @typedef {Document|DocumentFragment|Element} */ 5 /** @typedef {Document|DocumentFragment|Element} */
6 var ProcessingRoot; 6 var ProcessingRoot;
7 7
8 /** 8 /**
9 * @fileoverview This is a simple template engine inspired by JsTemplates 9 * @fileoverview This is a simple template engine inspired by JsTemplates
10 * optimized for i18n. 10 * optimized for i18n.
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 var isElement = root instanceof Element; 176 var isElement = root instanceof Element;
177 if (isElement && root.matches(selector)) 177 if (isElement && root.matches(selector))
178 processElement(/** @type {!Element} */(root), data, visited); 178 processElement(/** @type {!Element} */(root), data, visited);
179 179
180 var elements = root.querySelectorAll(selector); 180 var elements = root.querySelectorAll(selector);
181 for (var i = 0; i < elements.length; ++i) { 181 for (var i = 0; i < elements.length; ++i) {
182 processElement(elements[i], data, visited); 182 processElement(elements[i], data, visited);
183 } 183 }
184 184
185 if (mark) { 185 if (mark) {
186 var processed = isElement ? [root] : root.children; 186 var processed = isElement ? [root] : root.children;
Dan Beam 2015/07/22 00:20:40 fwiw: this would probably work on iOS as well v
187 for (var i = 0; i < processed.length; ++i) { 187 if (processed) {
Dan Beam 2015/07/21 21:26:21 I'm confused. if ([]) always triggers. root.child
188 processed[i].setAttribute('i18n-processed', ''); 188 for (var i = 0; i < processed.length; ++i) {
189 processed[i].setAttribute('i18n-processed', '');
190 }
189 } 191 }
190 } 192 }
191 } 193 }
192 194
193 /** 195 /**
194 * Run through various [i18n-*] attributes and populate. 196 * Run through various [i18n-*] attributes and populate.
195 * @param {!Element} element 197 * @param {!Element} element
196 * @param {!LoadTimeData} data 198 * @param {!LoadTimeData} data
197 * @param {!Array<ProcessingRoot>} visited 199 * @param {!Array<ProcessingRoot>} visited
198 */ 200 */
199 function processElement(element, data, visited) { 201 function processElement(element, data, visited) {
200 for (var i = 0; i < attributeNames.length; i++) { 202 for (var i = 0; i < attributeNames.length; i++) {
201 var name = attributeNames[i]; 203 var name = attributeNames[i];
202 var attribute = element.getAttribute(name); 204 var attribute = element.getAttribute(name);
203 if (attribute != null) 205 if (attribute != null)
204 handlers[name](element, attribute, data, visited); 206 handlers[name](element, attribute, data, visited);
205 } 207 }
206 } 208 }
207 209
208 return { 210 return {
209 process: process 211 process: process
210 }; 212 };
211 }()); 213 }());
OLDNEW
« 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