Bug Tracker

Opened 10 years ago

Closed 9 years ago

#6261 closed bug (fixed)

clone(false) inserts empty nodes in IE

Reported by: Eddie Owned by:
Priority: low Milestone:
Component: manipulation Version: 1.4.2
Keywords: clone true false ie insert inserts blank Cc:
Blocked by: Blocking:

Description

$('#myElement').clone(false) inserts empty nodes in IE while $('#myElement').clone(true) doesn't.

An example:

<ul id="myElement">
	<li><span>Test</span><div>&nbsp;</div></li>
</ul>

$('#myElement').clone(true) will end up in:

<ul id="myElement">
	<li><span>Test</span><div>&nbsp;</div></li>
</ul>

$('#myElement').clone(false) will end up in:

<ul id="myElement">
	<li><span>Test</span> <div>&nbsp;</div></li>
</ul>

Mark the space directly after the closing </span>. This will mess up certain designs in IE 8 (and maybe others). See attached Screenshots.

Attachments (3)

clone_true.png (2.5 KB) - added by Eddie 10 years ago.
clone(true) in IE 8
clone_false.png (2.5 KB) - added by Eddie 10 years ago.
clone(false) in IE 8
test-6261.html (388 bytes) - added by dmethvin 9 years ago.

Download all attachments as: .zip

Change History (7)

Changed 10 years ago by Eddie

Attachment: clone_true.png added

clone(true) in IE 8

Changed 10 years ago by Eddie

Attachment: clone_false.png added

clone(false) in IE 8

comment:1 Changed 9 years ago by dmethvin

Component: unfiledmanipulation

comment:2 Changed 9 years ago by dmethvin

Priority: undecided

I get the same behavior with an extraneous text node, regardless of whether .clone() is called with true or false. In the clone code you can see that this.outerHTML is returning markup with the extra spaces. This probably isn't fixable unless we find a solution that doesn't involve outerHTML.

Changed 9 years ago by dmethvin

Attachment: test-6261.html added

comment:3 Changed 9 years ago by SlexAxton

Milestone: 1.4.31.5
Priority: undecidedlow
Status: newopen

comment:4 Changed 9 years ago by danheberden

Resolution: fixed
Status: openclosed

No longer an issue in 1.5 - http://jsfiddle.net/danheberden/kaa8D/

Last edited 9 years ago by danheberden (previous) (diff)
Note: See TracTickets for help on using tickets.