Bug Tracker

Opened 14 years ago

Closed 12 years ago

#3450 closed bug (invalid)

contains selector using non-breaking space doesn't work in IE7

Reported by: lancetek Owned by: flesler
Priority: minor Milestone: 1.3
Component: selector Version: 1.2.6
Keywords: non-breaking space,   Cc:
Blocked by: Blocking:

Description

JQuery fails to select a td element that contains a non-breaking space, for IE7.

eg: $('td:contains(" ")').addClass("otherTest");

This functionality works fine in Firefox 3.

Attachments (1)

test-3450.html (849 bytes) - added by dmethvin 13 years ago.
Shows diff btwn .innerText and .text()

Download all attachments as: .zip

Change History (4)

comment:1 Changed 13 years ago by dmethvin

Component: unfilledselector

comment:2 Changed 13 years ago by dmethvin

I cannot create any test using Firefox or IE that selects something with :contains(" ") and I am not convinced it should work anyway. The contains argument looks at the element's text (using .textContent or .innerText). The selector string is handled by Javascript and so doesn't get HTML entities processed.

If anything, the selector should be :contains("\u00a0") and that does work on Firefox. However, it still does not work in IE7 or IE8. The problem is that IE's .innerText property returns the non-breaking space as \u0020 instead of \u00a0, and that is what Sizzle tries first.

One fix would be to use Sizzle's getText function instead of trying innerText at all, but that could be significantly slower.

Changed 13 years ago by dmethvin

Attachment: test-3450.html added

Shows diff btwn .innerText and .text()

comment:3 Changed 12 years ago by snover

Resolution: invalid
Status: newclosed

The ticket as described is invalid because :contains functions on text content, not HTML.

Note: See TracTickets for help on using tickets.