Skip to main content

Bug Tracker

Side navigation

#4417 closed bug (duplicate)

Opened March 25, 2009 06:12AM UTC

Closed November 22, 2010 05:19AM UTC

Last modified March 14, 2012 02:14PM UTC

problem with attribute name when clone in IE7

Reported by: boneazul Owned by:
Priority: low Milestone: 1.5
Component: manipulation Version: 1.3.2
Keywords: clone attribute Cc:
Blocked by: Blocking:
Description

there is a problem in IE7 when clone elements, after change name elements .

I want to clone a tr element ,but clone in FF and IE7 show diferents results look the example

Attachments (5)
  • clone_function_upgraded.js (2.6 KB) - added by boneazul March 27, 2009 07:16PM UTC.

    new clone method

  • jquery.js (118.8 KB) - added by boneazul March 27, 2009 07:17PM UTC.

    jquery1.3.2 with method clone modified

  • jquery_close.html (0.4 KB) - added by boneazul March 25, 2009 06:12AM UTC.
  • test_v2.HTML (4.1 KB) - added by jerone March 27, 2009 11:00PM UTC.

    test v2

  • teste.HTML (0.9 KB) - added by boneazul March 27, 2009 07:18PM UTC.

    test case .html

Change History (16)

Changed March 25, 2009 06:22AM UTC by boneazul comment:1

alert test in FF3 shows me <td><input id="test" name="a[]"></td>

when in IE7 shows me <td><input id=test name=a></td>

is this a bug??

Changed March 25, 2009 02:26PM UTC by jerone comment:2

IE7 is correct here; as W3C says

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits (![0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

Changed March 25, 2009 04:05PM UTC by boneazul comment:3

the problem is not in the name with especial caracters.

Change the concat "[]" to another letter like "b" in this script the same problem is detected follow this code

<html>

<head>

<title></title>

<meta content="">

<style></style>

<script src="http://code.jquery.com/jquery-latest.js"></script>

<script>

$(function(){

this point we concat the name white letter b (W3C says that is

not wrong) ok?

$("#test").attr('name',$("#test").attr('name')+"b");

Now we clone the line

var obj_tr_clone=$("#line").clone(true);

Show html clone

alert(obj_tr_clone.html());

});

</script>

</head>

<body>

<table>

<tr id="line">

<td><input id="test" name="a"></td>

</tr>

</table>

</body>

</html>

In fact what happened .

1 - We change the name "a" to "ab"

2- Clone the line

3 - Alert the html clone

FF is ok because he shows me the new name in alert -> "ab"

"<td><input id="test" name="ab"></td>"

but in IE7 he shows me the old name in alert -> "a"

and don't change the name (its wrong as i can see)

why he don't change the name???

"<td><input id=test name=a></td>"

who is wrong ?? the method clone()?? the method html()?? or IE7??

sorry about my poor english..

Changed March 25, 2009 10:15PM UTC by boneazul comment:4

IE copies events bound via attachEvent when

using cloneNode. Calling detachEvent on the

clone will also remove the events from the orignal

In order to get around this, we use innerHTML.

Unfortunately, this means some modifications to

attributes in IE that are actually only stored

as properties will not be copied (such as the

the name attribute on an input).

i found it in script jquery.js

the problem looks like in IE7 Unfortunately

i'm right??

Changed March 26, 2009 02:13AM UTC by dmethvin comment:5

Yes, this looks like it has also been reported in a slightly different situation in ticket #4422. It seems like IE is stripping off the quotes and that is causing some bizarre problems.

Changed March 26, 2009 04:48AM UTC by boneazul comment:6

i found the problem....

in fact jquery use outerHTML to clone the html element

and IE7 respond with the first html rended(why??i don't now)

example

if you render first

<input type="text" name="a" id="aa"> and change any attribute via javascript after dom loaded like (name,id) or any framework javascript will not be correct avaiable in outerHTML method

html always will be cloned as <input type="text" name="a" id="aa">

same as any attribute be modified

however a way to fix it, is upgrade method clone in jquery to find all childs inside outerHTML and replace this attibutes like (name,id,size,...) to real values .there is possible and it is easy to do.I will write a pseudo code then workaround this ..and suggest to core jquery to fix this problem.

and pray to IE fix it.. :)

Changed March 26, 2009 02:37PM UTC by jerone comment:7

Maybe it's an idea to temporary store these attributes before cloning and attach them after.

Changed March 27, 2009 07:14PM UTC by boneazul comment:8

ok i'm here again...

i wrote a little code upgrading method clone in jquery core to fix the problem with name in IE6 + that not suport jQuery.support.noCloneEvent

and i would like ask you to test the code..

works fine in the diferents test cases..

if you want to update or upgrade the code to some more simple or generic thats ok...

just give me the credits.. :)

@Jonatan de Sá Lemes - Brazil

i guess then i solvet it in 14 lines to aggregate in core function ...

the codes and tests cases is attached

Changed March 27, 2009 10:59PM UTC by jerone comment:9

I did some testing of your script and it seems it works great.

The only problem with it was that it worked with browser identification, which is a big no in jQuery.

I've come up with a support solution that checks if the browser has support for special characters in attributes (name).

I've updated your test file with the new function.

Hope it gets approved.

Changed March 31, 2009 01:03AM UTC by boneazul comment:10

now it's great.Thank you for you helping. i did some another tests and the problem doens't happen with another attributes like id,size,etc just with name attribute..very strange..: ) .it's ok now.

this change will be applied in jquery clone method v1.3.3 ???

i hope so.if not thank you.help'm a lot.

Changed January 22, 2010 07:11AM UTC by vishvananda comment:11

this is still causing issues with trailing slashes in action parameters of forms. Is there a decent workaround? For now I'm adding the action after I clone the form

Changed June 12, 2010 02:04PM UTC by dmethvin comment:12

component: unfiledmanipulation

Changed September 24, 2010 12:16PM UTC by grjasewe comment:13

It is a problem for struts2-jquery-grid. See http://www.trirand.com/blog/?page_id=393/help/multiple-search-multiple-criteria-same-field/#p19979. Any more news on a resoultion for this bug?

Changed October 23, 2010 09:47PM UTC by SlexAxton comment:14

keywords: → clone attribute
milestone: 1.41.5
priority: majorlow
status: newopen

Changed November 22, 2010 05:19AM UTC by snover comment:15

resolution: → duplicate
status: openclosed

This ticket is confusing. Closing as a duplicate of the much clearer #6236.

Changed November 22, 2010 05:19AM UTC by snover comment:16

Duplicate of #6236.