Side navigation
#12425 closed bug (invalid)
Opened August 29, 2012 07:18PM UTC
Closed September 13, 2012 09:00AM UTC
Doing attr('type', 'hidden') twice when creating a new jQuery element gives an error in IE8
Reported by: | alfatek | Owned by: | alfatek |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Doing something like this:
var form = $('#form1'); var key = 'lala'; var value = 'life goes on'; $(document.createElement('input')).attr('type', 'hidden').attr('type', 'hidden').attr('id', 'h').appendTo(form);
results in:
Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0) Timestamp: Wed, 29 Aug 2012 19:07:01 UTC Message: This command is not supported. Line: 2313 Char: 5 Code: 0 URI: http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.js
The line that causes the issue is:
elem.setAttribute( name, "" + value );
jQuery already has a "validation check" (type property can't be changed) for this normally but when using createElement the check isn't properly applied.
Test Case:
There are 3 buttons:
1) normal JS triggers the problem
2) using jquery with attr on an element just created with createElement triggers the problem
3) using jquery on an element that already exists on the page triggers the correct jquery validation check and shows a custom error message
Attachments (0)
Change History (4)
Changed August 29, 2012 07:22PM UTC by comment:1
owner: | → alfatek |
---|---|
status: | new → pending |
Changed August 29, 2012 07:30PM UTC by comment:2
status: | pending → new |
---|
My point is that, at least, using
$(document.createElement('input')).attr('type', 'hidden').attr('type', 'hidden');
or
$('#in').attr('type', 'hidden').attr('type', 'hidden');
should have the same result triggering the jQuery validation check "type property can't be changed". The first case doesn't trigger it instead triggering the browser bug.
Someone that happens to use the first example would get an IE8 specific error where one of the goals of jQuery usage is to "abstract" browser specific issues.
Changed August 29, 2012 07:39PM UTC by comment:3
status: | new → pending |
---|
Well the code there can induce the error but isn't realistic. I am assuming you were not aware of the oldIE limitation and managed to find a realistic path where this happened?
I'd actually prefer to remove the check and thrown error completely. I think this is the only place where we so specifically cripple the other browsers in the name of oldIE. When jQuery 2.0 arrives there will not be any reason to have this check.
Changed September 13, 2012 09:00AM UTC by comment:4
resolution: | → invalid |
---|---|
status: | pending → closed |
Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!
So it sounds like you understand the problem. Why are you creating an unrealistic test case to induce it? What resolution are you advocating?