Bug Tracker

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#6470 closed bug (duplicate)

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:


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.

Change History (4)

comment:1 Changed 12 years ago by addyosmani

Keywords: css selectors added
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.

comment:2 Changed 12 years ago by snover

Keywords: needsreview added

I am almost certain this is bug #7128.

comment:3 Changed 12 years ago by addyosmani

Keywords: needsreview removed
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.

comment:4 Changed 12 years ago by addyosmani

Duplicate of #7128.

Note: See TracTickets for help on using tickets.