Skip to main content

Bug Tracker

Side navigation

#9646 closed bug (fixed)

Opened June 22, 2011 11:30AM UTC

Closed December 13, 2012 03:08PM UTC

Last modified December 13, 2012 03:14PM UTC

IE7: Cloning of form-elements and changing their names also changes the name of the elements that are cloned.

Reported by: andre.brunnsberg@planmill.com Owned by: rwaldron
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.

Attachments (0)
Change History (13)

Changed June 22, 2011 01:26PM UTC by rwaldron comment:1

component: unfiledmanipulation
owner: → andre.brunnsberg@planmill.com
status: newpending

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?

Changed June 22, 2011 02:36PM UTC by andre.brunnsberg@planmill.com comment:2

status: pendingnew

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.

Changed June 22, 2011 03:40PM UTC by dmethvin comment:3

priority: undecidedlow

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.

Changed June 22, 2011 03:40PM UTC by dmethvin comment:4

status: newopen

Changed June 22, 2011 04:12PM UTC by rwaldron comment:5

_comment0: @dmethvin I've just run this in IE7 and it doesn't seem to be reproducing... \ \ http://gyazo.com/59266d566d42dcb2b8d980757e01bf2e.png1308767759753171

@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.

Changed June 22, 2011 05:06PM UTC by andre.brunnsberg@planmill.com comment:6

Did you remember to uncomment the line that access the element's name-attribute?

Changed June 22, 2011 06:22PM UTC by rwaldron comment:7

Ugh... why would you write a test that isn't _just_ runnable?

Changed June 22, 2011 07:44PM UTC by andre.brunnsberg@planmill.com comment:8

No idea, ask dmethvin who rewrote the test case. :-)

Changed July 12, 2011 06:22PM UTC by rwaldron comment:9

owner: andre.brunnsberg@planmill.comrwaldron
status: openassigned

Changed March 03, 2012 09:16PM UTC by scottgonzalez comment:10

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.

Changed July 03, 2012 08:50AM UTC by andre.brunnsberg@planmill.com comment:11

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);
				}
		}
	});
})();

Changed December 13, 2012 03:08PM UTC by Oleg comment:12

resolution: → fixed
status: assignedclosed

Fix #9646. Cloned nodes shouldn't affect original in IE7. Close gh-947.

Changeset: 13651f296d14b2400d703d1945065c0373862eb5

Changed December 13, 2012 03:14PM UTC by dmethvin comment:13

milestone: 1.next1.9