|
26 | 26 | <script type="module">
|
27 | 27 | import './property-effects-elements.js';
|
28 | 28 | import { Polymer, html } from '../../polymer-legacy.js';
|
29 |
| -import { setSanitizeDOMValue, sanitizeDOMValue, setLegacyOptimizations } from '../../lib/utils/settings.js'; |
| 29 | +import { setSanitizeDOMValue, sanitizeDOMValue, setLegacyOptimizations, legacyUndefined, setLegacyUndefined, legacyNoBatch, setLegacyNoBatch } from '../../lib/utils/settings.js'; |
30 | 30 | import { PropertyEffects } from '../../lib/mixins/property-effects.js';
|
31 | 31 |
|
| 32 | +setLegacyUndefined(Boolean(window.location.search.match('legacyUndefined'))); |
| 33 | +setLegacyNoBatch(Boolean(window.location.search.match('legacyNoBatch'))); |
| 34 | + |
| 35 | + |
32 | 36 | suite('single-element binding effects', function() {
|
33 | 37 |
|
34 | 38 | var el;
|
|
1234 | 1238 | el.cpnd3 = {prop: 'cpnd3'};
|
1235 | 1239 | assert.equal(el.$.boundProps.prop1, 'cpnd1cpnd2cpnd3');
|
1236 | 1240 | el.cpnd4 = 'cpnd4';
|
1237 |
| - assert.equal(el.$.boundProps.prop1, 'cpnd1cpnd2cpnd3literalComputedcpnd4'); |
| 1241 | + assert.equal(el.$.boundProps.prop1, |
| 1242 | + legacyUndefined ? |
| 1243 | + 'cpnd1cpnd2cpnd3' : 'cpnd1cpnd2cpnd3literalComputedcpnd4'); |
1238 | 1244 | el.cpnd5 = 'cpnd5';
|
1239 | 1245 | assert.equal(el.$.boundProps.prop1, 'cpnd1cpnd2cpnd3literalComputedcpnd5cpnd4');
|
1240 | 1246 | });
|
|
1265 | 1271 | el.cpnd3 = {prop: 'cpnd3'};
|
1266 | 1272 | assert.equal(el.$.boundChild.getAttribute('compoundAttr1'), 'cpnd1cpnd2cpnd3');
|
1267 | 1273 | el.cpnd4 = 'cpnd4';
|
1268 |
| - assert.equal(el.$.boundChild.getAttribute('compoundAttr1'), 'cpnd1cpnd2cpnd3literalComputedcpnd4'); |
| 1274 | + assert.equal(el.$.boundChild.getAttribute('compoundAttr1'), |
| 1275 | + legacyUndefined ? |
| 1276 | + 'cpnd1cpnd2cpnd3' : 'cpnd1cpnd2cpnd3literalComputedcpnd4'); |
1269 | 1277 | el.cpnd5 = 'cpnd5';
|
1270 | 1278 | assert.equal(el.$.boundChild.getAttribute('compoundAttr1'), 'cpnd1cpnd2cpnd3literalComputedcpnd5cpnd4');
|
1271 | 1279 | });
|
|
1302 | 1310 | el.cpnd3 = {prop: 'cpnd3'};
|
1303 | 1311 | assert.equal(el.$.compound1.textContent, 'cpnd1cpnd2cpnd3');
|
1304 | 1312 | el.cpnd4 = 'cpnd4';
|
1305 |
| - assert.equal(el.$.compound1.textContent, 'cpnd1cpnd2cpnd3literalComputedcpnd4'); |
| 1313 | + assert.equal(el.$.compound1.textContent, |
| 1314 | + legacyUndefined ? |
| 1315 | + 'cpnd1cpnd2cpnd3' : 'cpnd1cpnd2cpnd3literalComputedcpnd4'); |
1306 | 1316 | el.cpnd5 = 'cpnd5';
|
1307 | 1317 | assert.equal(el.$.compound1.textContent, 'cpnd1cpnd2cpnd3literalComputedcpnd5cpnd4');
|
1308 | 1318 | // Once the binding evaluates back to '', it will in fact be ''
|
|
1770 | 1780 | customElements.define('pe-method-observer', TestClass);
|
1771 | 1781 | let el = document.createElement('pe-method-observer');
|
1772 | 1782 | document.body.appendChild(el);
|
1773 |
| - assert.equal(el.observer.callCount, 1); |
1774 |
| - assert.deepEqual(el.observer.getCall(0).args, [undefined, undefined]); |
| 1783 | + if (legacyUndefined) { |
| 1784 | + assert.equal(el.observer.callCount, 0); |
| 1785 | + } else { |
| 1786 | + assert.equal(el.observer.callCount, 1); |
| 1787 | + assert.deepEqual(el.observer.getCall(0).args, [undefined, undefined]); |
| 1788 | + } |
1775 | 1789 | assert.equal(el.pcSpy.callCount, 1);
|
1776 | 1790 | el.a = 'a';
|
1777 |
| - assert.equal(el.observer.callCount, 2); |
1778 |
| - assert.deepEqual(el.observer.getCall(1).args, ['a', undefined]); |
| 1791 | + if (legacyUndefined) { |
| 1792 | + assert.equal(el.observer.callCount, 0); |
| 1793 | + } else { |
| 1794 | + assert.equal(el.observer.callCount, 2); |
| 1795 | + assert.deepEqual(el.observer.getCall(1).args, ['a', undefined]); |
| 1796 | + } |
1779 | 1797 | assert.equal(el.pcSpy.callCount, 2);
|
1780 | 1798 | el.b = {c: 'c'};
|
1781 |
| - assert.equal(el.observer.callCount, 3); |
1782 |
| - assert.deepEqual(el.observer.getCall(2).args, ['a', 'c']); |
| 1799 | + if (legacyUndefined) { |
| 1800 | + assert.equal(el.observer.callCount, 1); |
| 1801 | + assert.deepEqual(el.observer.getCall(0).args, ['a', 'c']); |
| 1802 | + } else { |
| 1803 | + assert.equal(el.observer.callCount, 3); |
| 1804 | + assert.deepEqual(el.observer.getCall(2).args, ['a', 'c']); |
| 1805 | + } |
1783 | 1806 | assert.equal(el.pcSpy.callCount, 3);
|
1784 | 1807 | el.setProperties({
|
1785 | 1808 | a: 'A',
|
1786 | 1809 | b: {c: 'C'}
|
1787 | 1810 | });
|
1788 |
| - assert.equal(el.observer.callCount, 4); |
1789 |
| - assert.deepEqual(el.observer.getCall(3).args, ['A', 'C']); |
1790 |
| - assert.equal(el.pcSpy.callCount, 4); |
| 1811 | + if (legacyNoBatch && legacyUndefined) { |
| 1812 | + assert.equal(el.observer.callCount, 3); |
| 1813 | + assert.deepEqual(el.observer.getCall(1).args, ['A', 'c']); |
| 1814 | + assert.deepEqual(el.observer.getCall(2).args, ['A', 'C']); |
| 1815 | + assert.equal(el.pcSpy.callCount, 5); |
| 1816 | + } else if (legacyUndefined) { |
| 1817 | + assert.equal(el.observer.callCount, 2); |
| 1818 | + assert.deepEqual(el.observer.getCall(1).args, ['A', 'C']); |
| 1819 | + assert.equal(el.pcSpy.callCount, 4); |
| 1820 | + } else { |
| 1821 | + assert.equal(el.observer.callCount, 4); |
| 1822 | + assert.deepEqual(el.observer.getCall(3).args, ['A', 'C']); |
| 1823 | + assert.equal(el.pcSpy.callCount, 4); |
| 1824 | + } |
1791 | 1825 |
|
1792 | 1826 | el.observer = sinon.spy();
|
1793 | 1827 | assert.equal(el.observer.callCount, 1);
|
1794 | 1828 | assert.deepEqual(el.observer.getCall(0).args, ['A', 'C']);
|
1795 |
| - assert.equal(el.pcSpy.callCount, 5); |
| 1829 | + if (legacyNoBatch && legacyUndefined) { |
| 1830 | + assert.equal(el.pcSpy.callCount, 6); |
| 1831 | + } else { |
| 1832 | + assert.equal(el.pcSpy.callCount, 5); |
| 1833 | + } |
1796 | 1834 | document.body.removeChild(el);
|
1797 | 1835 | });
|
1798 | 1836 |
|
|
1810 | 1848 | assert.equal(el.compute.callCount, 0);
|
1811 | 1849 | assert.equal(el.pcSpy.callCount, 0);
|
1812 | 1850 | el.a = 'a';
|
1813 |
| - assert.equal(el.compute.callCount, 1); |
1814 |
| - assert.deepEqual(el.compute.getCall(0).args, ['a', undefined]); |
1815 |
| - assert.equal(el.prop, 'aundefined'); |
| 1851 | + if (legacyUndefined) { |
| 1852 | + assert.equal(el.compute.callCount, 0); |
| 1853 | + } else { |
| 1854 | + assert.equal(el.compute.callCount, 1); |
| 1855 | + assert.deepEqual(el.compute.getCall(0).args, ['a', undefined]); |
| 1856 | + assert.equal(el.prop, 'aundefined'); |
| 1857 | + } |
1816 | 1858 | assert.equal(el.pcSpy.callCount, 1);
|
1817 | 1859 | el.b = {c: 'c'};
|
1818 |
| - assert.equal(el.compute.callCount, 2); |
1819 |
| - assert.deepEqual(el.compute.getCall(1).args, ['a', 'c']); |
| 1860 | + if (legacyUndefined) { |
| 1861 | + assert.equal(el.compute.callCount, 1); |
| 1862 | + assert.deepEqual(el.compute.getCall(0).args, ['a', 'c']); |
| 1863 | + } else { |
| 1864 | + assert.equal(el.compute.callCount, 2); |
| 1865 | + assert.deepEqual(el.compute.getCall(1).args, ['a', 'c']); |
| 1866 | + } |
1820 | 1867 | assert.equal(el.prop, 'ac');
|
1821 | 1868 | assert.equal(el.pcSpy.callCount, 2);
|
1822 | 1869 | el.setProperties({
|
1823 | 1870 | a: 'A',
|
1824 | 1871 | b: {c: 'C'}
|
1825 | 1872 | });
|
1826 |
| - assert.equal(el.compute.callCount, 3); |
1827 |
| - assert.deepEqual(el.compute.getCall(2).args, ['A', 'C']); |
| 1873 | + if (legacyNoBatch && legacyUndefined) { |
| 1874 | + assert.equal(el.compute.callCount, 3); |
| 1875 | + assert.deepEqual(el.compute.getCall(1).args, ['A', 'c']); |
| 1876 | + assert.deepEqual(el.compute.getCall(2).args, ['A', 'C']); |
| 1877 | + assert.equal(el.pcSpy.callCount, 4); |
| 1878 | + } else if (legacyUndefined) { |
| 1879 | + assert.equal(el.compute.callCount, 2); |
| 1880 | + assert.deepEqual(el.compute.getCall(1).args, ['A', 'C']); |
| 1881 | + assert.equal(el.pcSpy.callCount, 3); |
| 1882 | + } else { |
| 1883 | + assert.equal(el.compute.callCount, 3); |
| 1884 | + assert.deepEqual(el.compute.getCall(2).args, ['A', 'C']); |
| 1885 | + assert.equal(el.pcSpy.callCount, 3); |
| 1886 | + } |
1828 | 1887 | assert.equal(el.prop, 'AC');
|
1829 |
| - assert.equal(el.pcSpy.callCount, 3); |
1830 | 1888 | document.body.removeChild(el);
|
1831 | 1889 | });
|
1832 | 1890 |
|
|
0 commit comments