The Context property/parameter

The Context property/parameter


Back in June, Brandon wrote an enlightening article about the
misunderstood "context" parameter.
Read it here: http://brandonaaron.net/blog/2009/06/24/understanding-the-context-in-jquery
Most of it makes sense to me now but I'm still a little confused about
some of the assertions made as a result of the article. (from various
readers)
This is how I see it:
---
$('#container a');
1. Gets all anchors within the context (document)
2. Returns an array (only) with the anchors that are within #container
(i.e. runs through all anchors checking parentNodes)
---
$('a', $('#container')[0]);
1. Context is #container
2. Returns all anchors found in context (simplified:
context.getElementsByTagName('a'))
---
$('a', '#container'); // or $('a', $('#container'));
1. Context is #container (this is where I'm confused)***
2. Returns all anchors found in context
---
*** This is where I'm confused. As far as I'm concerned, the context
is "#container" because that is the element that's searched within.
The only reason the "context" property is -document- is because -$(s,
c)- is really -$(c).find(s)- ... Hence the expression -$(c).context-
evaluates to -document-; the "context" property is not changed as a
result of -find()-.
Recently on Stack Overflow somebody was raving about this context
issue and mentioned the following:
---
var ct = $('#myContainer');
// This will still search the ***whole doc*** for elements with class
'myClass'
$('.myClass', ct);
---
That can't be true, right? It doesn't "search the whole doc".
The "context" property may be "document" but ".myClass" is only
searched for within "#myContainer", right? (this is how I see it,
after looking at the source)
I think the main reason people (including me) are confused is because
the "context" property does not correspond with the "context"
parameter. I'm not too bothered about it but it seems to be causing
confusion elsewhere.
So I guess all I wanted was a bit of clarification... Am I right? Am I
completely off the mark?
Thanks all!