Skip to content

Commit 202aaa6

Browse files
committed
Fix error in click-jack prevention which crashes on Firefox.
1 parent dd4596a commit 202aaa6

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11

22
# Changelog
33

4+
## Version 1.0.8
5+
6+
- Fix Firefox-compatibility issue in Gmail click-jack prevention.
7+
48
## Version 1.0.7
59

610
- Fix issues with Gmail preventing click-events on buttons registered

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gmail-js",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "JavaScript API for Gmail (useful for chrome extensions)",
55
"main": "src/gmail.js",
66
"types": "src/gmail.d.ts",

src/gmail.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,18 +2436,27 @@ var Gmail = function(localJQuery) {
24362436
api.tracker.custom_dom_observers[action] = config;
24372437
};
24382438

2439+
var getTarget = function(e) {
2440+
// firefox does not support e.path
2441+
if (e.path) {
2442+
return e.path[0];
2443+
} else {
2444+
return e.target;
2445+
}
2446+
};
24392447

2448+
// prevent gmail jacking our click-events!
24402449
var preventGmailJacking = function() {
2441-
// prevent gmail jacking our click-events!
2442-
24432450
// install event-handler only once!
24442451
if (!api.tracker.jackPreventionInstalled) {
24452452
window.addEventListener("click", (e) => {
2446-
const realTarget = e.path[0];
2447-
const gmailJsButton = realTarget.querySelector(".gmailjs");
2448-
if (gmailJsButton) {
2449-
gmailJsButton.click();
2450-
e.preventDefault();
2453+
const target = getTarget(e);
2454+
if (target) {
2455+
const gmailJsButton = target.querySelector(".gmailjs");
2456+
if (gmailJsButton) {
2457+
gmailJsButton.click();
2458+
e.preventDefault();
2459+
}
24512460
}
24522461
});
24532462
api.tracker.jackPreventionInstalled = true;

0 commit comments

Comments
 (0)