Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#9618 closed bug (wontfix)

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

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 (2)

comment:1 Changed 8 years ago by dmethvin

Component: unfiledselector
Priority: undecidedlow
Resolution: wontfix
Status: newclosed

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 8 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!

Note: See TracTickets for help on using tickets.