- Notifications
You must be signed in to change notification settings - Fork20.6k
Commit063831b
Attributes: Make
The HTML spec defines boolean attributes:https://html.spec.whatwg.org/#boolean-attributesthat often correlate with boolean properties. If the attribute is missing, itcorrelates with the `false` property value, if it's present - the `true`property value. The only valid values are an empty string or the attribute name.jQuery tried to be helpful here and treated boolean attributes in a special wayin the `.attr()` API:1. For the getter, as long as the attribute was present, it was returning the attribute name lowercased, ignoring the value.2. For the setter, it was removing the attribute when `false` was passed; otherwise, it was ignoring the passed value and set the attribute - interestingly, in jQuery `>=3` not lowercased anymore.The problem is the spec occasionally converts boolean attributes into ones withadditional attribute values with special behavior - one such example is the new`"until-found"` value for the `hidden` attribute. Our setter normalizationmeans passing those values is impossible with jQuery. Also, new booleanattributes are introduced occasionally and jQuery cannot easily add them to thelist without incurring breaking changes.This patch removes any special handling of boolean attributes - the getterreturns the value as-is and the setter sets the provided value.To provide better backwards compatibility with the very frequent `false` valueprovided to remove the attribute, this patch makes `false` trigger attributeremoval for ALL non-ARIA attributes. ARIA attributes are exempt from the rulesince many of them recognize `"false"` as a valid value with semantics differentthan the attribute missing. To remove an ARIA attribute, use `.removeAttr()` orpass `null` as the value to `.attr()` which doesn't have this exception.Fixesgh-5388Closesgh-5452Co-authored-by: Richard Gibson <richard.gibson@gmail.com>.attr( name, false )
remove for all non-ARIA attrs1 parentf80e78e commit063831b
3 files changed
+84
-48
lines changedLines changed: 8 additions & 30 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
38 | 38 |
| |
39 | 39 |
| |
40 | 40 |
| |
41 |
| - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
42 | 49 |
| |
43 | 50 |
| |
44 | 51 |
| |
| |||
96 | 103 |
| |
97 | 104 |
| |
98 | 105 |
| |
99 |
| - | |
100 |
| - | |
101 |
| - | |
102 |
| - | |
103 |
| - | |
104 |
| - | |
105 |
| - | |
106 |
| - | |
107 |
| - | |
108 |
| - | |
109 |
| - | |
110 |
| - | |
111 |
| - | |
112 |
| - | |
113 |
| - | |
114 |
| - | |
115 |
| - | |
116 |
| - | |
117 |
| - | |
118 |
| - | |
119 |
| - | |
120 |
| - | |
121 |
| - | |
122 |
| - | |
123 |
| - | |
124 |
| - | |
125 |
| - | |
126 |
| - | |
127 |
| - |
Lines changed: 72 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
304 | 304 |
| |
305 | 305 |
| |
306 | 306 |
| |
307 |
| - | |
| 307 | + | |
308 | 308 |
| |
309 | 309 |
| |
310 | 310 |
| |
311 | 311 |
| |
312 |
| - | |
| 312 | + | |
313 | 313 |
| |
314 | 314 |
| |
315 | 315 |
| |
| |||
318 | 318 |
| |
319 | 319 |
| |
320 | 320 |
| |
321 |
| - | |
| 321 | + | |
322 | 322 |
| |
323 | 323 |
| |
324 | 324 |
| |
| |||
345 | 345 |
| |
346 | 346 |
| |
347 | 347 |
| |
348 |
| - | |
349 |
| - | |
| 348 | + | |
| 349 | + | |
350 | 350 |
| |
351 | 351 |
| |
352 | 352 |
| |
353 | 353 |
| |
354 | 354 |
| |
355 | 355 |
| |
356 | 356 |
| |
357 |
| - | |
| 357 | + | |
358 | 358 |
| |
359 | 359 |
| |
360 | 360 |
| |
361 | 361 |
| |
362 | 362 |
| |
363 |
| - | |
| 363 | + | |
364 | 364 |
| |
365 | 365 |
| |
366 | 366 |
| |
| |||
1790 | 1790 |
| |
1791 | 1791 |
| |
1792 | 1792 |
| |
1793 |
| - | |
1794 |
| - | |
1795 |
| - | |
1796 |
| - | |
1797 |
| - | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
1798 | 1796 |
| |
1799 |
| - | |
1800 |
| - | |
| 1797 | + | |
| 1798 | + | |
1801 | 1799 |
| |
1802 | 1800 |
| |
1803 | 1801 |
| |
1804 | 1802 |
| |
1805 | 1803 |
| |
1806 | 1804 |
| |
1807 | 1805 |
| |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
1808 | 1866 |
| |
1809 | 1867 |
| |
1810 | 1868 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
948 | 948 |
| |
949 | 949 |
| |
950 | 950 |
| |
951 |
| - | |
952 |
| - | |
953 |
| - | |
954 |
| - | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
955 | 955 |
| |
956 | 956 |
| |
957 | 957 |
| |
|
0 commit comments
Comments
(0)