Created
April 30, 2022 03:03
-
-
Save robsonsobral/759b6b6c61f09074397a82fbbb29bf38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import isSelectorValid from './isSelectorValid'; | |
export default (param) => { | |
switch (true) { | |
case isSelectorValid(param): | |
return document.querySelectorAll(param); | |
case param instanceof HTMLElement: | |
return [param]; | |
case param instanceof NodeList: | |
case param instanceof HTMLCollection: | |
return Array.from(param); | |
default: | |
return null; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment