Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //dom_utils Class, keep this in a utils file of some sort
- class dom_utils {
- constructor(selector) {
- this.node = selector;
- }
- exists() {
- return typeof this.node !== 'undefined';
- }
- }
- export default dom_utils;
- //implement anywhere (probably inside a constructor)
- import dom_utils from '@/helpers/utilities';
- class some_class(){
- constructor(){
- this.node = document.querySelector('.some-element');
- this.node.utils = new dom_utils(this.node);
- }
- //then call utils inside your methods
- some_method(){
- let exists = this.node.utils.exists();
- }
- }
Add Comment
Please, Sign In to add comment