|
688 | 688 |
|
689 | 689 | });
|
690 | 690 |
|
691 |
| -</script> |
| 691 | +suite('binding corner cases', function() { |
692 | 692 |
|
693 |
| -<script> |
694 |
| - suite('binding corner cases', function() { |
| 693 | + // IE can create adjacent text nodes that split bindings; this test |
| 694 | + // ensures the code that addresses this is functional |
| 695 | + test('text binding after entity', function() { |
| 696 | + var el = document.createElement('x-entity-and-binding'); |
| 697 | + assert.equal(el.$.binding.textContent, 'binding'); |
| 698 | + }); |
695 | 699 |
|
696 |
| - // IE can create adjacent text nodes that split bindings; this test |
697 |
| - // ensures the code that addresses this is functional |
698 |
| - test('text binding after entity', function() { |
699 |
| - var el = document.createElement('x-entity-and-binding'); |
700 |
| - assert.equal(el.$.binding.textContent, 'binding'); |
701 |
| - }); |
| 700 | +}); |
702 | 701 |
|
| 702 | +suite('compound binding / string interpolation', function() { |
| 703 | + |
| 704 | + test('compound adjacent property bindings', function() { |
| 705 | + var el = document.createElement('x-basic'); |
| 706 | + assert.equal(el.$.boundChild.compound1, ''); |
| 707 | + el.cpnd2 = 'cpnd2'; |
| 708 | + assert.equal(el.$.boundChild.compound1, 'cpnd2'); |
| 709 | + el.cpnd1 = 'cpnd1'; |
| 710 | + el.cpnd3 = {prop: 'cpnd3'}; |
| 711 | + assert.equal(el.$.boundChild.compound1, 'cpnd1cpnd2cpnd3'); |
| 712 | + el.cpnd4 = 'cpnd4'; |
| 713 | + assert.equal(el.$.boundChild.compound1, 'cpnd1cpnd2cpnd3'); |
| 714 | + el.cpnd5 = 'cpnd5'; |
| 715 | + assert.equal(el.$.boundChild.compound1, 'cpnd1cpnd2cpnd3literalcpnd5cpnd4'); |
| 716 | + }); |
| 717 | + |
| 718 | + test('compound property bindings with literals', function() { |
| 719 | + var el = document.createElement('x-basic'); |
| 720 | + assert.equal(el.$.boundChild.compound2, 'literal1 literal2 literal3 literal4'); |
| 721 | + el.cpnd1 = 'cpnd1'; |
| 722 | + el.cpnd2 = 'cpnd2'; |
| 723 | + el.cpnd3 = {prop: 'cpnd3'}; |
| 724 | + el.cpnd4 = 'cpnd4'; |
| 725 | + el.cpnd5 = 'cpnd5'; |
| 726 | + assert.equal(el.$.boundChild.compound2, 'literal1 cpnd1 literal2 cpnd2cpnd3 literal3 literalcpnd5cpnd4 literal4'); |
| 727 | + el.cpnd1 = null; |
| 728 | + el.cpnd2 = undefined; |
| 729 | + el.cpnd3 = {}; |
| 730 | + el.cpnd4 = ''; |
| 731 | + el.cpnd5 = ''; |
| 732 | + assert.equal(el.$.boundChild.compound2, 'literal1 literal2 literal3 literal literal4'); |
| 733 | + }); |
| 734 | + |
| 735 | + test('compound adjacent property bindings', function() { |
| 736 | + var el = document.createElement('x-basic'); |
| 737 | + assert.equal(el.$.boundChild.getAttribute('compoundAttr1'), ''); |
| 738 | + el.cpnd2 = 'cpnd2'; |
| 739 | + assert.equal(el.$.boundChild.getAttribute('compoundAttr1'), 'cpnd2'); |
| 740 | + el.cpnd1 = 'cpnd1'; |
| 741 | + el.cpnd3 = {prop: 'cpnd3'}; |
| 742 | + assert.equal(el.$.boundChild.getAttribute('compoundAttr1'), 'cpnd1cpnd2cpnd3'); |
| 743 | + el.cpnd4 = 'cpnd4'; |
| 744 | + assert.equal(el.$.boundChild.getAttribute('compoundAttr1'), 'cpnd1cpnd2cpnd3'); |
| 745 | + el.cpnd5 = 'cpnd5'; |
| 746 | + assert.equal(el.$.boundChild.getAttribute('compoundAttr1'), 'cpnd1cpnd2cpnd3literalcpnd5cpnd4'); |
| 747 | + }); |
| 748 | + |
| 749 | + test('compound property bindings with literals', function() { |
| 750 | + var el = document.createElement('x-basic'); |
| 751 | + assert.equal(el.$.boundChild.getAttribute('compoundAttr2'), 'literal1 literal2 literal3 literal4'); |
| 752 | + el.cpnd1 = 'cpnd1'; |
| 753 | + el.cpnd2 = 'cpnd2'; |
| 754 | + el.cpnd3 = {prop: 'cpnd3'}; |
| 755 | + el.cpnd4 = 'cpnd4'; |
| 756 | + el.cpnd5 = 'cpnd5'; |
| 757 | + assert.equal(el.$.boundChild.getAttribute('compoundAttr2'), 'literal1 cpnd1 literal2 cpnd2cpnd3 literal3 literalcpnd5cpnd4 literal4'); |
| 758 | + el.cpnd1 = null; |
| 759 | + el.cpnd2 = undefined; |
| 760 | + el.cpnd3 = {}; |
| 761 | + el.cpnd4 = ''; |
| 762 | + el.cpnd5 = ''; |
| 763 | + assert.equal(el.$.boundChild.getAttribute('compoundAttr2'), 'literal1 literal2 literal3 literal literal4'); |
| 764 | + }); |
| 765 | + |
| 766 | + test('compound adjacent textNode bindings', function() { |
| 767 | + var el = document.createElement('x-basic'); |
| 768 | + assert.equal(el.$.compound1.textContent, ''); |
| 769 | + el.cpnd2 = 'cpnd2'; |
| 770 | + assert.equal(el.$.compound1.textContent, 'cpnd2'); |
| 771 | + el.cpnd1 = 'cpnd1'; |
| 772 | + el.cpnd3 = {prop: 'cpnd3'}; |
| 773 | + assert.equal(el.$.compound1.textContent, 'cpnd1cpnd2cpnd3'); |
| 774 | + el.cpnd4 = 'cpnd4'; |
| 775 | + assert.equal(el.$.compound1.textContent, 'cpnd1cpnd2cpnd3'); |
| 776 | + el.cpnd5 = 'cpnd5'; |
| 777 | + assert.equal(el.$.compound1.textContent, 'cpnd1cpnd2cpnd3literalcpnd5cpnd4'); |
| 778 | + }); |
| 779 | + |
| 780 | + test('compound textNode bindings with literals', function() { |
| 781 | + var el = document.createElement('x-basic'); |
| 782 | + assert.equal(el.$.compound2.textContent.trim(), 'literal1 literal2 literal3 literal4'); |
| 783 | + el.cpnd1 = 'cpnd1'; |
| 784 | + el.cpnd2 = 'cpnd2'; |
| 785 | + el.cpnd3 = {prop: 'cpnd3'}; |
| 786 | + el.cpnd4 = 'cpnd4'; |
| 787 | + el.cpnd5 = 'cpnd5'; |
| 788 | + assert.equal(el.$.compound2.textContent.trim(), 'literal1 cpnd1 literal2 cpnd2cpnd3 literal3 literalcpnd5cpnd4 literal4'); |
| 789 | + el.cpnd1 = null; |
| 790 | + el.cpnd2 = undefined; |
| 791 | + el.cpnd3 = {}; |
| 792 | + el.cpnd4 = ''; |
| 793 | + el.cpnd5 = ''; |
| 794 | + assert.equal(el.$.compound2.textContent.trim(), 'literal1 literal2 literal3 literal literal4'); |
703 | 795 | });
|
704 |
| -</script> |
705 | 796 |
|
| 797 | +}); |
706 | 798 |
|
| 799 | +</script> |
707 | 800 |
|
708 | 801 | </body>
|
709 | 802 | </html>
|
0 commit comments