Skip to main content

Bug Tracker

Side navigation

#11019 closed bug (invalid)

Opened December 13, 2011 08:30PM UTC

Closed December 14, 2011 12:10AM UTC

.empty() on an empty elment deletes siblings.

Reported by: John@Irie-Inc.com Owned by:
Priority: low Milestone: None
Component: manipulation Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:
Description

Suppose you have a truly empty tag:

<span id="foo"/>

If you call $('#foo').empty() it will delete everything AFTER the span within the same parent element.

If the span is defined like this: <span id="foo"></span> then it works correctly.

Tested on Firefox 8.0.1. Tested in jQuery 1.6.1 and 1.7.1.

Here is a simple sample:

<html>

<head>

<script type="text/javascript" src="js/jquery.js"></script>

<script>

$(document).ready(function(){

$('#foo').empty();

});

</script>

</head>

<body>

<span id="foo"/>

This is after #foo.

</body>

</html>

Attachments (0)
Change History (2)

Changed December 13, 2011 09:49PM UTC by John@Irie-Inc.com comment:1

Withdrawn. Turns out, on further inspection, that Firefox is doing something other than what you would expect. It is wrapping the span around the rest of the contents of the parent object.

Changed December 14, 2011 12:10AM UTC by sindresorhus comment:2

component: unfiledmanipulation
priority: undecidedlow
resolution: → invalid
status: newclosed