#9646 closed bug (fixed)
IE7: Cloning of form-elements and changing their names also changes the name of the elements that are cloned.
Reported by: | Owned by: | Rick Waldron | |
---|---|---|---|
Priority: | low | Milestone: | 1.9 |
Component: | manipulation | Version: | 1.6.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Check example: http://jsbin.com/akolu4/6
If the name-attribute first is accessed through the attr()-function before the element is cloned the element which is cloned also gets its name changed when the name of the cloned element is changed.
Change History (13)
comment:1 Changed 12 years ago by
Component: | unfiled → manipulation |
---|---|
Owner: | set to [email protected]… |
Status: | new → pending |
comment:2 Changed 12 years ago by
Status: | pending → new |
---|
I can reproduce it only in IE7. I have also tested it with Firefox, Chrome, IE8 and IE9, in those browsers it works fine. I now also tested it with jQuery 1.5.2 and with that version it also works fine in IE7 so this is a 1.6.x - specific bug.
comment:3 Changed 12 years ago by
Priority: | undecided → low |
---|
Yep, it's a strange one, reduced here:
http://jsfiddle.net/dmethvin/ZEuwq/
It doesn't seem to be related to the id and name being the same, as the reduced test case shows. Also strange that it *doesn't* fail in IE6, only IE7.
comment:4 Changed 12 years ago by
Status: | new → open |
---|
comment:5 Changed 12 years ago by
@dmethvin I've just run this in IE7 and it doesn't seem to be reproducing...
http://gyazo.com/59266d566d42dcb2b8d980757e01bf2e.png
EDIT: I foolishly missed the part about uncommenting a piece of code that was meant to reproduce the bug. Silly me.
comment:6 Changed 12 years ago by
Did you remember to uncomment the line that access the element's name-attribute?
comment:9 Changed 12 years ago by
Owner: | changed from [email protected]… to Rick Waldron |
---|---|
Status: | open → assigned |
Triage confirmed. http://jsfiddle.net/rwaldron/6VJbe/
comment:10 Changed 11 years ago by
Summary: | IE7: Cloning of form-elements and hanging their names also changes the name of the elements that are cloned. → IE7: Cloning of form-elements and changing their names also changes the name of the elements that are cloned. |
---|
comment:11 Changed 11 years ago by
Here is a workaround if someone stumbles on this bug. It overwrites the attr-function with a version that checks if the browser is MSIE7 (or older version) and then directly gets the name attribute from the DOM-element.
(function($) { //Make a closure of the original function var originalMethod = jQuery.fn.attr, isIE7 = (jQuery.browser.msie && jQuery.browser.version < 8); jQuery.fn.extend({ attr: function(name) { //If browser is MSIE7 (or older IE) and we are trying to get the name-attribute if (isIE7 && arguments.length === 1 && name === 'name') { var $that = jQuery(this); return ($that.length) ? $that[0].name : undefined; //Otherwise just return the original function } else { return originalMethod.apply(this, arguments); } } }); })();
comment:12 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fix #9646. Cloned nodes shouldn't affect original in IE7. Close gh-947.
Changeset: 13651f296d14b2400d703d1945065c0373862eb5
comment:13 Changed 10 years ago by
Milestone: | 1.next → 1.9 |
---|
Thanks for providing this test case, though it's not clear to me that anything unexpected is occurring. I'm viewing the test case in Chrome - is your issue browser specific?