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) { |