Closed
Bug 951887
Opened 11 years ago
Closed 11 years ago
checkValidity on required input that's not in the DOM returns true because it's not considered mutable
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla30
People
(Reporter: dunbarb2, Assigned: bzbarsky)
Details
Attachments
(1 file)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Steps to reproduce:
Run the following javascript:
var input = document.createElement('input');
input.required = true;
console.log(input.checkValidity());
Actual results:
The output is 'true'.
Expected results:
The output should be 'false'.
Comment 1•11 years ago
|
||
Confirming in FF28; see this fiddle for reference: http://jsfiddle.net/MAeLA/
Updated•11 years ago
|
Component: Untriaged → DOM
Product: Firefox → Core
![]() |
Assignee | |
Comment 2•11 years ago
|
||
The spec at http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#the-required-attribute says:
Constraint validation: If the element is required, and its value IDL attribute applies
and is in the mode value, and the element is mutable, and the element's value is the
empty string, then the element is suffering from being missing.
In this case, the element is required, the value IDL attribute applies and is in mode value, the elements value is the empty string.
The spec doesn't have an actual centralized definition of "mutable". At http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#the-input-element it says:
Each input element can be mutable. Except where otherwise specified, an input element is
always mutable. Similarly, except where otherwise specified, the user agent should not
allow the user to modify the element's value or checkedness.
and then some more pieces:
When an input element is disabled, it is not mutable.
The readonly attribute is a boolean attribute that controls whether or not the user can
edit the form control. When specified, the element is not mutable.
and maybe others; it's hard to tell, since they're scattered about.
In any case, our implementation treats all elements that are not in the DOM as not mutable. That seems to date back to the original form validation checkin in bug 345822.
Mounir, do you recall why we do that?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(mounir)
Summary: checkValidity on required input → checkValidity on required input that's not in the DOM returns true because it's not considered mutable
![]() |
Assignee | |
Comment 3•11 years ago
|
||
Attachment #8386415 -
Flags: review?(bugs)
![]() |
Assignee | |
Updated•11 years ago
|
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Comment 4•11 years ago
|
||
I am pretty sure this used to be a requirement. Something like a form control outside of a document is considered as non mutable. We could ask Hixie or check the HTML spec rev log. Though, I am not sure if that requirement (being in a document) is really useful.
Updated•11 years ago
|
Flags: needinfo?(mounir)
![]() |
Assignee | |
Updated•11 years ago
|
Whiteboard: [need review]
Updated•11 years ago
|
Attachment #8386415 -
Flags: review?(bugs) → review+
![]() |
Assignee | |
Comment 5•11 years ago
|
||
Flags: in-testsuite+
Whiteboard: [need review]
![]() |
Assignee | |
Comment 6•11 years ago
|
||
And https://hg.mozilla.org/integration/mozilla-inbound/rev/e7e2197a831d to fix the preexisting tests we had for this stuff.
Comment 7•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/c0d472d6e645
https://hg.mozilla.org/mozilla-central/rev/e7e2197a831d
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•