Removing legacy on-tap
Recommended by polymer team to remove legacy on tap for on click.
On click has better performance and is well supported by browsers.
If you register tap on gr-button, it will still work, since both click
and tap are notified when user clicks on button.
Change-Id: If683f2ca9b4a2df2270c2df8bce5da3f865f524b
(cherry picked from commit 54f8e3a273)
This commit is contained in:
committed by
Paladox none
parent
f06aefbd58
commit
081f670049
@@ -176,7 +176,7 @@ limitations under the License.
|
||||
<div class$="[[_computeClass(_expanded, showAvatar, message)]]">
|
||||
<gr-avatar account="[[author]]" image-size="100"></gr-avatar>
|
||||
<div class="contentContainer">
|
||||
<div class="author" on-tap="_handleAuthorTap">
|
||||
<div class="author" on-click="_handleAuthorClick">
|
||||
<span hidden$="[[!showOnBehalfOf]]">
|
||||
<span class="name">[[message.real_author.name]]</span>
|
||||
on behalf of
|
||||
@@ -233,7 +233,7 @@ limitations under the License.
|
||||
</span>
|
||||
</template>
|
||||
<template is="dom-if" if="[[message.id]]">
|
||||
<span class="date" on-tap="_handleAnchorTap">
|
||||
<span class="date" on-click="_handleAnchorClick">
|
||||
<gr-date-formatter
|
||||
has-tooltip
|
||||
show-date-and-time
|
||||
@@ -242,7 +242,7 @@ limitations under the License.
|
||||
</template>
|
||||
<iron-icon
|
||||
id="expandToggle"
|
||||
on-tap="_toggleExpanded"
|
||||
on-click="_toggleExpanded"
|
||||
title="Toggle expanded state"
|
||||
icon="[[_computeExpandToggleIcon(_expanded)]]">
|
||||
</span>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
listeners: {
|
||||
tap: '_handleTap',
|
||||
click: '_handleClick',
|
||||
},
|
||||
|
||||
properties: {
|
||||
@@ -163,13 +163,13 @@
|
||||
}
|
||||
},
|
||||
|
||||
_handleTap(e) {
|
||||
_handleClick(e) {
|
||||
if (this.message.expanded) { return; }
|
||||
e.stopPropagation();
|
||||
this.set('message.expanded', true);
|
||||
},
|
||||
|
||||
_handleAuthorTap(e) {
|
||||
_handleAuthorClick(e) {
|
||||
if (!this.message.expanded) { return; }
|
||||
e.stopPropagation();
|
||||
this.set('message.expanded', false);
|
||||
@@ -232,7 +232,7 @@
|
||||
return classes.join(' ');
|
||||
},
|
||||
|
||||
_handleAnchorTap(e) {
|
||||
_handleAnchorClick(e) {
|
||||
e.preventDefault();
|
||||
this.dispatchEvent(new CustomEvent('message-anchor-tap', {
|
||||
bubbles: true,
|
||||
|
||||
@@ -109,7 +109,7 @@ limitations under the License.
|
||||
hide-automated="[[_hideAutomated]]"
|
||||
project-name="[[projectName]]"
|
||||
show-reply-button="[[showReplyButtons]]"
|
||||
on-message-anchor-tap="_handleAnchorTap"
|
||||
on-message-anchor-tap="_handleAnchorClick"
|
||||
label-extremes="[[_labelExtremes]]"
|
||||
data-message-id$="[[message.id]]"></gr-message>
|
||||
</template>
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
this.handleExpandCollapse(!this._expanded);
|
||||
},
|
||||
|
||||
_handleAnchorTap(e) {
|
||||
_handleAnchorClick(e) {
|
||||
this.scrollToMessage(e.detail.id);
|
||||
},
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
},
|
||||
|
||||
listeners: {
|
||||
tap: '_handleAction',
|
||||
click: '_handleAction',
|
||||
keydown: '_handleKeydown',
|
||||
},
|
||||
|
||||
@@ -41,7 +41,11 @@ limitations under the License.
|
||||
|
||||
const addSpyOn = function(eventName) {
|
||||
const spy = sandbox.spy();
|
||||
element.addEventListener(eventName, spy);
|
||||
if (eventName == 'tap') {
|
||||
Polymer.Gestures.addListener(element, eventName, spy);
|
||||
} else {
|
||||
element.addEventListener(eventName, spy);
|
||||
}
|
||||
return spy;
|
||||
};
|
||||
|
||||
@@ -64,6 +68,8 @@ limitations under the License.
|
||||
assert.isTrue(element.$$('paper-button').disabled);
|
||||
});
|
||||
|
||||
// 'tap' event is tested so we don't loose backward compatibility with older
|
||||
// plugins who didn't move to on-click which is faster and well supported.
|
||||
for (const eventName of ['tap', 'click']) {
|
||||
test('dispatches ' + eventName + ' event', () => {
|
||||
const spy = addSpyOn(eventName);
|
||||
@@ -74,16 +80,16 @@ limitations under the License.
|
||||
|
||||
// Keycodes: 32 for Space, 13 for Enter.
|
||||
for (const key of [32, 13]) {
|
||||
test('dispatches tap event on keycode ' + key, () => {
|
||||
test('dispatches click event on keycode ' + key, () => {
|
||||
const tapSpy = sandbox.spy();
|
||||
element.addEventListener('tap', tapSpy);
|
||||
element.addEventListener('click', tapSpy);
|
||||
MockInteractions.pressAndReleaseKeyOn(element, key);
|
||||
assert.isTrue(tapSpy.calledOnce);
|
||||
});
|
||||
|
||||
test('dispatches no tap event with modifier on keycode ' + key, () => {
|
||||
test('dispatches no click event with modifier on keycode ' + key, () => {
|
||||
const tapSpy = sandbox.spy();
|
||||
element.addEventListener('tap', tapSpy);
|
||||
element.addEventListener('click', tapSpy);
|
||||
MockInteractions.pressAndReleaseKeyOn(element, key, 'shift');
|
||||
MockInteractions.pressAndReleaseKeyOn(element, key, 'ctrl');
|
||||
MockInteractions.pressAndReleaseKeyOn(element, key, 'meta');
|
||||
@@ -107,9 +113,9 @@ limitations under the License.
|
||||
|
||||
// Keycodes: 32 for Space, 13 for Enter.
|
||||
for (const key of [32, 13]) {
|
||||
test('stops tap event on keycode ' + key, () => {
|
||||
test('stops click event on keycode ' + key, () => {
|
||||
const tapSpy = sandbox.spy();
|
||||
element.addEventListener('tap', tapSpy);
|
||||
element.addEventListener('click', tapSpy);
|
||||
MockInteractions.pressAndReleaseKeyOn(element, key);
|
||||
assert.isFalse(tapSpy.called);
|
||||
});
|
||||
|
||||
@@ -244,7 +244,7 @@ limitations under the License.
|
||||
|
||||
</style>
|
||||
<div id="container" class="container">
|
||||
<div class="header" id="header" on-tap="_handleToggleCollapsed">
|
||||
<div class="header" id="header" on-click="_handleToggleCollapsed">
|
||||
<div class="headerLeft">
|
||||
<span class="authorName">[[comment.author.name]]</span>
|
||||
<span class="draftLabel">DRAFT</span>
|
||||
@@ -265,7 +265,7 @@ limitations under the License.
|
||||
on-click="_handleCommentDelete">
|
||||
(Delete)
|
||||
</gr-button>
|
||||
<span class="date" on-tap="_handleAnchorTap">
|
||||
<span class="date" on-click="_handleAnchorClick">
|
||||
<gr-date-formatter
|
||||
has-tooltip
|
||||
date-str="[[comment.updated]]"></gr-date-formatter>
|
||||
|
||||
@@ -416,7 +416,7 @@
|
||||
}, STORAGE_DEBOUNCE_INTERVAL);
|
||||
},
|
||||
|
||||
_handleAnchorTap(e) {
|
||||
_handleAnchorClick(e) {
|
||||
e.preventDefault();
|
||||
if (!this.comment.line) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user