Skip to content

Commit 9168bc1

Browse files
committed
fix(tap): allow document to be tap polyfilled
Closes #9726
1 parent d252fa4 commit 9168bc1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/tap-click/tap-click.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ export class TapClick {
7272
this.lastTouchEnd = 0;
7373
this.dispatchClick = true;
7474

75+
if (this.plt.doc() === ev.target) {
76+
this.startCoord = pointerCoord(ev);
77+
return true;
78+
}
79+
7580
let activatableEle = getActivatableTarget(ev.target);
7681
if (!activatableEle) {
7782
this.startCoord = null;
@@ -97,7 +102,7 @@ export class TapClick {
97102
if (!this.startCoord) {
98103
return;
99104
}
100-
if (this.activator) {
105+
if (this.activator && ev.target !== this.plt.doc()) {
101106
let activatableEle = getActivatableTarget(ev.target);
102107
if (activatableEle) {
103108
this.activator.upAction(ev, activatableEle, this.startCoord);
@@ -133,7 +138,7 @@ export class TapClick {
133138
return;
134139
}
135140

136-
if (this.activator) {
141+
if (this.activator && this.plt.doc() !== ev.target) {
137142
// cool, a click is gonna happen, let's tell the activator
138143
// so the element can get the given "active" style
139144
const activatableEle = getActivatableTarget(ev.target);
@@ -235,7 +240,7 @@ export const isActivatable = function (ele: HTMLElement) {
235240
}
236241

237242
for (let i = 0, l = ACTIVATABLE_ATTRIBUTES.length; i < l; i++) {
238-
if (ele.hasAttribute(ACTIVATABLE_ATTRIBUTES[i])) {
243+
if (ele.hasAttribute && ele.hasAttribute(ACTIVATABLE_ATTRIBUTES[i])) {
239244
return true;
240245
}
241246
}

src/tap-click/test/tap-click.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ describe('TapClick', () => {
3535
expect( isActivatable(ele) ).toBe(true);
3636
});
3737

38+
it('should be not activatable on element without "hasAttribute" function', () => {
39+
let doc = document.createDocumentFragment();
40+
expect( isActivatable(<any>doc) ).toBe(false);
41+
});
42+
3843
});
3944

4045
});

0 commit comments

Comments
 (0)