Fix for browsers that don't have input.labels.

This commit is contained in:
Steven Orvell
2018-05-04 16:24:41 -07:00
parent 2ce4f70094
commit 036e4f66b8

View File

@@ -125,7 +125,7 @@ function canBeLabelled(el) {
* @return {!Array<!HTMLLabelElement>} Relevant label for `el`
*/
function matchingLabels(el) {
let labels = Array.prototype.slice.call(/** @type {HTMLInputElement} */(el).labels);
let labels = Array.prototype.slice.call(/** @type {HTMLInputElement} */(el).labels || []);
// IE doesn't have `labels` and Safari doesn't populate `labels`
// if element is in a shadowroot.
// In this instance, finding the non-ancestor labels is enough,