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

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

Issue 454223004: Typecheck JS files for chrome://history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@B_download
Patch Set: rebase once again 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 unified diff | Download patch
« no previous file with comments | « ui/webui/resources/js/event_tracker.js ('k') | 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 <include src="assert.js"> 5 <include src="assert.js">
6 6
7 /** 7 /**
8 * Alias for document.getElementById. 8 * Alias for document.getElementById.
9 * @param {string} id The ID of the element to find. 9 * @param {string} id The ID of the element to find.
10 * @return {HTMLElement} The found element or null if not found. 10 * @return {HTMLElement} The found element or null if not found.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 var newQuery = ''; 162 var newQuery = '';
163 for (var q in query) { 163 for (var q in query) {
164 newQuery += (newQuery ? '&' : '?') + q + '=' + query[q]; 164 newQuery += (newQuery ? '&' : '?') + q + '=' + query[q];
165 } 165 }
166 166
167 return location.origin + location.pathname + newQuery + location.hash; 167 return location.origin + location.pathname + newQuery + location.hash;
168 } 168 }
169 169
170 /** 170 /**
171 * @param {Node} el An element to search for ancestors with |className|. 171 * @param {Element} el An element to search for ancestors with |className|.
172 * @param {string} className A class to search for. 172 * @param {string} className A class to search for.
173 * @return {Node} A node with class of |className| or null if none is found. 173 * @return {Element} A node with class of |className| or null if none is found.
174 */ 174 */
175 function findAncestorByClass(el, className) { 175 function findAncestorByClass(el, className) {
176 return findAncestor(el, function(el) { 176 return /** @type {Element} */(findAncestor(el, function(el) {
177 return el.classList && el.classList.contains(className); 177 return el.classList && el.classList.contains(className);
178 }); 178 }));
179 } 179 }
180 180
181 /** 181 /**
182 * Return the first ancestor for which the {@code predicate} returns true. 182 * Return the first ancestor for which the {@code predicate} returns true.
183 * @param {Node} node The node to check. 183 * @param {Node} node The node to check.
184 * @param {function(Node):boolean} predicate The function that tests the 184 * @param {function(Node):boolean} predicate The function that tests the
185 * nodes. 185 * nodes.
186 * @return {Node} The found ancestor or null if not found. 186 * @return {Node} The found ancestor or null if not found.
187 */ 187 */
188 function findAncestor(node, predicate) { 188 function findAncestor(node, predicate) {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 * @param {number} maxLength The maximum length allowed for the string. 432 * @param {number} maxLength The maximum length allowed for the string.
433 * @return {string} The original string if its length does not exceed 433 * @return {string} The original string if its length does not exceed
434 * |maxLength|. Otherwise the first |maxLength| - 1 characters with '...' 434 * |maxLength|. Otherwise the first |maxLength| - 1 characters with '...'
435 * appended. 435 * appended.
436 */ 436 */
437 function elide(original, maxLength) { 437 function elide(original, maxLength) {
438 if (original.length <= maxLength) 438 if (original.length <= maxLength)
439 return original; 439 return original;
440 return original.substring(0, maxLength - 1) + '\u2026'; 440 return original.substring(0, maxLength - 1) + '\u2026';
441 } 441 }
OLDNEW
« no previous file with comments | « ui/webui/resources/js/event_tracker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698