Modify ↓
Ticket #5553 (closed bug: worksforme)
What is 'context' , in the context of jQuery ?
| Reported by: | dbjdbj | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | core | Version: | 1.3.2 |
| Keywords: | context | Cc: | |
| Blocking: | Blocked by: |
Description
I think, we need a clear defintion of the 'context'. The second argument to the $() function. I think we are pretty close. But I found this in the init :
// Handle $(DOMElement)
if (selector.nodeType) {
this.context = this[0] = selector;
this.length = 1;
return this;
}
Which confused me? I thought that context is the parent element, inside which selector is applied ? Like this:
jQuery( context ).find( selector ) ;
According to this , the above part of init() should be changed to this:
// Handle $(DOMElement)
if (selector.nodeType) {
this[0] = selector;
this.context = selector.parentNode || selector;
this.length = 1;
return this;
}
Otherwise, this:
jQuery( selector ).find( selector ) ;
would be also valid ? Can context and selector be ever a same element ?
It seems clarification is required ...
--DBJ
Change History
comment:1 Changed 4 years ago by dmethvin
- Status changed from new to closed
- Resolution set to invalid
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

This would be best discussed on jQuery-dev since it's not a bug report as far as I can tell.