Modify ↓
Ticket #1980 (closed bug: wontfix)
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: | |
| Blocking: | Blocked by: |
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>
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

A possible workaround might be to wrap the contents of the body with a div and clone that.
$('body').wrapInner('<div />').clone();