Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 9ff610d

Browse files
author
Gabriel Schulhof
committed
Checkboxradio: Retrieve form ID via .getAttribute()
Closes gh-7224 Fixes gh-7223
1 parent a9d37be commit 9ff610d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

js/widgets/forms/checkboxradio.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ $.widget( "mobile.checkboxradio", $.extend( {
196196

197197
// If we're inside a form
198198
if ( form ) {
199-
formId = form.id;
199+
formId = form.getAttribute( "id" );
200200

201201
// If the form has an ID, collect radios scattered throught the document which
202202
// nevertheless are part of the form by way of the value of their form attribute

tests/unit/checkboxradio/input-set-tests.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
<div data-nstest-role="page">
3333
<label>Radio<input id="radio:1" type="radio" name="group1"></label>
3434
<form id="the-[form]">
35+
<!--
36+
https://github.com/jquery/jquery-mobile/issues/7223
37+
Adding the below hidden input will cause code that accesses the form attribute via
38+
form.id to return this input, rather than the ID of the form. The presence of this
39+
input constitutes a test against that kind of code. The correct way to retrieve the
40+
id of a form is form.getAttribute( "id" ).
41+
-->
42+
<input type="hidden" name="id" value="">
3543
<label>Radio<input id="radio:2" type="radio" name="group1"></label>
3644
<label>Radio<input id="radio:7" type="radio" name="group1" form="the-'other'-form"></label>
3745
</form>

0 commit comments

Comments
 (0)