jquery / sizzle

A sizzlin' hot selector engine.
https://sizzlejs.com
Other
6.29k stars 951 forks source link

Unsupported pseudo: visible #476

Closed fiote closed 3 years ago

fiote commented 3 years ago

I'm using Sizzle as a standalone lib without jquery (cloned the git, npm run builded it and included the min.js file on my project).

For most part it works great, but I'm trying to use the :visible pseudo-selector and it's saying it's not supported. Is there some parameter/option I need to set/enable to make it work when building the project or something like that?

timmywil commented 3 years ago

:visible is actually a custom pseudo selector added by jQuery. However, you can add this yourself without adding the rest of jQuery. See https://github.com/jquery/jquery/blob/main/src/css/hiddenVisibleSelectors.js

Sizzle.selectors.pseudo.visible = function visibleSelector( elem ) {
  return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
}
fiote commented 3 years ago

Thanks a LOT @timmywil \o/