Skip to main content

Bug Tracker

Side navigation

#10812 closed bug (fixed)

Opened November 17, 2011 12:14PM UTC

Closed November 17, 2011 05:05PM UTC

Last modified March 08, 2012 07:35PM UTC

passing empty object to .before() or .after() throws exception in IE7

Reported by: anonymous Owned by: dmethvin
Priority: high Milestone: 1.7.1
Component: manipulation Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:
Description

The following line:

$( '.hlist dl dl, .hlist ol ol, .hlist ul ul' )

.before( '( ' ).after( ') ' );

Throws an exception in IE7 if the the query returns empty, passing null to before() and .after(). IE8 and other browsers does not have this problem.

Attachments (0)
Change History (8)

Changed November 17, 2011 01:28PM UTC by dmethvin comment:1

owner: → anonymous
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

Changed November 17, 2011 02:33PM UTC by anonymous comment:2

status: pendingnew

Adding jFiddle: http://jsfiddle.net/5m6et/

Changed November 17, 2011 02:38PM UTC by anonymous comment:3

http://jsfiddle.net/5m6et/1/

Hope this one works.

Changed November 17, 2011 02:45PM UTC by timmywil comment:4

component: unfiledmanipulation
milestone: None1.next
priority: undecidedhigh
status: newopen

Changed November 17, 2011 03:21PM UTC by dmethvin comment:5

milestone: 1.next1.7.1
owner: anonymousdmethvin
status: openassigned

It's actually failing everywhere, you can see the console error thrown by Sizzle.error in Chrome for example. It's a simple fix so I'll get it now.

Changed November 17, 2011 03:32PM UTC by anonymous comment:6

I discovered indeed it happens in all browsers. The problem is in combination with the text passed ("( "). Passing "<span>( </span>" instead does not fail.

Changed November 17, 2011 03:48PM UTC by anonymous comment:7

It appears to happen on any combination of characters (brackets and operators) that have any meaning in javascript. "*" is especially fun... .append() and .prepend() are not affected.

The best fix is to not do anything when applied to null.

Changed November 17, 2011 05:05PM UTC by Dave Methvin comment:8

resolution: → fixed
status: assignedclosed

Fix #10812, let .before() and .after() work on empty collections.

Changeset: dd845a2c0f63f97e74e4d490ee66e12e0bf180c5