Skip to main content

Bug Tracker

Side navigation

#6470 closed bug (duplicate)

Opened April 22, 2010 09:06AM UTC

Closed October 27, 2010 05:24AM UTC

Last modified October 27, 2010 05:24AM UTC

Inconsistencies when escaping characters in selector for <script> element

Reported by: p3k Owned by:
Priority: low Milestone: 1.4.3
Component: selector Version: 1.4.2
Keywords: css selectors Cc:
Blocked by: Blocking:
Description

I have the following HTML as an example:

<script src="foo.js?v=1"></script>
<script src="foo.js?v=2"></script>
<script src="bar.js"></script>

Using the selector

^=
to retrieve the first two <script> elements I get inconsistent results in different browsers:

Firefox 3.5.9, Safari 4.0.5 and Chrome 5.0.342.9:

$("script[src^=foo\\\\.js]").length === 2 // true and correct according to docs
$("script[src^=foo.js]").length === 0   // true and correct according to docs

Internet Explorer 8.0.6001.18702:

$("script[src^=foo\\\\.js]").length === 2 // false!
$("script[src^=foo\\\\.js]").length === 0 // true
$("script[src^=foo.js]").length === 0   // false!
$("script[src^=foo.js]").length === 2   // true

This means: to get the correct results I have to use

$("script[src^=foo.js]")
for IExplore and
$("script[src^=foo\\\\.js]")
for the other browsers.

Attachments (0)
Change History (4)

Changed October 06, 2010 08:57PM UTC by addyosmani comment:1

keywords: → css selectors
priority: → low

See here for a live test case replicating the issue in the above ticket: http://jsfiddle.net/addyosmani/puH2q/

I was able to get the correct output in IE8 and IE9 but the tests failed in IE6 and IE7.

Flagging for a further review as to the cause behind this issue.

Changed October 16, 2010 05:14AM UTC by snover comment:2

keywords: css selectorscss selectors needsreview

I am almost certain this is bug #7128.

Changed October 27, 2010 05:24AM UTC by addyosmani comment:3

keywords: css selectors needsreviewcss selectors
resolution: → duplicate
status: newclosed

Having dug deeper into #7128, I too am quite sure that it's the same issue as we're seeing in this ticket. As snover has also highlighted this concern, I am closing it as a duplicate. If for any reason we later decide they are unrelated, feel free to re-open.

Changed October 27, 2010 05:24AM UTC by addyosmani comment:4

Duplicate of #7128.