Merge pull request #1136 from antonva/fix-1031

Add element property check to fix google product search bars.
This commit is contained in:
Oliver Blanthorn 2018-11-02 11:15:27 +00:00 committed by GitHub
commit de9fc2d4b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}
}
}
}