Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Landing some minor perf optimization to jQuery().
- Loading branch information
Showing
2 changed files
with
13 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then this also might improve things :
--DBJ
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment node is allowed there. If a comment is present, then the code should fail.
Your code will produce your desired outcome Gecko and IE, but only due to browser bugs. It will fail in Chrome, Opera, Webkit, and Blackberry.
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try the code example again:-
What is
document.document.firstChild
? Is it a comment or the head? So when IE and Firefox get the head, that's a bug.Garrett
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well close enough on the code example to convey the point (should be <head>
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Easy to fix, don't get upset ... Concentrate on good things ...
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the thinking your response. I helped you avoid a bug. How does that make me "upset"?
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Garrets: I was talking to myself, so "don't get upset" ... ;o)
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, got it. I know some people really talk to themselves a lot. Well, I sometimes don't edit my words so well either, AYCS from the code examples.
But please try and get my name right, though -- it's "Garrett".
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My name is not DBJDBJ, either ...
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@john
'jQuery.setArray' is still significantly faster then 'jQuery.makeArray', and although it is not strictly necessary, 'jQuery(aArray)' is still heavily used internally.
Is this change motivated by the intention to deprecate/remove 'jQuery.setArray'? It is not used any more.
If so, then I would suggest to integrate 'jQuery.setArray' inside 'jQuery.makeArray' or inside 'jQuery.merge or even better inside' 'jQuery'.
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rkatic: Actually, that's not entirely true - the only place jQuery(array) is used is within pushStack - that can easily be rewritten to use the faster code path - and if it's being removed then it makes a lot of sense to deprecate/remove it as well (people should be using pushStack anyway).
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@john, I wellcome anyhting that untangles jQuery() , "multifunctional" single function interface.
That is If, I understood properly you want to deprecarte jQuery( array ) ...
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that's not what I said. I use want to remove jQuery.fn.setArray as it's no longer needed - it can be incorporated into jQuery.fn.pushStack.
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I got carried away. Although, name "pushStack()" dramaticaly improves the readability of the API. It clearly reveals the intent and the reason of existence of the method... I would like to see (much) more of that kind of activity, while moving towards 1.5
The Official jQuery Podcast – Episode 9 – David Artz, Aol.also reveals , what my little contribution (from few months ago) tried to explain too : not everyone is jQuery expert. Managing a large(ish) teams and/or Web 2.0 companies, becomes a nightmare, because of power and flexibility of jQuery. Which often produces a lot of headaches when "given" to those big teams developing and/or supporting large portals.
They rarely bother with api documentation, usually not before the whole mountain of javascript code starts disolving, because of code like : $("*").click() ...
All API ambiguity must be weeded-out, as much as possible ...
--DBJ
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Uf, I wrote
jQuery.setArray
instead ofjQuery.fn.seArray
. I have to sleep.)I know, but
pushStack
is heavily used. Had to be more clear telling thatjQuery(array)
is frequently evaluated.I am not completely convinced about incorporating
setArray
intopushStack
.Internally, currently,
pushStack
is the only one that usesjQuery(array)
, but what about plugins? What about addingjQuery.fromArray
then.b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rkatic: As a public-facing API setArray simply doesn't make sense (and it never has been an API that we've wanted to expose). It's a destructive operation which is completely against the rest of the jQuery API. Moving it into pushStack is really better all around.
b8076a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
John, I completely agree to remove
setArray
, but maybejQuery.fn.init
is more appropriate to integrate that.