QSA--buggy in lots of browsers?

D

David Mark

Having recently added an experimental QSA add-on for My Library, I have
been warned that QSA is a bear cross-browser. I don't doubt that, but
the other assertion was that the "major" libraries have it beat (likely
in the same way they "beat" DOM traversal).

I suppose to determine if it is buggy, you have to have a baseline that
is not buggy. So I suspected that some of the "buggy" behavior and
accompanying workarounds would be mystical incantations.

The querying in jQuery 1.41 (for example), uses an oddly named variable
called "Zizzle" to abstract the two layers (QSA and some really
off-the-wall and error-filled DOM traversal).

The original Sizzle is "declared" as follows:-

window.Sizzle = Sizzle;

Well, of course it is. Some things never change. :(

if ( document.querySelectorAll ) {

Bad feature detection (of course). I can easily see that blowing up in
some future IE incarnation (or who knows what other browser as host
objects can do what they want on type conversion).

(function(){
var oldSizzle = Sizzle, div = document.createElement("div");
div.innerHTML = "<p class='TEST'></p>";

Same old story. Needlessly tangling up feature testing with the
notoriously flaky innerHTML property.

// Safari can't handle uppercase or unicode characters when
// in quirks mode.

Interesting observation. Just Safari? Seems more like a Webkit issue
(assuming there is an issue). And what unicode characters?

if ( div.querySelectorAll && div.querySelectorAll(".TEST").length
=== 0) {
return;
}

How about !div.querySelectorAll(".TEST").length? The strict comparison
is silly.

Sizzle = function(query, context, extra, seed){
context = context || document;

That lets out frames.

// Only use querySelectorAll on non-XML documents

No worries, it is well established that jQuery is unsuitable for
traversing (or mutating) XML documents (Resig called a punt on that
issue a few months back). So this should really read: don't use jQuery
to read or write XML documents of any kind.

// (ID selectors don't work in non-HTML documents)
if ( !seed && context.nodeType === 9 && !isXML(context) ) {

isXML? Lets see:-

var isXML = function(elem){
// documentElement is verified for cases where it doesn't yet exist

Always a good idea.

// (such as loading iframes in IE - #4833)

Interesting observation, but the understanding must be that the
documentElement may not exist, period. In other words, this is not an
IE/IFrame issue, but a gap in logic that could have been avoided long
before the observed failure.

And, of course, jQuery can't support frames anyway (see above). I
assume bits of it do, but certainly not the query engine.

var documentElement = (elem ? elem.ownerDocument || elem :
0).documentElement;

What a perfectly ludicrous (and unreadable) line of code (didn't look to
see what it was replacing). But at least it doesn't throw exceptions if
the documentElement property is missing. The telling thing is that this
is one of those "overloaded" functions that jQuery is famous for,
requiring it to discriminate between different types of host objects
(elements and documents in this case).

return documentElement ? documentElement.nodeName !== "HTML" : false;

Whatever. It certainly doesn't add up to a cross-browser XML
discriminator (and is used all over the place in a library that doesn't
really support XML). And according to the above comment about IE and
IFrames, the documentElement may be missing in some cases, but otherwise
supported, so this is tangled up as it always returns false whenever it
can't find that property.

};

Back to the query portion:-

try {
return makeArray( context.querySelectorAll(query), extra );
} catch(e){}
}

That's it, is it? One (possible) quirk worked around. I see I haven't
been missing out on much (if anything). Who would have thought that
"jdalton" would exaggerate a claim? It must be the end of the world. :)

return oldSizzle(query, context, extra, seed);
};

for ( var prop in oldSizzle ) {

No filter (of course). Keep this thing away from other scripts.

Sizzle[ prop ] = oldSizzle[ prop ];
}

div = null; // release memory in IE

Cargo cult. There's no circular reference to break here. I used to do
the same thing, which is likely not a coincidence. ;)

})();
}

Okay, so how about the latest "stable" version of Prototype:-

SelectorsAPI: !!document.querySelector,

[...]

if (Prototype.BrowserFeatures.SelectorsAPI &&
document.compatMode === 'BackCompat') {

So any quirks mode.

Selector.CASE_INSENSITIVE_CLASS_NAMES = (function(){

That sounds sort of like the quirk that surfaced in jQuery.

var div = document.createElement('div'),
span = document.createElement('span');

div.id = "prototype_test_id";
span.className = 'Test';
div.appendChild(span);
var isIgnored = (div.querySelector('#prototype_test_id .test') !==
null);
div = span = null;

Another coincidence perhaps? Looks almost exactly like what I was
putting out in 2007, which showed up in jQuery in 2008 and is now being
copied by Prototype. Odd that these bums are my biggest "critics" (or
perhaps they are just jealous). :)

return isIgnored;
})();

I do like that pattern. :) And the logic is better than jQuery's.
Still, it is testing querySelector, but using querySelectorAll for its
queries (bad object inference).

}

[...]

shouldUseSelectorsAPI: function() {
if (!Prototype.BrowserFeatures.SelectorsAPI) return false;

Poor form.

if (Selector.CASE_INSENSITIVE_CLASS_NAMES) return false;

Same.


if (!Selector._div) Selector._div = new Element('div');

The RHS is mind-bogglingly inept. How about using createElement?

They are setting up for the big finale:-

try {
Selector._div.querySelector(this.expression);
} catch(e) {
return false;
}

return true;
},

Making the try-catch a one-off is admirable. The object inference is
inexcusable. And unless I've missed something, that's it for Prototype.

So, it appears there is nearly one quirk worked around between these two
"majors". I won't confirm it as one for sure, but I do remember such an
issue with Webkit in quirks mode (unrelated to QSA), so perhaps. I'll
look into it further. I don't know why jQuery bothered as they can't
support quirks mode in IE, which makes it a waste to attempt to support
others. Not surprising given its history though.

Yes, It appears I've seriously underestimated the time and care it takes
to create a QSA adapter. I should probably just pack it in. :)
 
D

David Mark

David said:
Having recently added an experimental QSA add-on for My Library, I have
been warned that QSA is a bear cross-browser. I don't doubt that, but
the other assertion was that the "major" libraries have it beat (likely
in the same way they "beat" DOM traversal).

I suppose to determine if it is buggy, you have to have a baseline that
is not buggy. So I suspected that some of the "buggy" behavior and
accompanying workarounds would be mystical incantations.

The querying in jQuery 1.41 (for example), uses an oddly named variable
called "Zizzle" to abstract the two layers (QSA and some really
off-the-wall and error-filled DOM traversal).

Typo. "Sizzle" of course.

[...]
Cargo cult. There's no circular reference to break here. I used to do
the same thing, which is likely not a coincidence. ;)

And, of course, it exits early if it spots that one quirk. I'm sure
Resig would say that the memory issue is only in IE and the quirk is
only in Safari, so it's all good. ;)
 
R

Roja Gilwreathe

It is completely disingenuous for you to assert that you never flame
or act immaturely on this newsgroup. This thread was a completely un-
instigated set of potshots against jQuery just to make your own ideas
and library sound great and wonderful. Of course, this is standard
operating procedure on this alleged 'newsgroup,' which devolved long
ago into your personal dumping ground for whichever axe you feel like
grinding at the moment.

You should have figured out a long time ago that relevance goes hand
in hand with manners. You may be a damn clever JS developer, but no
one, I assure you, no one, thinks of you as anything more than a forum
troll with severe anger and jealousy issues.

David said:
Having recently added an experimental QSA add-on for My Library, I have
been warned that QSA is a bear cross-browser.  I don't doubt that, but
the other assertion was that the "major" libraries have it beat (likely
in the same way they "beat" DOM traversal).
I suppose to determine if it is buggy, you have to have a baseline that
is not buggy.  So I suspected that some of the "buggy" behavior and
accompanying workarounds would be mystical incantations.
The querying in jQuery 1.41 (for example), uses an oddly named variable
called "Zizzle" to abstract the two layers (QSA and some really
off-the-wall and error-filled DOM traversal).

Typo.  "Sizzle" of course.

[...]


Cargo cult.  There's no circular reference to break here.  I used to do
the same thing, which is likely not a coincidence.  ;)

And, of course, it exits early if it spots that one quirk.  I'm sure
Resig would say that the memory issue is only in IE and the quirk is
only in Safari, so it's all good.  ;)
 
J

john

Having recently added an experimental QSA add-on for My Library, I have
been warned that QSA is a bear cross-browser.

i've been testing both querySelector and querySelectorAll recently and
the results are pretty much what you'd expect. the following from
IE8/JScript 5.8 which all complain about "Invalid argument." where as
Safari 4, Firefox 3.6 and Opera 10.10 all agree (mostly) about the results:

var a = document.querySelector('ul li:last-child');
var b = document.querySelectorAll('table tbody tr:nth-child(2n+0)');
var c = document.querySelectorAll('table tbody tr:nth-child(2n+1)');
var d = document.querySelectorAll('table tbody tr:nth-child(even)');
var e = document.querySelectorAll('table tbody tr:nth-child(odd)');
var f = document.querySelectorAll('input:not([disabled])');
var g = document.querySelectorAll('html:root');
var h = document.querySelector('table tbody tr:first-of-type'); *
var i = document.querySelector('table tbody tr:last-of-type'); *
var j = document.querySelectorAll('div:empty');
var k = document.querySelector('div span:eek:nly-child');
var l = document.querySelectorAll('table:first-of-type');
var m = document.querySelector('body div:last-of-type'); *+
var n = document.querySelector('span:eek:nly-of-type');
var o = document.querySelector('input:checked');
var p = document.querySelectorAll('input:enabled');
var q = document.querySelectorAll('input:disabled');

while the following match in IE8, Safari 4, Firefox 3.6 and Opera 10.10:

var r = document.querySelector('ul li:first-child');
var s = document.querySelector('input[type=submit]');
var t = document.querySelector('input[value~=Submit]');
var u = document.querySelector('input[name|=submit]');
var v = document.querySelectorAll('input[type^=s]');
var w = document.querySelectorAll('input[type$=t]');
var x = document.querySelectorAll('input[type*=ubmi]');
var y = document.querySelectorAll('table + ul');
var z = document.querySelector('table ~ p');

--- test document ---------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>qs(a)</title>
</head>
<body>
<p><input type=submit name=submit_button value=Submit></p>
<p><input type=submit name=submit-button value=Submit></p>
<table>
<caption>caption</caption>
<thead>
<tr><th>header</th></tr>
</thead>
<tbody>
<tr><td>data1</td></tr>
<tr><td>data2</td></tr>
<tr><td>data3</td></tr>
</tbody>
</table>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
<p>abc</p>
<div></div>
<div><span>span</span></div>
<p><input type="checkbox" name="box" value="box" checked></p>
</body>
</html>
 
J

john

Having recently added an experimental QSA add-on for My Library, I have
been warned that QSA is a bear cross-browser.

i've been testing both querySelector and querySelectorAll recently and
the results are pretty much what you'd expect. the following from
IE8/JScript 5.8 which all complain about "Invalid argument." where as
Safari 4, Firefox 3.6 and Opera 10.10 all agree (mostly) about the results:

[ results ]

and Google Chrome 5.0.307.5 matches Safari 4
 
S

slebetman

 This thread was a completely un-
instigated set of potshots against jQuery just to make your own ideas
and library sound great and wonderful.

Wow, pointing out that buggy code is buggy is taking potshots? I
thought that was how opensource (and just plain old good academic
discussion) was supposed to work.
Of course, this is standard
operating procedure on this alleged 'newsgroup,' which devolved long
ago into your personal dumping ground for whichever axe you feel like
grinding at the moment.

To me, open, honest criticism of code is excellent policy. If you
can't stand honesty then it's your loss. Honesty is always valuable
regardless of weather or not I agree with the idea (and I often find
myself disagreeing with David).
You should have figured out a long time ago that relevance goes hand
in hand with manners.

Manners have little to do with how well code is written. I'd much
prefer code that is as bug-free as possible to code written by polite
people. After all, I'm not aiming to be David Mark's or John Resig's
friend. I just want to use the code.

Criticisms like Davids is extremely useful because there are faults
pointed out in his posts that are not acknowledged on jQuery's bug
tracker because its developers don't consider them to be bugs.
 You may be a damn clever JS developer, but no
one, I assure you, no one, thinks of you as anything more than a forum
troll with severe anger and jealousy issues.
<snipped the rest>

Well.. definitely not no one unless your universe consist entirely of
jQuery fanboys.
 
R

Roja Gilwreathe

Would anyone really deny that DM is always as condescending and
denigrating as he can possibly be? If he cared about jQuery (which he
doesn't), then he would have stopped this pathetic ritual a long time
ago and contributed constructively.

Manners may have little to do with code quality, but they have a great
deal to do with participation and perception. When one sees the
general level of discourse around here, it's not surprising that
people here seem to overlook the importance of these human
interactions on software projects. It's hard for productivity to
arise from the endless arguments, fiskings, ad hominem attacks, and
general lack of civility on this newsgroup, all of which are direct
byproducts of David's continual presence.

Now I have no desire and not nearly enough time to actually get
entangled in this cycle of attacks (too late?), but merely wanted to
voice my frustation with the general situation. This place is not a
resource for anyone who is looking for something besides herbal Viagra
or a small group of people viciously picking apart each other's
sentences ad nauseam.
 
R

rf

Roja said:

Gee, another top post, against all the rules of this newsgroup.

Obviously not a regular reader. Just a drop in troll angry that is favourite
library is being exposed as totally flawed.
 
R

rf

Jake said:
^^^^^^^^^^^^^^^

Sounds familiar.

Not here.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I would actually bet on the opposite, see above.

A search for the word Gilwreathe in google groups reveals zero hits

A search on my news server reveals exactly two hits. The two posts in this
thread.

A general search for Gilwreathe on the web returns exactly one hit, oddly
enough a chinese "lets copy usenet" site that reveals my first post in this
thred.

No, not familar at all.

I don't care who this dipstick is, I'm on Davids side. Lets get rid of these
stupid "libraries" and replace them with code that actually works.
 
D

David Mark

Roja said:
It is completely disingenuous for you to assert that you never flame
or act immaturely on this newsgroup. This thread was a completely un-
instigated set of potshots against jQuery just to make your own ideas
and library sound great and wonderful.

Actually, it couldn't have been more instigated.

http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/910da4771b1fc832#

There was a bogus test posted that excluded my QSA add-on (without
noting the fact) and then asserted My Library was "one of the slowest"
because QSA out-performed it. This was ostensibly because the other
libraries had gone to great lengths to ensure their QSA tack-ons were
consistent cross-browser. :)
Of course, this is standard
operating procedure on this alleged 'newsgroup,' which devolved long
ago into your personal dumping ground for whichever axe you feel like
grinding at the moment.

No. Like the others who refer to any opinion they don't like as
"trolling", you seem to be mixed up about how discussion groups work.
If you want to talk "dumping grounds", how about jQuery? Now that's a
dump. ;)
You should have figured out a long time ago that relevance goes hand
in hand with manners.

LOL. You feel my review of "Sizzle" was in bad taste? Why? Because
you use it and now can't sleep at night? I know unwelcome epiphanies
are unwelcome. But that doesn't mean you have to come in here and
insult everybody. Seems like bad manners to me.
You may be a damn clever JS developer, but no
one, I assure you, no one, thinks of you as anything more than a forum
troll with severe anger and jealousy issues.

There it is! You don't seem to know what "troll" means. Oh, and the
hat trick with "anger" and "jealousy". I assure you I am not angry
about jQuery's follies (except when they get in the way of my Web
browsing). And no, I am certainly not jealous. What is there to be
jealous of?

And please don't top-post. It screws up the context of the discussion.
Thanks!
David said:
Having recently added an experimental QSA add-on for My Library, I have
been warned that QSA is a bear cross-browser. I don't doubt that, but
the other assertion was that the "major" libraries have it beat (likely
in the same way they "beat" DOM traversal).
I suppose to determine if it is buggy, you have to have a baseline that
is not buggy. So I suspected that some of the "buggy" behavior and
accompanying workarounds would be mystical incantations.
The querying in jQuery 1.41 (for example), uses an oddly named variable
called "Zizzle" to abstract the two layers (QSA and some really
off-the-wall and error-filled DOM traversal).
Typo. "Sizzle" of course.

[...]


Cargo cult. There's no circular reference to break here. I used to do
the same thing, which is likely not a coincidence. ;)
And, of course, it exits early if it spots that one quirk. I'm sure
Resig would say that the memory issue is only in IE and the quirk is
only in Safari, so it's all good. ;)
 
D

David Mark

john said:
i've been testing both querySelector and querySelectorAll recently and
the results are pretty much what you'd expect. the following from
IE8/JScript 5.8 which all complain about "Invalid argument." where as
Safari 4, Firefox 3.6 and Opera 10.10 all agree (mostly) about the results:

Sure. IE8 won't query on some selectors, so you have to wrap the call
in a try-catch and fall back to DOM traversal or XPath. I assume that
at least some of them fail because IE doesn't support the selectors in
CSS either.
 
D

David Mark

slebetman said:
Wow, pointing out that buggy code is buggy is taking potshots? I
thought that was how opensource (and just plain old good academic
discussion) was supposed to work.

That's what I thought too. There seems to be a huge population of
people out there who have never used Usenet and think that anything they
disagree with is "trolling" (the most over-used word on the Internet).
For them, forums are encounter groups (or something other than academic
duscussion).
To me, open, honest criticism of code is excellent policy. If you
can't stand honesty then it's your loss. Honesty is always valuable
regardless of weather or not I agree with the idea (and I often find
myself disagreeing with David).

You troll. Stop trolling! :)
Manners have little to do with how well code is written. I'd much
prefer code that is as bug-free as possible to code written by polite
people. After all, I'm not aiming to be David Mark's or John Resig's
friend. I just want to use the code.

The former rather than the latter I hope. ;)
Criticisms like Davids is extremely useful because there are faults
pointed out in his posts that are not acknowledged on jQuery's bug
tracker because its developers don't consider them to be bugs.

Or the documentation. Do they stipulate that you can't use quirks mode
in there? :)
Well.. definitely not no one unless your universe consist entirely of
jQuery fanboys.

Such a (parallel) universe seems to exist (and occasionally collides
with this one). :)
 
D

David Mark

Roja said:
Would anyone really deny that DM is always as condescending and
denigrating as he can possibly be?
Yes.

If he cared about jQuery (which he
doesn't), then he would have stopped this pathetic ritual a long time
ago and contributed constructively.

You don't know your history. For the umpteenth time, I tried to help
jQuery several times. Didn't pan out as they kept fumbling the ideas.
Manners may have little to do with code quality, but they have a great
deal to do with participation and perception.

What is it about this particular thread that you find in bad taste?
When one sees the
general level of discourse around here, it's not surprising that
people here seem to overlook the importance of these human
interactions on software projects.

No, that's all BS. This is a discussion group, not a project. I've
worked on _hundreds_ of software projects and sure as hell never got
accused of bad manners. Now here...
It's hard for productivity to
arise from the endless arguments, fiskings, ad hominem attacks, and

"Ad hominem attacks" is another overused word that often serves only to
make the user sound like a laughingstock (see also troll). Can you
point out any such attacks in the QSA review?
general lack of civility on this newsgroup, all of which are direct
byproducts of David's continual presence.

ISTM that you talk a lot about me. Do you have any ideas to contribute
(or anything related to the topic at hand?)
Now I have no desire and not nearly enough time to actually get
entangled in this cycle of attacks (too late?),
Yes.

but merely wanted to
voice my frustation with the general situation.

It's out of control, isn't it? :) Don't worry, we won't be talking
about jQuery much longer as it is going to go the way of the Dodo.
This place is not a
resource for anyone who is looking for something besides herbal Viagra
or a small group of people viciously picking apart each other's
sentences ad nauseam.

Nope. And will you please stop top-posting? Thanks!
 
D

David Mark

Andrew said:
As I understand it, DM tried to help jquery be improved but that his
comments have largely been ignored. So is the pathetic ritual you're
referring to that the developers appear to choose to ignore assistance?

Yes. It's a long, sad story and very well-documented. But those who
pop in here to whine about the latest chapters haven't been following along.
So, at what NG do you perceive a suitable general level of discourse?
alt.programmer.wannabe.really.really.really.i.do


Its a NG, if you are unhappy with the level of civility in a post you
can ignore it.

Or even filter the poster. In the moderated groups this is usually
eschewed by control-freaks for cries of banishment. :)
Why do you complain about how rude people are by being rude?

Yes, it is a paradox.
I admire DM's persistence with regards to his comments about the quality
of code in various js libraries and frameworks. His reviews challenge my
understanding of js and is helping me to increase my understanding.

Thanks! Glad you like them.
 
D

David Mark

rf said:
Gee, another top post, against all the rules of this newsgroup.

Obviously not a regular reader. Just a drop in troll angry that is favourite
library is being exposed as totally flawed.

Yes, that is an appropriate use of the word (troll). Take note, Roja.
 
D

David Mark

rf said:
Not here.


A search for the word Gilwreathe in google groups reveals zero hits

Nearly one.
A search on my news server reveals exactly two hits. The two posts in this
thread.

LOL. It's the same guy (gal?) over and over. They just keep changing
their name to make it look like they are an army.
A general search for Gilwreathe on the web returns exactly one hit, oddly
enough a chinese "lets copy usenet" site that reveals my first post in this
thred.

No, not familar at all.

Yeah, I've never heard of most of these people who come in here crying
about "trolling" in a group nobody is forcing them to read.
I don't care who this dipstick is, I'm on Davids side. Lets get rid of these
stupid "libraries" and replace them with code that actually works.

That's the most sensible thing I've heard all day. :)
 
D

David Mark

Jake said:
"Roger Gilreath" is a google groups alias of DM, been mentioned in a
thread or two here, and I just assume "Roja" knows that as well.

As I've mentioned numerous times. I use that when GG decides I've
posted too many times in the last hour (or whatever). Used it a couple
of times in other groups to thwart bans as well (until poor "Roger" got
banned too).

Is it your assertion that I am this top-posting crank? That's certainly
not the case. More like they are trying to be funny by corrupting the
alias. I didn't even catch it until now. :)
 
G

Garrett Smith

David said:
Roja Gilwreathe wrote:
[...]
"Ad hominem attacks" is another overused word that often serves only to
make the user sound like a laughingstock (see also troll).

How so?
 
D

David Mark

Garrett said:
David said:
Roja Gilwreathe wrote:
[...]
"Ad hominem attacks" is another overused word that often serves only to
make the user sound like a laughingstock (see also troll).

Because it is typically tossed about to describe anybody the poster
doesn't like. In general usage, it's got no real meaning at this point,
other than to show that the user is clueless about the origins of the
term. Technically speaking, most who cry "troll" are in fact trolling
themselves (like this latest crank).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top