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

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

Issue 667933003: Ensure existence of queried elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make some parameters non-nullable. Created 6 years, 2 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/file_manager/file_manager/foreground/js/ui/progress_center_panel.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/js/util.js
diff --git a/ui/webui/resources/js/util.js b/ui/webui/resources/js/util.js
index 9f973511327a3ac3fa15a8f83c532c1178630af3..10881b2500cc1edf87caed3e49e0e09139728709 100644
--- a/ui/webui/resources/js/util.js
+++ b/ui/webui/resources/js/util.js
@@ -261,6 +261,21 @@ function getRequiredElement(id) {
'Missing required element: ' + id);
}
+/**
+ * Query an element that's known to exist by a selector. We use this instead of
+ * just calling querySelector and not checking the result because this lets us
+ * satisfy the JSCompiler type system.
+ * @param {(!Document|!DocumentFragment|!Element)} context The context object
+ * for querySelector.
+ * @param {string} selectors CSS selectors to query the element.
+ * @return {!HTMLElement} the Element.
+ */
+function queryRequiredElement(context, selectors) {
+ var element = context.querySelector(selectors);
+ return assertInstanceof(element, HTMLElement,
+ 'Missing required element: ' + selectors);
+}
+
// Handle click on a link. If the link points to a chrome: or file: url, then
// call into the browser to do the navigation.
document.addEventListener('click', function(e) {
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/ui/progress_center_panel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698