[Django] #31404: Use HTML5 boolean attribute syntax for the multiple attribute of the select element in selector-chosen divisions.

5 views
Skip to first unread message

Django

unread,
Mar 26, 2020, 6:52:14 AM3/26/20
to django-...@googlegroups.com
#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.

Django

unread,
Mar 26, 2020, 6:58:32 AM3/26/20
to django-...@googlegroups.com
#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 | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

[https://github.com/django/django/pull/12631 PR] — Thanks for the patch.
Seems reasonable. Will Accept to review. 👍

--
Ticket URL: <https://code.djangoproject.com/ticket/31404#comment:1>

Django

unread,
Mar 26, 2020, 7:01:35 AM3/26/20
to django-...@googlegroups.com
#31404: Use HTML5 boolean attribute syntax for the multiple attribute of the select
element in selector-chosen divisions.
-------------------------------------+-------------------------------------
Reporter: zriv | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by zriv):

* stage: Accepted => Unreviewed


Comment:

[https://github.com/django/django/pull/12631 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/31404#comment:2>

Django

unread,
Mar 26, 2020, 7:01:50 AM3/26/20
to django-...@googlegroups.com
#31404: Use HTML5 boolean attribute syntax for SelectMultiple's multiple attribute
created by SelectFilter2.js.
--------------------------------------+------------------------------------
Reporter: zriv | Owner: zriv
Type: Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* owner: nobody => zriv
* status: new => assigned
* component: Forms => contrib.admin


* stage: Unreviewed => Accepted


Comment:

[https://github.com/django/django/pull/12631 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/31404#comment:3>

Django

unread,
Mar 27, 2020, 3:41:07 AM3/27/20
to django-...@googlegroups.com
#31404: Use HTML5 boolean attribute syntax for SelectMultiple's multiple attribute
created by SelectFilter2.js.
-------------------------------------+-------------------------------------
Reporter: zriv | Owner: zriv
Type: | Status: assigned
Cleanup/optimization |

Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/31404#comment:4>

Django

unread,
Mar 27, 2020, 4:10:46 AM3/27/20
to django-...@googlegroups.com
#31404: Use HTML5 boolean attribute syntax for SelectMultiple's multiple attribute
created by SelectFilter2.js.
-------------------------------------+-------------------------------------
Reporter: zriv | Owner: zriv
Type: | Status: closed

Cleanup/optimization |
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"b9336b78cf2a9a29f4934041c9e221bc68daec80" b9336b7]:
{{{
#!CommitTicketReference repository=""
revision="b9336b78cf2a9a29f4934041c9e221bc68daec80"
Fixed #31404 -- Changed selector-chosen's multiple attribute to HTML5
boolean syntax.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31404#comment:5>

Reply all
Reply to author
Forward
0 new messages