Skip to main content

Bug Tracker

Side navigation

#9416 closed bug (duplicate)

Opened May 24, 2011 08:56PM UTC

Closed May 24, 2011 10:45PM UTC

Last modified March 14, 2012 06:24AM UTC

Clone() function is not able to parse a form within a form properly in IE7 - 9

Reported by: jjcrist@gmail.com Owned by: jjcrist@gmail.com
Priority: low Milestone: 1.next
Component: manipulation Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:
Description

The following code illustrates the issue.

Note: This is particularly an issue with ASP.NET Forms, where all pages generated are surrounded with a form. IF the user has a form within the asp page, they are likely to have a similar issue.


<!DOCTYPE>

<html>
<head> 
    <!-- 
    OVERVIEW: jquery 1.5.0 Clone() function is not able to parse a form within a form properly in IE7 - 9 (not tested in IE6)
    INSTRUCTIONS: Change the jquery version to 1.5.0 to see the issue and compare it with 1.4.4
    latest version doesn't work <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js" type="text/javascript"></script>
    1st version that introduces issue <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.js" type="text/javascript"></script>
    
    ERROR:
    Message: 'nodeType' is null or not an object
    Line: 5332
    Char: 2
    Code: 0
    URI: https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.js
    -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.js" type="text/javascript"></script>
</head>

<body>
<form><!--comment out this form tag to see it work properly with the newer jquery versions-->
    <a href="" class="a">Print</a>
    <div id="contents">

        <form></form>
        <div></div>
    </div>
    <textarea id="y" cols="50" rows="20"></textarea>
    <textarea id="z" cols="50" rows="20"></textarea>
</form><!--comment out this form tag to see it work properly with the newer jquery versions-->
  <script>
      $("a.a").click(function(e) {
          e.preventDefault();
          $('#y').val($('#contents').html());
          $('#z').val($('#contents').clone().html());
      });
  </script>
</body>

</html>

Attachments (0)
Change History (8)

Changed May 24, 2011 09:07PM UTC by anonymous comment:1

Like I mentioned in the comments of the code, this is not an issue in jquery v1.4.4. It was introduced in v1.5.0 and is still an issue in v1.6.1.

Changed May 24, 2011 09:49PM UTC by timmywil comment:2

component: unfiledmanipulation
owner: → jjcrist@gmail.com
priority: undecidedlow
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced test case on http://jsfiddle.net that reproduces the issue experienced to help us assess your ticket.

Additionally, test against the jQuery (edge) version to ensure the issue still exists.

Changed May 24, 2011 09:59PM UTC by rwaldron comment:3

Wait, in the demo it says newer jQuery versions work?

Changed May 24, 2011 10:15PM UTC by anonymous comment:4

Replying to [comment:3 rwaldron]:

Wait, in the demo it says newer jQuery versions work?

Not sure what you are referring to. I said in numerous places that jQuery v1.5.0 and up do not work with the example code attached to this ticket.

jQuery 1.4.4 will work. Therefore, the issue was introduced in v1.5.0.

I hope this clears things up :)

Changed May 24, 2011 10:29PM UTC by anonymous comment:5

Here is the code running in jsfiddle.net (jquery v1.6):

http://jsfiddle.net/6Cm3y/2/

  • click the 'Print' link to view how the results using the html() function compared to the clone() function.

Notice it's working for the html() function but the clone() function returns an error. Again, this was produced using IE 7 - 9.

Here it is using the jquery (edge):

http://jsfiddle.net/6Cm3y/3/

Notice it is still not working.

Changed May 24, 2011 10:43PM UTC by rwaldron comment:6

Changed May 24, 2011 10:45PM UTC by rwaldron comment:7

resolution: → duplicate
status: pendingclosed

See also: #8086

Changed May 24, 2011 10:45PM UTC by rwaldron comment:8

Duplicate of #6894.