Bug Tracker

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#10812 closed bug (fixed)

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.

Change History (8)

comment:1 Changed 5 years ago by dmethvin

  • Owner set to anonymous
  • Status changed from new to pending

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.

comment:2 in reply to: ↑ description ; follow-up: Changed 5 years ago by anonymous

  • Status changed from pending to new

comment:3 in reply to: ↑ 2 Changed 5 years ago by anonymous

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

Hope this one works.

comment:4 Changed 5 years ago by timmywil

  • Component changed from unfiled to manipulation
  • Milestone changed from None to 1.next
  • Priority changed from undecided to high
  • Status changed from new to open

comment:5 Changed 5 years ago by dmethvin

  • Milestone changed from 1.next to 1.7.1
  • Owner changed from anonymous to dmethvin
  • Status changed from open to assigned

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.

comment:6 Changed 5 years ago by anonymous

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

comment:7 Changed 5 years ago by anonymous

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.

comment:8 Changed 5 years ago by Dave Methvin

  • Resolution set to fixed
  • Status changed from assigned to closed

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

Changeset: dd845a2c0f63f97e74e4d490ee66e12e0bf180c5

Note: See TracTickets for help on using tickets.