Skip to main content

Bug Tracker

Side navigation

#1980 closed bug (wontfix)

Opened November 27, 2007 11:29PM UTC

Closed December 07, 2007 03:33AM UTC

cannot clone <html> or <body> in Safari

Reported by: tdhooper Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: clone safari body head Cc:
Blocked by: Blocking:
Description

The page below give the following error in Safari (JavaScript console):

Value undefined (result of expression ret[i].getElementsByTagName) is not object.

This happens when using either $("body").clone() or $("html").clone()

(Safari 3.0.4 tested)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title>jQuery.clone() test</title>
		
		<script src="jquery-1.2.1.min.js" type="text/javascript"> </script>
		<script type="text/javascript">
			
			$(document).ready(function(){
			

				var cloneTest = $("html").clone();
				alert(cloneTest);
				

			});
		
		</script>
	</head>
	
	<body>
		<p>test</p>
	</body>
</html>
Attachments (0)
Change History (1)

Changed December 07, 2007 03:33AM UTC by brandon comment:1

resolution: → wontfix
status: newclosed

A possible workaround might be to wrap the contents of the body with a div and clone that.

$('body').wrapInner('<div />').clone();