Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Arguments Overloading FTW
/**
* Converts any input box on a page to a CSS selector search and suggestion box.
*
* @constructor
* @param {nsIDOMDocument} aContentDocument
* The content document which inspector is attached to.
* @param {nsiInputElement|String} aInputNode
* The input element or the selector for teh input element to which the
* panel will be attached and from where search input will be taken.
* @param {Object} aOptions
* The options provided to the selector. Current available options are:
* - TODO
* @arguments The following combinations of the above three arguments is possible
* - (aContentDocument, aInputNode[, aOptions])
* - (aContentDocument, String[, aOptions])
* - (aInputNode[, aOptions])
* - (String[, aOptions])
*/
function SelectorSearch() {
this.searchBox = (typeof arguments[0] == "string")
? (this.doc = document).querySelector(arguments[0])
: (!arguments[0].ownerDocument)
? ((this.doc = arguments[0]) && typeof arguments[1] == "string")
? this.doc.querySelector(arguments[1])
: arguments[1]
: (this.doc = arguments[0].ownerDocument, arguments[0]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment