From 2515cd215f81e8533281664e83538cbc2fc9d103 Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Tue, 17 Nov 2020 11:58:44 -0800 Subject: [PATCH] Upstream internal error suppression. Co-authored-by: Phil Harnish --- lib/utils/gestures.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/utils/gestures.js b/lib/utils/gestures.js index 24a620c784..8c5477d74f 100644 --- a/lib/utils/gestures.js +++ b/lib/utils/gestures.js @@ -143,13 +143,20 @@ function matchingLabels(el) { // as the mouseCancellor code will handle ancstor labels if (!labels.length) { labels = []; - let root = el.getRootNode(); - // if there is an id on `el`, check for all labels with a matching `for` attribute - if (el.id) { - let matching = root.querySelectorAll(`label[for = ${el.id}]`); - for (let i = 0; i < matching.length; i++) { - labels.push(/** @type {!HTMLLabelElement} */(matching[i])); + try { + let root = el.getRootNode(); + // if there is an id on `el`, check for all labels with a matching `for` attribute + if (el.id) { + let matching = root.querySelectorAll(`label[for = ${el.id}]`); + for (let i = 0; i < matching.length; i++) { + labels.push(/** @type {!HTMLLabelElement} */(matching[i])); + } } + } catch (e) { + // Either: + // 1. el.getRootNode() failed. + // 2. el.id cannot be used in `querySelectorAll` + // In both cases, do nothing. } } return labels;