you-dont-need-x / you-dont-need-jquery

The next evolutive state of, "You Might Not Need jQuery", because you definitely don't need jQuery.
The Unlicense
121 stars 10 forks source link

context vs document #8

Open rlemon opened 8 years ago

rlemon commented 8 years ago

in your Querying the DOM section https://github.com/ndugger/youdontneedjquery#querying-the-dom

your example could be improved by offering a context example as well.

const myElement = $('.foo', context); or

const myElement = $context.find('.foo');

and the same 'non jQuery' solutions but replace document with context (or is rootElement maybe a better label?).

I think this is a common enough use case and I see a lot of people searching the entire DOM when they do have a context to start with. Just a suggestion.