Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed: e.matches: null check #1196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions content_scripts/hints.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ function createHints() {
elements = filterInvisibleElements(cssSelector);
} else {
elements = getVisibleElements(function (e, v) {
if (e.matches(cssSelector) && !e.disabled && !e.readOnly) {
if (e && e.matches(cssSelector) && !e.disabled && !e.readOnly) {
v.push(e);
}
});
Expand Down Expand Up @@ -489,7 +489,7 @@ function createHints() {
var cssSelector = "input";

var elements = getVisibleElements(function(e, v) {
if (e.matches(cssSelector) && !e.disabled && !e.readOnly
if (e && e.matches(cssSelector) && !e.disabled && !e.readOnly
&& (e.type === "text" || e.type === "search" || e.type === "password")) {
v.push(e);
}
Expand All @@ -498,7 +498,7 @@ function createHints() {
if (elements.length === 0 && document.querySelector(cssSelector) !== null) {
document.querySelector(cssSelector).scrollIntoView();
elements = getVisibleElements(function(e, v) {
if (e.matches(cssSelector) && !e.disabled && !e.readOnly) {
if (e && e.matches(cssSelector) && !e.disabled && !e.readOnly) {
v.push(e);
}
});
Expand Down
8 changes: 6 additions & 2 deletions content_scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ function isElementVisible(elm) {
}

function isElementClickable(e) {
if (!e) {
return false;
}

var cssSelector = "a, button, select, input, textarea, summary, *[onclick], *[contenteditable=true], *.jfk-button, *.goog-flat-menu-button, *[role=button], *[role=link], *[role=menuitem], *[role=option], *[role=switch], *[role=tab], *[role=checkbox], *[role=combobox], *[role=menuitemcheckbox], *[role=menuitemradio]";
if (runtime.conf.clickableSelector.length) {
cssSelector += ", " + runtime.conf.clickableSelector;
Expand Down Expand Up @@ -254,9 +258,9 @@ function filterOverlapElements(elements) {
// filter out tiny elements
elements = elements.filter(function(e) {
var be = getRealRect(e);
if (e.disabled || e.readOnly || !isElementDrawn(e, be)) {
if (e && (e.disabled || e.readOnly || !isElementDrawn(e, be))) {
return false;
} else if (e.matches("input, textarea, select, form") || e.contentEditable === "true") {
} else if (e && (e.matches("input, textarea, select, form") || e.contentEditable === "true")) {
return true;
} else {
var el = document.elementFromPoint(be.left + 3, be.top + 3);
Expand Down