Index: third_party/google_input_tools/third_party/closure_library/closure/goog/dom/dom.js |
diff --git a/third_party/google_input_tools/third_party/closure_library/closure/goog/dom/dom.js b/third_party/google_input_tools/third_party/closure_library/closure/goog/dom/dom.js |
index 1cb0dcad8f3a895c6a16c974c9a13587d1046a61..0da501d8760456f88f3f30741cbc08ea6261b88f 100644 |
--- a/third_party/google_input_tools/third_party/closure_library/closure/goog/dom/dom.js |
+++ b/third_party/google_input_tools/third_party/closure_library/closure/goog/dom/dom.js |
@@ -20,6 +20,7 @@ |
* to a different document object. This is useful if you are working with |
* frames or multiple windows. |
* |
+ * @author arv@google.com (Erik Arvidsson) |
*/ |
@@ -37,11 +38,13 @@ goog.require('goog.asserts'); |
goog.require('goog.dom.BrowserFeature'); |
goog.require('goog.dom.NodeType'); |
goog.require('goog.dom.TagName'); |
-goog.require('goog.functions'); |
+goog.require('goog.dom.safe'); |
+goog.require('goog.html.SafeHtml'); |
goog.require('goog.math.Coordinate'); |
goog.require('goog.math.Size'); |
goog.require('goog.object'); |
goog.require('goog.string'); |
+goog.require('goog.string.Unicode'); |
goog.require('goog.userAgent'); |
@@ -227,7 +230,9 @@ goog.dom.getElementsByClass = function(className, opt_el) { |
goog.dom.getElementByClass = function(className, opt_el) { |
var parent = opt_el || document; |
var retVal = null; |
- if (goog.dom.canUseQuerySelector_(parent)) { |
+ if (parent.getElementsByClassName) { |
+ retVal = parent.getElementsByClassName(className)[0]; |
+ } else if (goog.dom.canUseQuerySelector_(parent)) { |
retVal = parent.querySelector('.' + className); |
} else { |
retVal = goog.dom.getElementsByTagNameAndClass_( |
@@ -357,7 +362,7 @@ goog.dom.setProperties = function(element, properties) { |
element.className = val; |
} else if (key == 'for') { |
element.htmlFor = val; |
- } else if (key in goog.dom.DIRECT_ATTRIBUTE_MAP_) { |
+ } else if (goog.dom.DIRECT_ATTRIBUTE_MAP_.hasOwnProperty(key)) { |
element.setAttribute(goog.dom.DIRECT_ATTRIBUTE_MAP_[key], val); |
} else if (goog.string.startsWith(key, 'aria-') || |
goog.string.startsWith(key, 'data-')) { |
@@ -374,8 +379,8 @@ goog.dom.setProperties = function(element, properties) { |
* element.setAttribute(key, val) instead of element[key] = val. Used |
* by goog.dom.setProperties. |
* |
- * @type {Object} |
- * @private |
+ * @private {!Object<string, string>} |
+ * @const |
*/ |
goog.dom.DIRECT_ATTRIBUTE_MAP_ = { |
'cellpadding': 'cellPadding', |
@@ -494,7 +499,7 @@ goog.dom.getDocumentHeight = function() { |
* gadgets.window.adjustHeight(opt_height) |
* |
* @private |
- * @param {Window} win The window whose document height to retrieve. |
+ * @param {!Window} win The window whose document height to retrieve. |
* @return {number} The height of the document of the given window. |
*/ |
goog.dom.getDocumentHeight_ = function(win) { |
@@ -514,11 +519,9 @@ goog.dom.getDocumentHeight_ = function(win) { |
// But there are patterns. It just takes a lot of time and persistence |
// to figure out. |
- // If the window has no contents, it has no height. (In IE10, |
- // document.body & document.documentElement are null in an empty iFrame.) |
var body = doc.body; |
- var docEl = doc.documentElement; |
- if (!body && !docEl) { |
+ var docEl = /** @type {!HTMLElement} */ (doc.documentElement); |
+ if (!(docEl && body)) { |
return 0; |
} |
@@ -627,9 +630,14 @@ goog.dom.getDocumentScrollElement = function() { |
* @private |
*/ |
goog.dom.getDocumentScrollElement_ = function(doc) { |
- // WebKit needs body.scrollLeft in both quirks mode and strict mode. We also |
- // default to the documentElement if the document does not have a body (e.g. |
- // a SVG document). |
+ // Old WebKit needs body.scrollLeft in both quirks mode and strict mode. We |
+ // also default to the documentElement if the document does not have a body |
+ // (e.g. a SVG document). |
+ // Uses http://dev.w3.org/csswg/cssom-view/#dom-document-scrollingelement to |
+ // avoid trying to guess about browser behavior from the UA string. |
+ if (doc.scrollingElement) { |
+ return doc.scrollingElement; |
+ } |
if (!goog.userAgent.WEBKIT && goog.dom.isCss1CompatMode_(doc)) { |
return doc.documentElement; |
} |
@@ -671,12 +679,12 @@ goog.dom.getWindow_ = function(doc) { |
* would return a div with two child paragraphs |
* |
* @param {string} tagName Tag to create. |
- * @param {(Object|Array.<string>|string)=} opt_attributes If object, then a map |
+ * @param {(Object|Array<string>|string)=} opt_attributes If object, then a map |
* of name-value pairs for attributes. If a string, then this is the |
* className of the new element. If an array, the elements will be joined |
* together as the className of the new element. |
* @param {...(Object|string|Array|NodeList)} var_args Further DOM nodes or |
- * strings for text nodes. If one of the var_args is an array or NodeList,i |
+ * strings for text nodes. If one of the var_args is an array or NodeList, |
* its elements will be added as childNodes instead. |
* @return {!Element} Reference to a DOM node. |
*/ |
@@ -818,10 +826,13 @@ goog.dom.createTextNode = function(content) { |
* Create a table. |
* @param {number} rows The number of rows in the table. Must be >= 1. |
* @param {number} columns The number of columns in the table. Must be >= 1. |
- * @param {boolean=} opt_fillWithNbsp If true, fills table entries with nsbps. |
+ * @param {boolean=} opt_fillWithNbsp If true, fills table entries with |
+ * {@code goog.string.Unicode.NBSP} characters. |
* @return {!Element} The created table. |
*/ |
goog.dom.createTable = function(rows, columns, opt_fillWithNbsp) { |
+ // TODO(user): Return HTMLTableElement, also in prototype function. |
+ // Callers need to be updated to e.g. not assign numbers to table.cellSpacing. |
return goog.dom.createTable_(document, rows, columns, !!opt_fillWithNbsp); |
}; |
@@ -831,26 +842,60 @@ goog.dom.createTable = function(rows, columns, opt_fillWithNbsp) { |
* @param {!Document} doc Document object to use to create the table. |
* @param {number} rows The number of rows in the table. Must be >= 1. |
* @param {number} columns The number of columns in the table. Must be >= 1. |
- * @param {boolean} fillWithNbsp If true, fills table entries with nsbps. |
- * @return {!Element} The created table. |
+ * @param {boolean} fillWithNbsp If true, fills table entries with |
+ * {@code goog.string.Unicode.NBSP} characters. |
+ * @return {!HTMLTableElement} The created table. |
* @private |
*/ |
goog.dom.createTable_ = function(doc, rows, columns, fillWithNbsp) { |
- var rowHtml = ['<tr>']; |
- for (var i = 0; i < columns; i++) { |
- rowHtml.push(fillWithNbsp ? '<td> </td>' : '<td></td>'); |
- } |
- rowHtml.push('</tr>'); |
- rowHtml = rowHtml.join(''); |
- var totalHtml = ['<table>']; |
- for (i = 0; i < rows; i++) { |
- totalHtml.push(rowHtml); |
+ var table = /** @type {!HTMLTableElement} */ |
+ (doc.createElement(goog.dom.TagName.TABLE)); |
+ var tbody = table.appendChild(doc.createElement(goog.dom.TagName.TBODY)); |
+ for (var i = 0; i < rows; i++) { |
+ var tr = doc.createElement(goog.dom.TagName.TR); |
+ for (var j = 0; j < columns; j++) { |
+ var td = doc.createElement(goog.dom.TagName.TD); |
+ // IE <= 9 will create a text node if we set text content to the empty |
+ // string, so we avoid doing it unless necessary. This ensures that the |
+ // same DOM tree is returned on all browsers. |
+ if (fillWithNbsp) { |
+ goog.dom.setTextContent(td, goog.string.Unicode.NBSP); |
+ } |
+ tr.appendChild(td); |
+ } |
+ tbody.appendChild(tr); |
} |
- totalHtml.push('</table>'); |
+ return table; |
+}; |
+ |
+ |
+/** |
+ * Converts HTML markup into a node. |
+ * @param {!goog.html.SafeHtml} html The HTML markup to convert. |
+ * @return {!Node} The resulting node. |
+ */ |
+goog.dom.safeHtmlToNode = function(html) { |
+ return goog.dom.safeHtmlToNode_(document, html); |
+}; |
- var elem = doc.createElement(goog.dom.TagName.DIV); |
- elem.innerHTML = totalHtml.join(''); |
- return /** @type {!Element} */ (elem.removeChild(elem.firstChild)); |
+ |
+/** |
+ * Helper for {@code safeHtmlToNode}. |
+ * @param {!Document} doc The document. |
+ * @param {!goog.html.SafeHtml} html The HTML markup to convert. |
+ * @return {!Node} The resulting node. |
+ * @private |
+ */ |
+goog.dom.safeHtmlToNode_ = function(doc, html) { |
+ var tempDiv = doc.createElement(goog.dom.TagName.DIV); |
+ if (goog.dom.BrowserFeature.INNER_HTML_NEEDS_SCOPED_ELEMENT) { |
+ goog.dom.safe.setInnerHtml(tempDiv, |
+ goog.html.SafeHtml.concat(goog.html.SafeHtml.create('br'), html)); |
+ tempDiv.removeChild(tempDiv.firstChild); |
+ } else { |
+ goog.dom.safe.setInnerHtml(tempDiv, html); |
+ } |
+ return goog.dom.childrenToNode_(doc, tempDiv); |
}; |
@@ -869,6 +914,7 @@ goog.dom.htmlToDocumentFragment = function(htmlString) { |
}; |
+// TODO(jakubvrana): Merge with {@code safeHtmlToNode_}. |
/** |
* Helper for {@code htmlToDocumentFragment}. |
* |
@@ -878,15 +924,27 @@ goog.dom.htmlToDocumentFragment = function(htmlString) { |
* @private |
*/ |
goog.dom.htmlToDocumentFragment_ = function(doc, htmlString) { |
- var tempDiv = doc.createElement('div'); |
+ var tempDiv = doc.createElement(goog.dom.TagName.DIV); |
if (goog.dom.BrowserFeature.INNER_HTML_NEEDS_SCOPED_ELEMENT) { |
tempDiv.innerHTML = '<br>' + htmlString; |
tempDiv.removeChild(tempDiv.firstChild); |
} else { |
tempDiv.innerHTML = htmlString; |
} |
+ return goog.dom.childrenToNode_(doc, tempDiv); |
+}; |
+ |
+ |
+/** |
+ * Helper for {@code htmlToDocumentFragment_}. |
+ * @param {!Document} doc The document. |
+ * @param {!Node} tempDiv The input node. |
+ * @return {!Node} The resulting node. |
+ * @private |
+ */ |
+goog.dom.childrenToNode_ = function(doc, tempDiv) { |
if (tempDiv.childNodes.length == 1) { |
- return /** @type {!Node} */ (tempDiv.removeChild(tempDiv.firstChild)); |
+ return tempDiv.removeChild(tempDiv.firstChild); |
} else { |
var fragment = doc.createDocumentFragment(); |
while (tempDiv.firstChild) { |
@@ -910,7 +968,7 @@ goog.dom.isCss1CompatMode = function() { |
/** |
* Returns true if the browser is in "CSS1-compatible" (standards-compliant) |
* mode, false otherwise. |
- * @param {Document} doc The document to check. |
+ * @param {!Document} doc The document to check. |
* @return {boolean} True if in CSS1-compatible mode. |
* @private |
*/ |
@@ -935,7 +993,7 @@ goog.dom.isCss1CompatMode_ = function(doc) { |
* the behavior is inconsistent: |
* |
* <pre> |
- * var a = document.createElement('br'); |
+ * var a = document.createElement(goog.dom.TagName.BR); |
* a.appendChild(document.createTextNode('foo')); |
* a.appendChild(document.createTextNode('bar')); |
* console.log(a.childNodes.length); // 2 |
@@ -954,7 +1012,7 @@ goog.dom.canHaveChildren = function(node) { |
if (node.nodeType != goog.dom.NodeType.ELEMENT) { |
return false; |
} |
- switch (node.tagName) { |
+ switch (/** @type {!Element} */ (node).tagName) { |
case goog.dom.TagName.APPLET: |
case goog.dom.TagName.AREA: |
case goog.dom.TagName.BASE: |
@@ -1143,8 +1201,8 @@ goog.dom.getChildren = function(element) { |
* @return {Element} The first child node of {@code node} that is an element. |
*/ |
goog.dom.getFirstElementChild = function(node) { |
- if (node.firstElementChild != undefined) { |
- return /** @type {Element} */(node).firstElementChild; |
+ if (goog.isDef(node.firstElementChild)) { |
+ return /** @type {!Element} */(node).firstElementChild; |
} |
return goog.dom.getNextElementNode_(node.firstChild, true); |
}; |
@@ -1156,8 +1214,8 @@ goog.dom.getFirstElementChild = function(node) { |
* @return {Element} The last child node of {@code node} that is an element. |
*/ |
goog.dom.getLastElementChild = function(node) { |
- if (node.lastElementChild != undefined) { |
- return /** @type {Element} */(node).lastElementChild; |
+ if (goog.isDef(node.lastElementChild)) { |
+ return /** @type {!Element} */(node).lastElementChild; |
} |
return goog.dom.getNextElementNode_(node.lastChild, false); |
}; |
@@ -1169,8 +1227,8 @@ goog.dom.getLastElementChild = function(node) { |
* @return {Element} The next sibling of {@code node} that is an element. |
*/ |
goog.dom.getNextElementSibling = function(node) { |
- if (node.nextElementSibling != undefined) { |
- return /** @type {Element} */(node).nextElementSibling; |
+ if (goog.isDef(node.nextElementSibling)) { |
+ return /** @type {!Element} */(node).nextElementSibling; |
} |
return goog.dom.getNextElementNode_(node.nextSibling, true); |
}; |
@@ -1183,8 +1241,8 @@ goog.dom.getNextElementSibling = function(node) { |
* an element. |
*/ |
goog.dom.getPreviousElementSibling = function(node) { |
- if (node.previousElementSibling != undefined) { |
- return /** @type {Element} */(node).previousElementSibling; |
+ if (goog.isDef(node.previousElementSibling)) { |
+ return /** @type {!Element} */(node).previousElementSibling; |
} |
return goog.dom.getNextElementNode_(node.previousSibling, false); |
}; |
@@ -1426,7 +1484,7 @@ goog.dom.compareNodeOrder = function(node1, node2) { |
* Utility function to compare the position of two nodes, when |
* {@code textNode}'s parent is an ancestor of {@code node}. If this entry |
* condition is not met, this function will attempt to reference a null object. |
- * @param {Node} textNode The textNode to compare. |
+ * @param {!Node} textNode The textNode to compare. |
* @param {Node} node The node to compare. |
* @return {number} -1 if node is before textNode, +1 otherwise. |
* @private |
@@ -1449,7 +1507,7 @@ goog.dom.compareParentsDescendantNodeIe_ = function(textNode, node) { |
* Utility function to compare the position of two nodes known to be non-equal |
* siblings. |
* @param {Node} node1 The first node to compare. |
- * @param {Node} node2 The second node to compare. |
+ * @param {!Node} node2 The second node to compare. |
* @return {number} -1 if node1 is before node2, +1 otherwise. |
* @private |
*/ |
@@ -1588,7 +1646,7 @@ goog.dom.getOuterHtml = function(element) { |
return element.outerHTML; |
} else { |
var doc = goog.dom.getOwnerDocument(element); |
- var div = doc.createElement('div'); |
+ var div = doc.createElement(goog.dom.TagName.DIV); |
div.appendChild(element.cloneNode(true)); |
return div.innerHTML; |
} |
@@ -1625,7 +1683,7 @@ goog.dom.findNode = function(root, p) { |
* @param {Node} root The root of the tree to search. |
* @param {function(Node) : boolean} p The filter function. |
- * @return {!Array.<!Node>} The found nodes or an empty array if none are found. |
+ * @return {!Array<!Node>} The found nodes or an empty array if none are found. |
*/ |
goog.dom.findNodes = function(root, p) { |
var rv = []; |
@@ -1639,7 +1697,7 @@ goog.dom.findNodes = function(root, p) { |
* using a depth first search. |
* @param {Node} root The root of the tree to search. |
* @param {function(Node) : boolean} p The filter function. |
- * @param {!Array.<!Node>} rv The found nodes are added to this array. |
+ * @param {!Array<!Node>} rv The found nodes are added to this array. |
* @param {boolean} findOne If true we exit after the first found node. |
* @return {boolean} Whether the search is complete or not. True in case findOne |
* is true and the node is found. False otherwise. |
@@ -1667,8 +1725,8 @@ goog.dom.findNodes_ = function(root, p, rv, findOne) { |
/** |
* Map of tags whose content to ignore when calculating text length. |
- * @type {Object} |
- * @private |
+ * @private {!Object<string, number>} |
+ * @const |
*/ |
goog.dom.TAGS_TO_IGNORE_ = { |
'SCRIPT': 1, |
@@ -1681,8 +1739,8 @@ goog.dom.TAGS_TO_IGNORE_ = { |
/** |
* Map of tags which have predefined values with regard to whitespace. |
- * @type {Object} |
- * @private |
+ * @private {!Object<string, string>} |
+ * @const |
*/ |
goog.dom.PREDEFINED_TAG_VALUES_ = {'IMG': ' ', 'BR': '\n'}; |
@@ -1691,7 +1749,7 @@ goog.dom.PREDEFINED_TAG_VALUES_ = {'IMG': ' ', 'BR': '\n'}; |
* Returns true if the element has a tab index that allows it to receive |
* keyboard focus (tabIndex >= 0), false otherwise. Note that some elements |
* natively support keyboard focus, even if they have no tab index. |
- * @param {Element} element Element to check. |
+ * @param {!Element} element Element to check. |
* @return {boolean} Whether the element has a tab index that allows keyboard |
* focus. |
* @see http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
@@ -1729,7 +1787,7 @@ goog.dom.setFocusableTabIndex = function(element, enable) { |
* Returns true if the element can be focused, i.e. it has a tab index that |
* allows it to receive keyboard focus (tabIndex >= 0), or it is an element |
* that natively supports keyboard focus. |
- * @param {Element} element Element to check. |
+ * @param {!Element} element Element to check. |
* @return {boolean} Whether the element allows keyboard focus. |
*/ |
goog.dom.isFocusable = function(element) { |
@@ -1753,7 +1811,7 @@ goog.dom.isFocusable = function(element) { |
/** |
* Returns true if the element has a specified tab index. |
- * @param {Element} element Element to check. |
+ * @param {!Element} element Element to check. |
* @return {boolean} Whether the element has a specified tab index. |
* @private |
*/ |
@@ -1768,7 +1826,7 @@ goog.dom.hasSpecifiedTabIndex_ = function(element) { |
/** |
* Returns true if the element's tab index allows the element to be focused. |
- * @param {Element} element Element to check. |
+ * @param {!Element} element Element to check. |
* @return {boolean} Whether the element's tab index allows focus. |
* @private |
*/ |
@@ -1781,7 +1839,7 @@ goog.dom.isTabIndexFocusable_ = function(element) { |
/** |
* Returns true if the element is focusable even when tabIndex is not set. |
- * @param {Element} element Element to check. |
+ * @param {!Element} element Element to check. |
* @return {boolean} Whether the element natively supports focus. |
* @private |
*/ |
@@ -1797,7 +1855,7 @@ goog.dom.nativelySupportsFocus_ = function(element) { |
/** |
* Returns true if the element has a bounding rectangle that would be visible |
* (i.e. its width and height are greater than zero). |
- * @param {Element} element Element to check. |
+ * @param {!Element} element Element to check. |
* @return {boolean} Whether the element has a non-zero bounding rectangle. |
* @private |
*/ |
@@ -1874,7 +1932,7 @@ goog.dom.getRawTextContent = function(node) { |
* Recursive support function for text content retrieval. |
* |
* @param {Node} node The node from which we are getting content. |
- * @param {Array} buf string buffer. |
+ * @param {Array<string>} buf string buffer. |
* @param {boolean} normalizeWhitespace Whether to normalize whitespace. |
* @private |
*/ |
@@ -2013,10 +2071,13 @@ goog.dom.isNodeList = function(val) { |
* null/undefined to match only based on class name). |
* @param {?string=} opt_class The class name to match (or null/undefined to |
* match only based on tag name). |
+ * @param {number=} opt_maxSearchSteps Maximum number of levels to search up the |
+ * dom. |
* @return {Element} The first ancestor that matches the passed criteria, or |
* null if no match is found. |
*/ |
-goog.dom.getAncestorByTagNameAndClass = function(element, opt_tag, opt_class) { |
+goog.dom.getAncestorByTagNameAndClass = function(element, opt_tag, opt_class, |
+ opt_maxSearchSteps) { |
if (!opt_tag && !opt_class) { |
return null; |
} |
@@ -2026,7 +2087,7 @@ goog.dom.getAncestorByTagNameAndClass = function(element, opt_tag, opt_class) { |
return (!tagName || node.nodeName == tagName) && |
(!opt_class || goog.isString(node.className) && |
goog.array.contains(node.className.split(/\s+/), opt_class)); |
- }, true)); |
+ }, true, opt_maxSearchSteps)); |
}; |
@@ -2036,11 +2097,14 @@ goog.dom.getAncestorByTagNameAndClass = function(element, opt_tag, opt_class) { |
* element itself is returned. |
* @param {Node} element The DOM node to start with. |
* @param {string} className The class name to match. |
+ * @param {number=} opt_maxSearchSteps Maximum number of levels to search up the |
+ * dom. |
* @return {Element} The first ancestor that matches the passed criteria, or |
* null if none match. |
*/ |
-goog.dom.getAncestorByClass = function(element, className) { |
- return goog.dom.getAncestorByTagNameAndClass(element, null, className); |
+goog.dom.getAncestorByClass = function(element, className, opt_maxSearchSteps) { |
+ return goog.dom.getAncestorByTagNameAndClass(element, null, className, |
+ opt_maxSearchSteps); |
}; |
@@ -2066,6 +2130,7 @@ goog.dom.getAncestor = function( |
var ignoreSearchSteps = opt_maxSearchSteps == null; |
var steps = 0; |
while (element && (ignoreSearchSteps || steps <= opt_maxSearchSteps)) { |
+ goog.asserts.assert(element.name != 'parentNode'); |
if (matcher(element)) { |
return element; |
} |
@@ -2100,24 +2165,20 @@ goog.dom.getActiveElement = function(doc) { |
/** |
- * @private {number} Cached version of the devicePixelRatio. |
- */ |
-goog.dom.devicePixelRatio_; |
- |
- |
-/** |
- * Gives the devicePixelRatio, or attempts to determine if not present. |
+ * Gives the current devicePixelRatio. |
+ * |
+ * By default, this is the value of window.devicePixelRatio (which should be |
+ * preferred if present). |
* |
- * By default, this is the same value given by window.devicePixelRatio. If |
- * devicePixelRatio is not defined, the ratio is calculated with |
+ * If window.devicePixelRatio is not present, the ratio is calculated with |
* window.matchMedia, if present. Otherwise, gives 1.0. |
* |
- * This function is cached so that the pixel ratio is calculated only once |
- * and only calculated when first requested. |
+ * Some browsers (including Chrome) consider the browser zoom level in the pixel |
+ * ratio, so the value may change across multiple calls. |
* |
* @return {number} The number of actual pixels per virtual pixel. |
*/ |
-goog.dom.getPixelRatio = goog.functions.cacheReturnValue(function() { |
+goog.dom.getPixelRatio = function() { |
var win = goog.dom.getWindow(); |
// devicePixelRatio does not work on Mobile firefox. |
@@ -2134,7 +2195,7 @@ goog.dom.getPixelRatio = goog.functions.cacheReturnValue(function() { |
goog.dom.matchesPixelRatio_(3) || 1; |
} |
return 1; |
-}); |
+}; |
/** |
@@ -2418,8 +2479,9 @@ goog.dom.DomHelper.prototype.createTextNode = function(content) { |
* Create a table. |
* @param {number} rows The number of rows in the table. Must be >= 1. |
* @param {number} columns The number of columns in the table. Must be >= 1. |
- * @param {boolean=} opt_fillWithNbsp If true, fills table entries with nsbps. |
- * @return {!Element} The created table. |
+ * @param {boolean=} opt_fillWithNbsp If true, fills table entries with |
+ * {@code goog.string.Unicode.NBSP} characters. |
+ * @return {!HTMLElement} The created table. |
*/ |
goog.dom.DomHelper.prototype.createTable = function(rows, columns, |
opt_fillWithNbsp) { |
@@ -2429,6 +2491,18 @@ goog.dom.DomHelper.prototype.createTable = function(rows, columns, |
/** |
+ * Converts an HTML into a node or a document fragment. A single Node is used if |
+ * {@code html} only generates a single node. If {@code html} generates multiple |
+ * nodes then these are put inside a {@code DocumentFragment}. |
+ * @param {!goog.html.SafeHtml} html The HTML markup to convert. |
+ * @return {!Node} The resulting node. |
+ */ |
+goog.dom.DomHelper.prototype.safeHtmlToNode = function(html) { |
+ return goog.dom.safeHtmlToNode_(this.document_, html); |
+}; |
+ |
+ |
+/** |
* Converts an HTML string into a node or a document fragment. A single Node |
* is used if the {@code htmlString} only generates a single node. If the |
* {@code htmlString} generates multiple nodes then these are put inside a |
@@ -2770,7 +2844,7 @@ goog.dom.DomHelper.prototype.findNode = goog.dom.findNode; |
* depth first search. |
* @param {Node} root The root of the tree to search. |
* @param {function(Node) : boolean} p The filter function. |
- * @return {Array.<Node>} The found nodes or an empty array if none are found. |
+ * @return {Array<Node>} The found nodes or an empty array if none are found. |
*/ |
goog.dom.DomHelper.prototype.findNodes = goog.dom.findNodes; |
@@ -2779,7 +2853,7 @@ goog.dom.DomHelper.prototype.findNodes = goog.dom.findNodes; |
* Returns true if the element has a tab index that allows it to receive |
* keyboard focus (tabIndex >= 0), false otherwise. Note that some elements |
* natively support keyboard focus, even if they have no tab index. |
- * @param {Element} element Element to check. |
+ * @param {!Element} element Element to check. |
* @return {boolean} Whether the element has a tab index that allows keyboard |
* focus. |
*/ |
@@ -2803,7 +2877,7 @@ goog.dom.DomHelper.prototype.setFocusableTabIndex = |
* Returns true if the element can be focused, i.e. it has a tab index that |
* allows it to receive keyboard focus (tabIndex >= 0), or it is an element |
* that natively supports keyboard focus. |
- * @param {Element} element Element to check. |
+ * @param {!Element} element Element to check. |
* @return {boolean} Whether the element allows keyboard focus. |
*/ |
goog.dom.DomHelper.prototype.isFocusable = goog.dom.isFocusable; |
@@ -2880,6 +2954,8 @@ goog.dom.DomHelper.prototype.isNodeList = goog.dom.isNodeList; |
* null/undefined to match only based on class name). |
* @param {?string=} opt_class The class name to match (or null/undefined to |
* match only based on tag name). |
+ * @param {number=} opt_maxSearchSteps Maximum number of levels to search up the |
+ * dom. |
* @return {Element} The first ancestor that matches the passed criteria, or |
* null if no match is found. |
*/ |
@@ -2893,6 +2969,8 @@ goog.dom.DomHelper.prototype.getAncestorByTagNameAndClass = |
* element itself is returned. |
* @param {Node} element The DOM node to start with. |
* @param {string} class The class name to match. |
+ * @param {number=} opt_maxSearchSteps Maximum number of levels to search up the |
+ * dom. |
* @return {Element} The first ancestor that matches the passed criteria, or |
* null if none match. |
*/ |