Bug Tracker

Modify

Ticket #9618 (closed bug: wontfix)

Opened 2 years ago

Last modified 2 years ago

invalid attribute selector works in IE9 when it should fail

Reported by: WanderingZombie Owned by:
Priority: low Milestone: 1.next
Component: selector Version: 1.6.1
Keywords: Cc:
Blocking: Blocked by:

Description

<html>
<body>
<div id="stoprId_1"></div>
<div id="stoprId_2"></div>
<div id="stoprId_3"></div>
</body>
</html>

$(document).ready(function(){
alert($('[id^="stoprId_"').length +"-"+
$('[id^="stoprId_"]').length);
});

will show 3-3 in IE9 and 0-3 in Firefox. jQuery is not behaving in a consistent manner

See  http://jsfiddle.net/WanderingZombie/vMNau/

Change History

comment:1 follow-up: ↓ 2 Changed 2 years ago by dmethvin

  • Priority changed from undecided to low
  • Resolution set to wontfix
  • Status changed from new to closed
  • Component changed from unfiled to selector

This was reported before, although I can't find the ticket. IE9 is trying to be helpful I suppose and auto-adds a closing bracket when it should be throwing an error.

Since the selector in question isn't valid, and since we're passing it to querySelectorAll for processing, I don't think it's productive to try and address this in jQuery merely to get an error thrown. You could file a report against IE to get the bug fixed, but that's most likely futile.

comment:2 in reply to: ↑ 1 Changed 2 years ago by WanderingZombie

Replying to dmethvin:

This was reported before, although I can't find the ticket. IE9 is trying to be helpful I suppose and auto-adds a closing bracket when it should be throwing an error.

Yes, but jQuery should surely have checked that the selector syntax was correct before attempting to process it and at that point returned the same consistent value regardless of browser.

Since the selector in question isn't valid, and since we're passing it to querySelectorAll for processing, I don't think it's productive to try and address this in jQuery merely to get an error thrown. You could file a report against IE to get the bug fixed, but that's most likely futile.

If jQuery behaved consistently across all browsers I could be persuaded to agree, however the invalid syntax does not conform to documented jQuery syntax and should thefore result in a jQuery error of some sort. Not doing so means that jQuery cannot be trusted to work reliably cross browser which after all is THE major benefit of using jQuery!

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.