Fix or deprecate != attribute selector
Reported by John-David Dalton | April 16th, 2008 @ 06:41 PM | in 1.6.1
I tried this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stric...">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test</title>
<script type="text/javascript" src="prototype.js"></script>
<script>
Event.observe(window, 'load', function(){
//Example "A"
alert($$('*[id!=""]').length); //IE: 2 (offset by the IE only "dom:loaded" script insert), Firefox: 1, Safari 3.1: 1
//Example "B"
alert($$('*[id!="foo"]').length); //IE: 10 (All Elements on the page), Firefox: 1, Safari 3.1: 1
//Example "C"
alert($$(':not(div)').length); //IE: 8 (offset by the script element), Firefox: 7, Safari 3.1: 7
//Example "D"
alert($$('*[tagName!="DIV"]').length); //IE: 8 (offset by the script element), Firefox: 0, Safari 3.1: 0
});
</script>
</head>
<body>
<div id="test">Hi</div>
<a href="#">word</a>
<div>Bye</div>
</body>
</html>
Forget the inconsistency of elements based on the dom:loaded IE script insert. This ticket is not about that. I don't see that as a big deal and if we move away from that in favor of a more stable solution (see http://dev.rubyonrails.org/ticke...) it won't be an issue.
Look at Example "B" and Example "D" that is where the problem is. This is because Firfox/Safari use XPath/Selector API while IE uses the DOM only. We should probably conform these somehow.
I Had to test the negative selector in IE with Prototype 1.6.0.2 (not the recent git version because it fails some unit tests). I did use the the stable and the git versions to test Firefox/Safari 3 because it bypasses the issue via its XPath/selector API.
This issue may be resolved in the recent git, but because it errors out I cannot test it.
Comments and changes to this ticket
-
-
John-David Dalton April 16th, 2008 @ 07:37 PM
This site could be wrong, I was following there usage example:
http://www.456bereastreet.com/ar...
The fact that the other browsers return results makes me wonder how invalid ":not" is...
Isn't "!=" not officially supported? Prototype has support for it and it's inconsistent at that. So I think this ticket is valid.
-
John-David Dalton April 16th, 2008 @ 07:44 PM
http://www.w3.org/TR/css3-select...
'*:not(div)' yields the same results (but Example "C") isn't what the ticket is about.
-
Tobie Langel April 16th, 2008 @ 07:45 PM
`tagName` isn't an attribute, it's a property of the DOM element. So that's not supported.
`!=` is not a valid selector and should be deprecated in favor of `:not()`
correct syntax for `:not(div)` is `*:not(div)`.
-
John-David Dalton April 16th, 2008 @ 07:46 PM
- → Title changed from Selector results inconsistent across IE and other browsers to [DOC] Selector results inconsistent across IE and other browsers
-
John-David Dalton April 16th, 2008 @ 07:48 PM
A note about correct usage or inconsistent results would be a nice have :).
Thanks for setting me straight ;)
-
Tobie Langel April 16th, 2008 @ 10:04 PM
- → State changed from new to bug_report
- → Title changed from [DOC] Selector results inconsistent across IE and other browsers to Fix or deprecate != attribute selector
- → Assigned user changed from to Andrew Dupont
-
Andrew Dupont April 17th, 2008 @ 05:16 PM
- → Milestone changed from to 1.6.1
-
Tobie Langel April 18th, 2008 @ 01:12 PM
- → State changed from bug_report to bug
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
The Prototype JavaScript library.
