CARVIEW |
jquery / jquery
- Source
- Commits
- Network (98)
- Graphs
-
Branch:
master
Comments for jquery's jquery


"noop" ? Isn't that: "no operation", abbreviated ? ... what was wrong with some combination of words "empty" and "function" ? I think even: "emptyFunction" would work better.
After all in jQ we have "isArray", "isFunction" ...and other nice descriptive names ;o)--DBJ

Sorry for getting back so late. I somehow forgot about this "thread". On to the points.
There are native and host objects in ECMAScript. Native objects are supplied independent of host environment.
{}
,[1,2,3]
,function foo(){}
,Object
andRegExp.prototype
— are all examples of native objects. Some of native objects are also called built-ins — these are the ones specified in ECMA —Object
,Function
,Number
,parseInt
,Math.max
, etc. And then there are host objects — those provided by host enviornment (e.g. exposed DOM bindings in browsers are obviously host objects —document
,document.getElementById
, etc.)When you say "plain object" is that which is defined with the literal
{}
, it sounds akward and still unclear to me.{}
only denotes how something is created, not what it really is :)new Object()
, for example, creates identical type of object, given thatObject
constructor is not overridden or shadowed.new Object
has nothing to do with literal notation, yet it creates an object similar to the one created via{}
(i.e. with same internal [[Prototype]] and [[Class]]). If I create my object vianew Object()
is it not a plain object anymore? It wasn't created with{}
after all ;) And what if I created an object with{}
and then changed its [[Prototype]] to referenceArray.prototype
?{}
-based definition doesn't seem like a good idea.We can't detect object's [[Prototype]] in standard ES3 (without
__proto__
extension or ES5Object.getPrototypeOf
), so I don't see how it's possible to satisfyo is <plain object> if Object.getPrototypeOf(o) == Object.prototype
condition. And if that's the only goal, why is there a [[Class]] check in current implementation? Does it mean that besides [[Prototype]] == Object.prototype, "plain object" should also have [[Class]] == "Object"?It's still hard to explain what "plain object" really is. And the reason I'm bringing this up is that when it's hard to explain what method really does, it usually means that something went wrong and probably needs to be rethought.

As I commented on jquery-dev I'm leaving it in so that we don't break compatibility with plugins.

Is there any reason to leave jQuery.event.proxy here? I don't see anywhere that uses it now.

Massively better. Hip hip hooray Alex!

Have to say I really appreciate this as one time I needed jQuery as a string and manually escaping all these was a pain.
Don't ask why I needed jQuery as a string.. :D

The MS tool also strips out conditional comments, it seems:
https://ajaxian.com/archives/microsoft-ajax-minifier-vs-yui-compressor

+5; painting it red!

Spelling mistake in event.js: wich should be which

The just do not use the "closure compiler", I guess ?
Is Microsoft Ajax Minifier any good?
https://stephenwalther.com/blog/archive/2009/10/16/using-the-new-microsoft-ajax-minifier.aspx

Weird, the commit message got munged. It should say "Make sure we use jQuery(document) instead of jQuery() in the delegate test.

The Closure compiler strips out comments, so I think the goal was to eliminate conditional comments completely from jQuery so that it is easy to build the compressed version.

kangax, you are right about
if (/*@cc_on ! @*/0)
. My code doesn't even work.
isMaybeLeak/*@cc_on=(@_jscript_version<5.7)@*/
looks much bulletproof.

@NV Or just —
if (/*@cc_on ! @*/0)
. I guess removal of conditional comments is to cater to Closure Compiler (which strips them).if (window.attachEvent && !window.addEventListener)
is a decent inference, but might fail when someone defines customaddEventListener
onwindow
(as, for example, MSDN demonstrates — https://msdn.microsoft.com/en-us/library/dd229916%28VS.85%29.aspx). The chance of someone following MSDN example is too big, as for my taste, so I'd rather go with something similar to what Garrett does in APE —var isMaybeLeak/*@cc_on=(@_jscript_version<5.7)@*/
(https://github.com/GarrettS/ape-javascript-library/blob/master/src/EventPublisher.js)

Oops, I forgot "@"
if ( window.attachEvent && /*@cc_on 1 @*/ ) {

Just curious, why not
if ( window.attachEvent && /*@cc_on 1 */ ) {
?

@jaubourg : Another thanks for the great follow up tests around the FOUC. I'll be publishing my loader (https://github.com/aheckmann/jQuery.use) over the next few days too as I feel more and more up to it (just coming back from major surgery).

Host objects can have characteristics of native objects such as Object.getPrototypeOf(obj) === Object.prototype but that is not consistent or guaranteed across browsers/environments.
Of course. It is why I used host/native as an condition of the definition.
To be more clearer, we can say that "plain objects" are all "user" objects definable with the literal{...}
notation. In fact, first version of the function was namedisLiteralObject
. Later it was renamed toisPlainObject
.

@rkatic Host objects can have characteristics of native objects such as
Object.getPrototypeOf(obj) === Object.prototype
but that is not consistent or guaranteed across browsers/environments.