#31404: Use HTML5 boolean attribute syntax for the multiple attribute of the select element in selector-chosen divisions. ------------------------------------------------+------------------------ Reporter: zriv | Owner: nobody Type: Cleanup/optimization | Status: new Component: Forms | Version: master Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | ------------------------------------------------+------------------------ In Django 2.1, as ticket #29041, SelectMultiple's `multiple` attribute was changed to use the HTML5 boolean attribute syntax, rather than the XHTML `multiple="multiple"` syntax. However, the `select` elements that are created by `SelectFilter2.js` for "selector-chosen" divisions still use the XHTML syntax. This mix of syntax styles can be verified by looking at the "Change user" page in the Django admin. "Available groups" and "Available user permissions" (`class="selector-available"`) use the HTML5 syntax, while "Chosen groups" and "Chosen user permissions" (`class ="selector-chosen"`) do not.
Based on previous changes to Django, I believe that this discrepancy is unintended. Therefore, this patch changes `SelectFilter2.js` to also create `multiple` attributes that use the HTML5 syntax, bringing it in line with the behavior of other parts of Django. The syntax of the test covering this change may appear somewhat convoluted at first, but this was done purposefully to avoid using jQuery's `.attr()`. When `.attr()` is called to get certain types of attributes, jQuery "normalizes" the output to hide differences between browsers. In the case of `multiple`, it appears that jQuery always returns the value "multiple" if the `multiple` attribute is present, regardless of whether `multiple` was defined as a boolean or contains a string. (You can even set `multiple` to a random string and it will still return the value "multiple".) So, to test the actual value of the `multiple` attribute, the jQuery object is first translated to the DOM element, then `getAttribute('multiple')` is called on it. As per the Django contribution documentation, I have edited the release notes, and have tried to mimic the wording of the release notes from ticket #29041. Thank you for taking the time to review this issue and pull request. Any feedback is of course greatly appreciated. -- Ticket URL: <https://code.djangoproject.com/ticket/31404> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/047.cd083bc6ee6a9bb568ddd9a89fdac361%40djangoproject.com.