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
Vanilla Javascript
( function( window ) {
window.domQ.fn.foo = function() {
return this;
};
} )( window );
ES Module
import domQ from "domQ";
domQ.fn.foo = function() {
return this;
};

Function Callback / Usage

domQ('*').foo();

Static Method

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

Function Declaration

Vanilla Javascript
ES Module
Vanilla Javascript
( function( window ) {
window.domQ.calcNumbers = function( number1, number2 ) {
return ( number1 + number2 );
};
} )( window );
ES Module
import domQ from "domQ";
domQ.calcNumbers = function( number1, number2 ) {
return ( number1 + number2 );
};

Function Callback / Usage

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