Bug Tracker

Modify

Ticket #9646 (closed bug: fixed)

Opened 3 years ago

Last modified 16 months ago

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

Reported by: andre.brunnsberg@… Owned by: rwaldron
Priority: low Milestone: 1.9
Component: manipulation Version: 1.6.1
Keywords: Cc:
Blocking: Blocked by:

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

comment:1 Changed 3 years ago by rwaldron

  • Owner set to andre.brunnsberg@…
  • Status changed from new to pending
  • Component changed from unfiled to manipulation

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?

comment:2 Changed 3 years ago by andre.brunnsberg@…

  • Status changed from pending to 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 3 years ago by dmethvin

  • Priority changed from undecided to 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 3 years ago by dmethvin

  • Status changed from new to open

comment:5 Changed 3 years ago by rwaldron

@dmethvin I've just run this in IE7 and it doesn't seem to be reproducing...

 http://gyazo.com/59266d566d42dcb2b8d980757e01bf2e.png

Version 0, edited 3 years ago by rwaldron (next)

comment:6 Changed 3 years ago by andre.brunnsberg@…

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

comment:7 Changed 3 years ago by rwaldron

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

comment:8 Changed 3 years ago by andre.brunnsberg@…

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

comment:9 Changed 3 years ago by rwaldron

  • Owner changed from andre.brunnsberg@… to rwaldron
  • Status changed from open to assigned

comment:10 Changed 2 years ago by scott.gonzalez

  • Summary changed from IE7: Cloning of form-elements and hanging their names also changes the name of the elements that are cloned. to IE7: Cloning of form-elements and changing their names also changes the name of the elements that are cloned.

comment:11 Changed 22 months ago by andre.brunnsberg@…

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 16 months ago by Oleg

  • Status changed from assigned to closed
  • Resolution set to fixed

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

Changeset: 13651f296d14b2400d703d1945065c0373862eb5

comment:13 Changed 16 months ago by dmethvin

  • Milestone changed from 1.next to 1.9

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.