Extending domQ
domQ can be extended, adding custom methods to domQ collections or custom static methods to the domQ object.
If you're writing JavaScript the way to do it is exactly the same as what you'd do for extending jQuery

Collection Method

This is how you can add an hypothetical foo method to domQ collections:

Function Declaration

Vanilla Javascript
ES Module
1
( function( window ) {
2
window.domQ.fn.foo = function() {
3
return this;
4
};
5
} )( window );
Copied!
1
import domQ from "domQ";
2
3
domQ.fn.foo = function() {
4
return this;
5
};
Copied!

Function Callback / Usage

1
domQ('*').foo();
Copied!

Static Method

This is how you can add an hypothetical calcNumbers static method to the Cash object:

Function Declaration

Vanilla Javascript
ES Module
1
( function( window ) {
2
window.domQ.calcNumbers = function( number1, number2 ) {
3
return ( number1 + number2 );
4
};
5
} )( window );
Copied!
1
import domQ from "domQ";
2
3
domQ.calcNumbers = function( number1, number2 ) {
4
return ( number1 + number2 );
5
};
Copied!

Function Callback / Usage

1
domQ.calcNumbers(10 + 2); // returns as 12
Copied!