From 9a338c1935f3c2cbdcfefde1d54f225a1db9bd42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Vilhelm=20=C3=81sgeirsson?= Date: Fri, 2 Nov 2018 01:02:59 +0000 Subject: [PATCH] Add element property check to fix google product search bars. --- src/lib/dom.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lib/dom.ts b/src/lib/dom.ts index d6ea741e..fed800ed 100644 --- a/src/lib/dom.ts +++ b/src/lib/dom.ts @@ -2,7 +2,11 @@ import * as config from "@src/lib/config" import { flatten } from "@src/lib/itertools" import state from "@src/state" import * as Logging from "@src/lib/logging" -import { activeTabId, openInNewTab, activeTabContainerId } from "@src/lib/webext" +import { + activeTabId, + openInNewTab, + activeTabContainerId, +} from "@src/lib/webext" const logger = new Logging.Logger("dom") // From saka-key lib/dom.js, under Apachev2 @@ -44,9 +48,13 @@ export function isTextEditable(element: Element) { // ARIA stuff isn't pulled out into fields, so we have to // manually inspect the attributes to find it. - for (const attr of element.attributes) { - if (attr.name === "role" && attr.value === "application") { - return true + // Google products perform some witchcraft with it's search input as + // seen in #1031, the conditional seems to be enough to fix it. + if (element.hasOwnProperty("attributes")) { + for (const attr of element.attributes) { + if (attr.name === "role" && attr.value === "application") { + return true + } } } }