Bug Tracker

Modify

Ticket #6470 (closed bug: duplicate)

Opened 3 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

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.

Change History

comment:1 Changed 3 years ago by addyosmani

  • Keywords css selectors added
  • Priority set to 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 3 years ago by snover

  • Keywords needsreview added

I am almost certain this is bug #7128.

comment:3 Changed 3 years ago by addyosmani

  • Keywords needsreview removed
  • Status changed from new to closed
  • Resolution set to duplicate

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 3 years ago by addyosmani

Duplicate of #7128.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.