Open
Description
Walking over whole DOM to look for a selector match is an overkill.
There're at least two better solutions:
- Launch the search from the given NODE over the REVERSED selector with cut off first part (it usually looks like * !~ ) -- saves ~50% of time in my benchmark. If it matches anything -- selector does what we want to.
- Pros: no problems with compatibility
- Write a separate matcher or find a way to reuse existing finders (though, I couldn't figure it out myself)
- Pros: the fastest way -- saves ~75% of time in my benchmark
- Cons: not so DRY
I've got some code but it's very-very dirty (I'm not a js-er, actually) but I can add it as a proof of concept via gist if you need.
WDYT?