|
615 | 615 | }); |
616 | 616 | }); |
617 | 617 |
|
618 | | - test('disabled elements don\'t fire taps', function() { |
619 | | - let el = document.createElement('x-disabled-tap'); |
620 | | - document.body.appendChild(el); |
621 | | - // tap an element with disabled attribute |
622 | | - let target = el.$.disabled; |
623 | | - // simulate the event sequence of a touch on the screen |
624 | | - let touches = [{ |
625 | | - clientX: 0, |
626 | | - clientY: 0, |
627 | | - identifier: 1, |
628 | | - // target is set to the element with `addEventListener`, which is `target` |
629 | | - target |
630 | | - }]; |
631 | | - let touchstart = new CustomEvent('touchstart', {bubbles: true, composed: true}); |
632 | | - touchstart.changedTouches = touchstart.touches = touches; |
633 | | - target.dispatchEvent(touchstart); |
634 | | - let touchend = new CustomEvent('touchend', {bubbles: true, composed: true}); |
635 | | - touchend.touches = touchend.changedTouches = touches; |
636 | | - target.dispatchEvent(touchend); |
637 | | - assert.equal(el.taps.length, 0); |
638 | | - // tap an element with a disabled ancestor |
639 | | - target = el.$.nested; |
640 | | - // simulate the event sequence of a touch on the screen |
641 | | - touches = [{ |
642 | | - clientX: 0, |
643 | | - clientY: 0, |
644 | | - identifier: 1, |
645 | | - // target is set to the element with `addEventListener`, which is `target` |
646 | | - target |
647 | | - }]; |
648 | | - touchstart = new CustomEvent('touchstart', {bubbles: true, composed: true}); |
649 | | - touchstart.changedTouches = touchstart.touches = touches; |
650 | | - target.dispatchEvent(touchstart); |
651 | | - touchend = new CustomEvent('touchend', {bubbles: true, composed: true}); |
652 | | - touchend.touches = touchend.changedTouches = touches; |
653 | | - target.dispatchEvent(touchend); |
654 | | - assert.equal(el.taps.length, 1); |
655 | | - document.body.removeChild(el); |
| 618 | + suite('disabled', function() { |
| 619 | + test('click() function works as expected on disabled elements', function() { |
| 620 | + Polymer.Gestures.resetMouseCanceller(); |
| 621 | + let el = document.createElement('x-disabled-tap'); |
| 622 | + document.body.appendChild(el); |
| 623 | + el.$.disabled.click(); |
| 624 | + el.$.nested.click(); |
| 625 | + el.$.disabledEl.click(); |
| 626 | + assert.deepEqual(el.taps, ['button#nested', 'x-disabled#disabledEl']); |
| 627 | + document.body.removeChild(el); |
| 628 | + }); |
| 629 | + |
| 630 | + test('disabled elements don\'t fire taps', function() { |
| 631 | + let el = document.createElement('x-disabled-tap'); |
| 632 | + document.body.appendChild(el); |
| 633 | + // tap an element with disabled attribute |
| 634 | + let target = el.$.disabled; |
| 635 | + // simulate the event sequence of a touch on the screen |
| 636 | + let touches = [{ |
| 637 | + clientX: 0, |
| 638 | + clientY: 0, |
| 639 | + identifier: 1, |
| 640 | + // target is set to the element with `addEventListener`, which is `target` |
| 641 | + target |
| 642 | + }]; |
| 643 | + let touchstart = new CustomEvent('touchstart', {bubbles: true, composed: true}); |
| 644 | + touchstart.changedTouches = touchstart.touches = touches; |
| 645 | + target.dispatchEvent(touchstart); |
| 646 | + let touchend = new CustomEvent('touchend', {bubbles: true, composed: true}); |
| 647 | + touchend.touches = touchend.changedTouches = touches; |
| 648 | + target.dispatchEvent(touchend); |
| 649 | + assert.deepEqual(el.taps, []); |
| 650 | + |
| 651 | + // tap an element with a disabled ancestor |
| 652 | + target = el.$.nested; |
| 653 | + // simulate the event sequence of a touch on the screen |
| 654 | + touches = [{ |
| 655 | + clientX: 0, |
| 656 | + clientY: 0, |
| 657 | + identifier: 1, |
| 658 | + // target is set to the element with `addEventListener`, which is `target` |
| 659 | + target |
| 660 | + }]; |
| 661 | + touchstart = new CustomEvent('touchstart', {bubbles: true, composed: true}); |
| 662 | + touchstart.changedTouches = touchstart.touches = touches; |
| 663 | + target.dispatchEvent(touchstart); |
| 664 | + touchend = new CustomEvent('touchend', {bubbles: true, composed: true}); |
| 665 | + touchend.touches = touchend.changedTouches = touches; |
| 666 | + target.dispatchEvent(touchend); |
| 667 | + assert.deepEqual(el.taps, ['button#nested']); |
| 668 | + |
| 669 | + // tap a custom element with a `disabled` property |
| 670 | + target = el.$.disabledEl; |
| 671 | + // simulate the event sequence of a touch on the screen |
| 672 | + touches = [{ |
| 673 | + clientX: 0, |
| 674 | + clientY: 0, |
| 675 | + identifier: 1, |
| 676 | + // target is set to the element with `addEventListener`, which is `target` |
| 677 | + target |
| 678 | + }]; |
| 679 | + touchstart = new CustomEvent('touchstart', {bubbles: true, composed: true}); |
| 680 | + touchstart.changedTouches = touchstart.touches = touches; |
| 681 | + target.dispatchEvent(touchstart); |
| 682 | + touchend = new CustomEvent('touchend', {bubbles: true, composed: true}); |
| 683 | + touchend.touches = touchend.changedTouches = touches; |
| 684 | + target.dispatchEvent(touchend); |
| 685 | + assert.deepEqual(el.taps, ['button#nested', 'x-disabled#disabledEl']); |
| 686 | + document.body.removeChild(el); |
| 687 | + }); |
| 688 | + |
| 689 | + test('test all "disablable" elements', function() { |
| 690 | + const el = document.createElement('all-disabled'); |
| 691 | + document.body.appendChild(el); |
| 692 | + el.tapAll(); |
| 693 | + assert.deepEqual(el.taps, ['div']); |
| 694 | + document.body.removeChild(el); |
| 695 | + }) |
656 | 696 | }); |
657 | 697 | }); |
658 | 698 | </script> |
|
0 commit comments