Skip to content

Instantly share code, notes, and snippets.

@robsonsobral
Created April 30, 2022 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robsonsobral/64c8100d51f8ebe3154c8b0f24fa8ac6 to your computer and use it in GitHub Desktop.
Save robsonsobral/64c8100d51f8ebe3154c8b0f24fa8ac6 to your computer and use it in GitHub Desktop.
const queryCheck = (s) => document.createDocumentFragment().querySelector(s);
export default function isSelectorValid(selector) {
if (typeof selector !== 'string') return false;
try { queryCheck(selector); } catch { return false; }
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment