Fix duplicate events when revert in polymer 2
Due to event retargetting, in shadow DOM, event will be fired both from the first element and the shadowroot host. Bug: Issue 11322 Change-Id: I52fbc0fac9dfdaf945dce3da0a266bfe58b0bd38
This commit is contained in:
@@ -51,19 +51,23 @@ limitations under the License.
|
||||
test('_handleConfirmTap', () => {
|
||||
const confirmHandler = sandbox.stub();
|
||||
element.addEventListener('confirm', confirmHandler);
|
||||
sandbox.stub(element, '_handleConfirmTap');
|
||||
sandbox.spy(element, '_handleConfirmTap');
|
||||
element.$$('gr-dialog').fire('confirm');
|
||||
assert.isTrue(confirmHandler.called);
|
||||
assert.isTrue(confirmHandler.calledOnce);
|
||||
assert.isTrue(element._handleConfirmTap.called);
|
||||
assert.isTrue(element._handleConfirmTap.calledOnce);
|
||||
});
|
||||
|
||||
test('_handleCancelTap', () => {
|
||||
const cancelHandler = sandbox.stub();
|
||||
element.addEventListener('cancel', cancelHandler);
|
||||
sandbox.stub(element, '_handleCancelTap');
|
||||
sandbox.spy(element, '_handleCancelTap');
|
||||
element.$$('gr-dialog').fire('cancel');
|
||||
assert.isTrue(cancelHandler.called);
|
||||
assert.isTrue(cancelHandler.calledOnce);
|
||||
assert.isTrue(element._handleCancelTap.called);
|
||||
assert.isTrue(element._handleCancelTap.calledOnce);
|
||||
});
|
||||
|
||||
test('_computeItemName function for branches', () => {
|
||||
|
@@ -56,6 +56,7 @@
|
||||
|
||||
_handleConfirmTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this._confirm();
|
||||
},
|
||||
|
||||
@@ -65,6 +66,7 @@
|
||||
|
||||
_handleCancelTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('cancel', null, {bubbles: false});
|
||||
},
|
||||
});
|
||||
|
@@ -51,19 +51,26 @@ limitations under the License.
|
||||
test('_handleConfirmTap', () => {
|
||||
const confirmHandler = sandbox.stub();
|
||||
element.addEventListener('confirm', confirmHandler);
|
||||
sandbox.stub(element, '_confirm');
|
||||
sandbox.spy(element, '_handleConfirmTap');
|
||||
sandbox.spy(element, '_confirm');
|
||||
element.$$('gr-dialog').fire('confirm');
|
||||
assert.isTrue(confirmHandler.called);
|
||||
assert.isTrue(confirmHandler.calledOnce);
|
||||
assert.isTrue(element._handleConfirmTap.called);
|
||||
assert.isTrue(element._confirm.called);
|
||||
assert.isTrue(element._confirm.called);
|
||||
assert.isTrue(element._confirm.calledOnce);
|
||||
});
|
||||
|
||||
test('_handleCancelTap', () => {
|
||||
const cancelHandler = sandbox.stub();
|
||||
element.addEventListener('cancel', cancelHandler);
|
||||
sandbox.stub(element, '_handleCancelTap');
|
||||
sandbox.spy(element, '_handleCancelTap');
|
||||
element.$$('gr-dialog').fire('cancel');
|
||||
assert.isTrue(cancelHandler.called);
|
||||
assert.isTrue(cancelHandler.calledOnce);
|
||||
assert.isTrue(element._handleCancelTap.called);
|
||||
assert.isTrue(element._handleCancelTap.calledOnce);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@@ -39,11 +39,13 @@
|
||||
|
||||
_handleConfirmTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('confirm', null, {bubbles: false});
|
||||
},
|
||||
|
||||
_handleCancelTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('cancel', null, {bubbles: false});
|
||||
},
|
||||
});
|
||||
|
@@ -49,19 +49,23 @@ limitations under the License.
|
||||
test('_handleConfirmTap', () => {
|
||||
const confirmHandler = sandbox.stub();
|
||||
element.addEventListener('confirm', confirmHandler);
|
||||
sandbox.stub(element, '_handleConfirmTap');
|
||||
sandbox.spy(element, '_handleConfirmTap');
|
||||
element.$$('gr-dialog').fire('confirm');
|
||||
assert.isTrue(confirmHandler.called);
|
||||
assert.isTrue(confirmHandler.calledOnce);
|
||||
assert.isTrue(element._handleConfirmTap.called);
|
||||
assert.isTrue(element._handleConfirmTap.calledOnce);
|
||||
});
|
||||
|
||||
test('_handleCancelTap', () => {
|
||||
const cancelHandler = sandbox.stub();
|
||||
element.addEventListener('cancel', cancelHandler);
|
||||
sandbox.stub(element, '_handleCancelTap');
|
||||
sandbox.spy(element, '_handleCancelTap');
|
||||
element.$$('gr-dialog').fire('cancel');
|
||||
assert.isTrue(cancelHandler.called);
|
||||
assert.isTrue(cancelHandler.calledOnce);
|
||||
assert.isTrue(element._handleCancelTap.called);
|
||||
assert.isTrue(element._handleCancelTap.calledOnce);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@@ -79,11 +79,13 @@
|
||||
|
||||
_handleConfirmTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('confirm', null, {bubbles: false});
|
||||
},
|
||||
|
||||
_handleCancelTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('cancel', null, {bubbles: false});
|
||||
},
|
||||
|
||||
|
@@ -53,11 +53,13 @@
|
||||
|
||||
_handleConfirmTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('confirm', null, {bubbles: false});
|
||||
},
|
||||
|
||||
_handleCancelTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('cancel', null, {bubbles: false});
|
||||
},
|
||||
|
||||
|
@@ -120,6 +120,7 @@
|
||||
|
||||
_handleConfirmTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.dispatchEvent(new CustomEvent('confirm',
|
||||
{detail: {base: this._getSelectedBase()}}));
|
||||
this._text = '';
|
||||
@@ -127,6 +128,7 @@
|
||||
|
||||
_handleCancelTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.dispatchEvent(new CustomEvent('cancel'));
|
||||
this._text = '';
|
||||
},
|
||||
|
@@ -60,11 +60,13 @@
|
||||
|
||||
_handleConfirmTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('confirm', null, {bubbles: false});
|
||||
},
|
||||
|
||||
_handleCancelTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('cancel', null, {bubbles: false});
|
||||
},
|
||||
});
|
||||
|
@@ -56,11 +56,13 @@
|
||||
|
||||
_handleConfirmTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.dispatchEvent(new CustomEvent('confirm', {bubbles: false}));
|
||||
},
|
||||
|
||||
_handleCancelTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.dispatchEvent(new CustomEvent('cancel', {bubbles: false}));
|
||||
},
|
||||
});
|
||||
|
@@ -181,6 +181,7 @@
|
||||
|
||||
_handleCloseTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('close', null, {bubbles: false});
|
||||
},
|
||||
|
||||
|
@@ -227,6 +227,7 @@
|
||||
|
||||
_handleDownloadTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.dispatchEvent(
|
||||
new CustomEvent('open-download-dialog', {bubbles: false}));
|
||||
},
|
||||
@@ -249,6 +250,7 @@
|
||||
|
||||
_handleUploadTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.dispatchEvent(
|
||||
new CustomEvent('open-upload-help-dialog', {bubbles: false}));
|
||||
},
|
||||
|
@@ -88,6 +88,7 @@
|
||||
|
||||
_handleCloseTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('close', null, {bubbles: false});
|
||||
},
|
||||
|
||||
|
@@ -77,6 +77,7 @@
|
||||
|
||||
_handleCloseTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('close', null, {bubbles: false});
|
||||
},
|
||||
|
||||
|
@@ -71,6 +71,7 @@
|
||||
|
||||
_handleCloseTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('close', null, {bubbles: false});
|
||||
},
|
||||
|
||||
|
@@ -330,6 +330,7 @@
|
||||
|
||||
_onMobileSearchTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('mobile-search', null, {bubbles: false});
|
||||
},
|
||||
|
||||
|
@@ -47,11 +47,13 @@
|
||||
|
||||
_handleConfirmTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('confirm', {reason: this.message}, {bubbles: false});
|
||||
},
|
||||
|
||||
_handleCancelTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('cancel', null, {bubbles: false});
|
||||
},
|
||||
});
|
||||
|
@@ -65,11 +65,13 @@
|
||||
if (this.disabled) { return; }
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('confirm', null, {bubbles: false});
|
||||
},
|
||||
|
||||
_handleCancelTap(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.fire('cancel', null, {bubbles: false});
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user