Skip to content

Instantly share code, notes, and snippets.

@bclinkinbeard
Created May 1, 2014 02:10
Show Gist options
  • Save bclinkinbeard/11443190 to your computer and use it in GitHub Desktop.
Save bclinkinbeard/11443190 to your computer and use it in GitHub Desktop.
requirebin sketch
var domready = require('domready'),
dom = require('domquery')
dom('body').html('<button>This is a button</button>')
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({UkybCi:[function(require,module,exports){!function(name,definition){if(typeof module!="undefined")module.exports=definition();else if(typeof define=="function"&&typeof define.amd=="object")define(definition);else this[name]=definition()}("domready",function(){var fns=[],listener,doc=document,domContentLoaded="DOMContentLoaded",loaded=/^loaded|^i|^c/.test(doc.readyState);if(!loaded)doc.addEventListener(domContentLoaded,listener=function(){doc.removeEventListener(domContentLoaded,listener);loaded=1;while(listener=fns.shift())listener()});return function(fn){loaded?fn():fns.push(fn)}})},{}],domready:[function(require,module,exports){module.exports=require("UkybCi")},{}]},{},[]);require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({jmFIFT:[function(require,module,exports){var select=require("./lib/select"),create=require("./lib/create");module.exports=select;module.exports.create=create},{"./lib/create":4,"./lib/select":8}],domquery:[function(require,module,exports){module.exports=require("jmFIFT")},{}],3:[function(require,module,exports){module.exports=attr;function attr(chain){return function attr(element,name,value){if(arguments.length==2){return element.getAttribute(name)}element.setAttribute(name,value);return chain}}},{}],4:[function(require,module,exports){var newElement=require("new-element");var select=require("./select");module.exports=create;function create(html){if(html.charAt(0)=="<"){return select(newElement(html))}return select(document.createElement(html))}},{"./select":8,"new-element":23}],5:[function(require,module,exports){var events=require("on-off");var delegate=require("delegate-dom");var bindKey=require("bind-key");var trim=require("trim");module.exports={change:event("change"),click:event("click"),keydown:event("keydown"),keyup:event("keyup"),keypress:event("keypress"),mousedown:event("mousedown"),mouseover:event("mouseover"),mouseup:event("mouseup"),resize:event("resize"),on:on,off:off};function event(type){return function(element,callback){return on(element,type,callback)}}function off(element,event,selector,callback){if(event.charAt(0)==">"){return bindKey.off(element,trim(event.slice(1)),callback)}if(arguments.length==4){return delegate.off(element,selector,event,callback)}callback=selector;events.off(element,event,callback)}function on(element,event,selector,callback){if(event.charAt(0)==">"){if(arguments.length==3){callback=selector}return bindKey(element,trim(event.slice(1)),callback)}if(arguments.length==4){return delegate.on(element,selector,event,callback)}callback=selector;events.on(element,event,callback)}},{"bind-key":11,"delegate-dom":13,"on-off":25,trim:33}],6:[function(require,module,exports){var format=require("new-format");module.exports=html;function html(chain){return function(element,newValue,vars){if(arguments.length>1){element.innerHTML=arguments.length>2?format(newValue,vars):newValue;return chain}return element.innerHTML}}},{"new-format":24}],7:[function(require,module,exports){module.exports=isHTML;function isHTML(text){return typeof text=="string"&&text.charAt(0)=="<"}},{}],8:[function(require,module,exports){var newChain=require("new-chain"),format=require("new-format"),classes=require("dom-classes"),children=require("dom-children"),newElement=require("new-element"),query=require("select-dom"),style=require("style-dom"),attr=require("./attr"),events=require("./events"),html=require("./html"),isHTML=require("./is-html"),text=require("./text"),val=require("./val");module.exports=select;function each(fn,elements){return function(){var i,len,ret,params,ret;len=elements.length;i=-1;params=[undefined].concat(Array.prototype.slice.call(arguments));while(++i<len){params[0]=elements[i];ret=fn.apply(undefined,params)}return ret}}function select(query){var key,chain,methods,elements;if(isHTML(query)){elements=[newElement(query,arguments[1])]}else if(typeof query=="string"){elements=Array.prototype.slice.call((arguments[1]||document).querySelectorAll(query))}else if(query==document){elements=[document.documentElement]}else{elements=Array.prototype.slice.call(arguments)}methods={addClass:each(classes.add,elements),removeClass:each(classes.remove,elements),toggleClass:each(classes.toggle,elements),show:each(style.show,elements),hide:each(style.hide,elements),style:each(style,elements)};for(key in events){methods[key]=each(events[key],elements)}for(key in children){methods[key]=each(children[key],elements)}chain=newChain.from(elements)(methods);chain.attr=each(attr(chain),elements);chain.classes=each(classes,elements);chain.hasClass=each(classes.has,elements),chain.html=each(html(chain),elements);chain.text=each(text(chain),elements);chain.val=each(val(chain),elements);chain.select=function(query){return select(query,elements[0])};return chain}},{"./attr":3,"./events":5,"./html":6,"./is-html":7,"./text":9,"./val":10,"dom-children":15,"dom-classes":18,"new-chain":22,"new-element":23,"new-format":24,"select-dom":27,"style-dom":29}],9:[function(require,module,exports){var format=require("new-format");module.exports=text;function text(chain){return function(element,newValue,vars){if(arguments.length>1){element.textContent=arguments.length>2?format(newValue,vars):newValue;return chain}return element.textContent}}},{"new-format":24}],10:[function(require,module,exports){module.exports=val;function val(chain){return function(element,newValue){if(arguments.length>1){element.value=newValue;return chain}return element.value}}},{}],11:[function(require,module,exports){var keynameOf=require("keyname-of");var events=require("on-off");module.exports=on;module.exports.on=on;module.exports.off=off;function on(element,keys,callback){var expected=process(keys);var fn=events.on(element,"keyup",function(event){if((event.ctrlKey||undefined)==expected.ctrl&&(event.altKey||undefined)==expected.alt&&(event.shiftKey||undefined)==expected.shift&&keynameOf(event.keyCode)==expected.key){callback(event)}});callback["cb-"+keys]=fn;return callback}function off(element,keys,callback){events.off(element,"keyup",callback["cb-"+keys])}function process(keys){var result={};keys=keys.split(/[^\w]+/);var i=keys.length,name;while(i--){name=keys[i].trim();if(name=="ctrl"){result.ctrl=true;continue}if(name=="alt"){result.alt=true;continue}if(name=="shift"){result.shift=true;continue}result.key=name.trim()}return result}},{"keyname-of":12,"on-off":25}],12:[function(require,module,exports){var map=require("keynames");module.exports=keynameOf;function keynameOf(n){return map[n]||String.fromCharCode(n).toLowerCase()}},{keynames:21}],13:[function(require,module,exports){module.exports=on;module.exports.on=on;module.exports.off=off;var matches=require("matches-dom-selector"),on=require("on-off");function on(el,selector,type,fn,capture){return on(el,type,function(e){if(matches(e.target||e.srcElement,selector))fn.call(el,e)},capture)}function off(el,type,fn,capture){on.off(el,type,fn,capture)}},{"matches-dom-selector":14,"on-off":25}],14:[function(require,module,exports){var query=require("select-dom");var proto=Element.prototype;var vendor=proto.matchesSelector||proto.webkitMatchesSelector||proto.mozMatchesSelector||proto.msMatchesSelector||proto.oMatchesSelector;module.exports=match;function match(el,selector){if(vendor)return vendor.call(el,selector);var nodes=query.all(selector,el.parentNode);for(var i=0;i<nodes.length;++i){if(nodes[i]==el)return true}return false}},{"select-dom":27}],15:[function(require,module,exports){var newElement=require("./new-element");var select=require("./select");module.exports={add:withChildren(add),addAfter:withChildren(addAfter),addBefore:withChildren(addBefore),insert:insert,replace:replace,remove:remove};function add(parent,child,vars){select(parent).appendChild(newElement(child,vars))}function addAfter(parent,child){var ref=select(arguments[arguments.length-1],parent).nextSibling;var vars=arguments.length>3?arguments[2]:undefined;if(ref==null){return add(parent,child,vars)}addBefore(parent,child,vars,ref)}function addBefore(parent,child){var ref=arguments[arguments.length-1];var vars=arguments.length>3?arguments[2]:undefined;select(parent).insertBefore(newElement(child,vars),select(ref,parent))}function insert(element){var parent=arguments[arguments.length-1];var vars=arguments.length>2?arguments[1]:undefined;add(select(parent),element,vars)}function replace(parent,target,repl,vars){select(parent).replaceChild(select(newElement(repl,vars)),select(target,parent))}function remove(element,child){var i,all;if(arguments.length==1&&typeof element!="string"){return element.parentNode.removeChild(element)}all=arguments.length>1?select.all(child,element):select.all(element);i=all.length;while(i--){all[i].parentNode.removeChild(all[i])}}function withChildren(fn){return function(_,children){if(!Array.isArray(children))children=[children];var i=-1;var len=children.length;var params=Array.prototype.slice.call(arguments);while(++i<len){params[1]=children[i];fn.apply(undefined,params)}}}},{"./new-element":16,"./select":17}],16:[function(require,module,exports){var newElement=require("new-element");module.exports=ifNecessary;function ifNecessary(html,vars){if(!isHTML(html))return html;return newElement(html,vars)}function isHTML(text){return typeof text=="string"&&text.charAt(0)=="<"}},{"new-element":23}],17:[function(require,module,exports){var select=require("select-dom");module.exports=ifNecessary;module.exports.all=ifNecessaryAll;function ifNecessary(child,parent){if(Array.isArray(child)){child=child[0]}if(typeof child!="string"){return child}if(typeof parent=="string"){parent=select(parent,document)}return select(child,parent)}function ifNecessaryAll(child,parent){if(Array.isArray(child)){child=child[0]}if(typeof child!="string"){return[child]}if(typeof parent=="string"){parent=select(parent,document)}return select.all(child,parent)}},{"select-dom":27}],18:[function(require,module,exports){var index=require("indexof");var whitespaceRe=/\s+/;var toString=Object.prototype.toString;module.exports=classes;module.exports.add=add;module.exports.contains=has;module.exports.has=has;module.exports.toggle=toggle;module.exports.remove=remove;module.exports.removeMatching=removeMatching;function classes(el){if(el.classList){return el.classList}var str=el.className.replace(/^\s+|\s+$/g,"");var arr=str.split(whitespaceRe);if(""===arr[0])arr.shift();return arr}function add(el,name){if(el.classList){el.classList.add(name);return}var arr=classes(el);var i=index(arr,name);if(!~i)arr.push(name);el.className=arr.join(" ")}function has(el,name){return el.classList?el.classList.contains(name):!!~index(classes(el),name)}function remove(el,name){if("[object RegExp]"==toString.call(name)){return removeMatching(el,name)}if(el.classList){el.classList.remove(name);return}var arr=classes(el);var i=index(arr,name);if(~i)arr.splice(i,1);el.className=arr.join(" ")}function removeMatching(el,re,ref){var arr=Array.prototype.slice.call(classes(el));for(var i=0;i<arr.length;i++){if(re.test(arr[i])){remove(el,arr[i])}}}function toggle(el,name){if(el.classList){return el.classList.toggle(name)}if(has(el,name)){remove(el,name)}else{add(el,name)}}},{indexof:19}],19:[function(require,module,exports){var indexOf=[].indexOf;module.exports=function(arr,obj){if(indexOf)return arr.indexOf(obj);for(var i=0;i<arr.length;++i){if(arr[i]===obj)return i}return-1}},{}],20:[function(require,module,exports){module.exports=parse;var map={option:[1,'<select multiple="multiple">',"</select>"],optgroup:[1,'<select multiple="multiple">',"</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tbody:[1,"<table>","</table>"],tfoot:[1,"<table>","</table>"],colgroup:[1,"<table>","</table>"],caption:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],th:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]};function parse(html){if("string"!=typeof html)throw new TypeError("String expected");var m=/<([\w:]+)/.exec(html);if(!m)throw new Error("No elements were generated.");var tag=m[1];if(tag=="body"){var el=document.createElement("html");el.innerHTML=html;return el.removeChild(el.lastChild)}var wrap=map[tag]||map._default;var depth=wrap[0];var prefix=wrap[1];var suffix=wrap[2];var el=document.createElement("div");el.innerHTML=prefix+html+suffix;while(depth--)el=el.lastChild;var els=el.children;if(1==els.length){return el.removeChild(els[0])}var fragment=document.createDocumentFragment();while(els.length){fragment.appendChild(el.removeChild(els[0]))}return fragment}},{}],21:[function(require,module,exports){module.exports={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"}},{}],22:[function(require,module,exports){module.exports=newChain;module.exports.from=from;function from(chain){return function(){var m,i;m=methods.apply(undefined,arguments);i=m.length;while(i--){chain[m[i].name]=m[i].fn}m.forEach(function(method){chain[method.name]=function(){method.fn.apply(this,arguments);return chain}});return chain}}function methods(){var all,el,i,len,result,key;all=Array.prototype.slice.call(arguments);result=[];i=all.length;while(i--){el=all[i];if(typeof el=="function"){result.push({name:el.name,fn:el});continue}if(typeof el!="object")continue;for(key in el){result.push({name:key,fn:el[key]})}}return result}function newChain(){return from({}).apply(undefined,arguments)}},{}],23:[function(require,module,exports){var domify=require("domify");var format=require("new-format");module.exports=newElement;function newElement(html,vars){if(!vars)return domify(html);return domify(format(html,vars))}},{domify:20,"new-format":24}],24:[function(require,module,exports){module.exports=format;function findContext(args){if(typeof args[1]=="object"&&args[1])return args[1];return Array.prototype.slice.call(args,1)}function format(text){var context=findContext(arguments);return String(text).replace(/\{?\{([^{}]+)}}?/g,replace(context))}function replace(context,nil){return function(tag,name){if(tag.substring(0,2)=="{{"&&tag.substring(tag.length-2)=="}}"){return"{"+name+"}"}if(!context.hasOwnProperty(name)){return tag}if(typeof context[name]=="function"){return context[name]()}return context[name]}}},{}],25:[function(require,module,exports){module.exports=on;module.exports.on=on;module.exports.off=off;function on(element,event,callback,capture){(element.addEventListener||element.attachEvent).call(element,event,callback,capture);return callback}function off(element,event,callback,capture){(element.removeEventListener||element.detachEvent).call(element,event,callback,capture);return callback}},{}],26:[function(require,module,exports){var qwery=require("qwery");module.exports={one:one,all:all};function all(selector,parent){return qwery(selector,parent)}function one(selector,parent){return all(selector,parent)[0]}},{qwery:28}],27:[function(require,module,exports){var fallback=require("./fallback");module.exports=one;module.exports.all=all;function one(selector,parent){parent||(parent=document);if(parent.querySelector){return parent.querySelector(selector)}return fallback.one(selector,parent)}function all(selector,parent){parent||(parent=document);if(parent.querySelectorAll){return parent.querySelectorAll(selector)}return fallback.all(selector,parent)}},{"./fallback":26}],28:[function(require,module,exports){(function(name,context,definition){if(typeof module!="undefined"&&module.exports)module.exports=definition();else if(typeof define=="function"&&define.amd)define(definition);else context[name]=definition()})("qwery",this,function(){var doc=document,html=doc.documentElement,byClass="getElementsByClassName",byTag="getElementsByTagName",qSA="querySelectorAll",useNativeQSA="useNativeQSA",tagName="tagName",nodeType="nodeType",select,id=/#([\w\-]+)/,clas=/\.[\w\-]+/g,idOnly=/^#([\w\-]+)$/,classOnly=/^\.([\w\-]+)$/,tagOnly=/^([\w\-]+)$/,tagAndOrClass=/^([\w]+)?\.([\w\-]+)$/,splittable=/(^|,)\s*[>~+]/,normalizr=/^\s+|\s*([,\s\+\~>]|$)\s*/g,splitters=/[\s\>\+\~]/,splittersMore=/(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/,specialChars=/([.*+?\^=!:${}()|\[\]\/\\])/g,simple=/^(\*|[a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/,attr=/\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/,pseudo=/:([\w\-]+)(\(['"]?([^()]+)['"]?\))?/,easy=new RegExp(idOnly.source+"|"+tagOnly.source+"|"+classOnly.source),dividers=new RegExp("("+splitters.source+")"+splittersMore.source,"g"),tokenizr=new RegExp(splitters.source+splittersMore.source),chunker=new RegExp(simple.source+"("+attr.source+")?"+"("+pseudo.source+")?");var walker={" ":function(node){return node&&node!==html&&node.parentNode},">":function(node,contestant){return node&&node.parentNode==contestant.parentNode&&node.parentNode},"~":function(node){return node&&node.previousSibling},"+":function(node,contestant,p1,p2){if(!node)return false;return(p1=previous(node))&&(p2=previous(contestant))&&p1==p2&&p1}};function cache(){this.c={}}cache.prototype={g:function(k){return this.c[k]||undefined},s:function(k,v,r){v=r?new RegExp(v):v;return this.c[k]=v}};var classCache=new cache,cleanCache=new cache,attrCache=new cache,tokenCache=new cache;function classRegex(c){return classCache.g(c)||classCache.s(c,"(^|\\s+)"+c+"(\\s+|$)",1)}function each(a,fn){var i=0,l=a.length;for(;i<l;i++)fn(a[i])}function flatten(ar){for(var r=[],i=0,l=ar.length;i<l;++i)arrayLike(ar[i])?r=r.concat(ar[i]):r[r.length]=ar[i];return r}function arrayify(ar){var i=0,l=ar.length,r=[];for(;i<l;i++)r[i]=ar[i];return r}function previous(n){while(n=n.previousSibling)if(n[nodeType]==1)break;return n}function q(query){return query.match(chunker)}function interpret(whole,tag,idsAndClasses,wholeAttribute,attribute,qualifier,value,wholePseudo,pseudo,wholePseudoVal,pseudoVal){var i,m,k,o,classes;if(this[nodeType]!==1)return false;if(tag&&tag!=="*"&&this[tagName]&&this[tagName].toLowerCase()!==tag)return false;if(idsAndClasses&&(m=idsAndClasses.match(id))&&m[1]!==this.id)return false;if(idsAndClasses&&(classes=idsAndClasses.match(clas))){for(i=classes.length;i--;)if(!classRegex(classes[i].slice(1)).test(this.className))return false}if(pseudo&&qwery.pseudos[pseudo]&&!qwery.pseudos[pseudo](this,pseudoVal))return false;if(wholeAttribute&&!value){o=this.attributes;for(k in o){if(Object.prototype.hasOwnProperty.call(o,k)&&(o[k].name||k)==attribute){return this}}}if(wholeAttribute&&!checkAttr(qualifier,getAttr(this,attribute)||"",value)){return false}return this}function clean(s){return cleanCache.g(s)||cleanCache.s(s,s.replace(specialChars,"\\$1"))}function checkAttr(qualify,actual,val){switch(qualify){case"=":return actual==val;case"^=":return actual.match(attrCache.g("^="+val)||attrCache.s("^="+val,"^"+clean(val),1));case"$=":return actual.match(attrCache.g("$="+val)||attrCache.s("$="+val,clean(val)+"$",1));case"*=":return actual.match(attrCache.g(val)||attrCache.s(val,clean(val),1));case"~=":return actual.match(attrCache.g("~="+val)||attrCache.s("~="+val,"(?:^|\\s+)"+clean(val)+"(?:\\s+|$)",1));case"|=":return actual.match(attrCache.g("|="+val)||attrCache.s("|="+val,"^"+clean(val)+"(-|$)",1))}return 0}function _qwery(selector,_root){var r=[],ret=[],i,l,m,token,tag,els,intr,item,root=_root,tokens=tokenCache.g(selector)||tokenCache.s(selector,selector.split(tokenizr)),dividedTokens=selector.match(dividers);if(!tokens.length)return r;token=(tokens=tokens.slice(0)).pop();if(tokens.length&&(m=tokens[tokens.length-1].match(idOnly)))root=byId(_root,m[1]);if(!root)return r;intr=q(token);els=root!==_root&&root[nodeType]!==9&&dividedTokens&&/^[+~]$/.test(dividedTokens[dividedTokens.length-1])?function(r){while(root=root.nextSibling){root[nodeType]==1&&(intr[1]?intr[1]==root[tagName].toLowerCase():1)&&(r[r.length]=root)}return r}([]):root[byTag](intr[1]||"*");for(i=0,l=els.length;i<l;i++){if(item=interpret.apply(els[i],intr))r[r.length]=item}if(!tokens.length)return r;each(r,function(e){if(ancestorMatch(e,tokens,dividedTokens))ret[ret.length]=e});return ret}function is(el,selector,root){if(isNode(selector))return el==selector;if(arrayLike(selector))return!!~flatten(selector).indexOf(el);var selectors=selector.split(","),tokens,dividedTokens;while(selector=selectors.pop()){tokens=tokenCache.g(selector)||tokenCache.s(selector,selector.split(tokenizr));dividedTokens=selector.match(dividers);tokens=tokens.slice(0);if(interpret.apply(el,q(tokens.pop()))&&(!tokens.length||ancestorMatch(el,tokens,dividedTokens,root))){return true}}return false}function ancestorMatch(el,tokens,dividedTokens,root){var cand;function crawl(e,i,p){while(p=walker[dividedTokens[i]](p,e)){if(isNode(p)&&interpret.apply(p,q(tokens[i]))){if(i){if(cand=crawl(p,i-1,p))return cand}else return p}}}return(cand=crawl(el,tokens.length-1,el))&&(!root||isAncestor(cand,root))}function isNode(el,t){return el&&typeof el==="object"&&(t=el[nodeType])&&(t==1||t==9)}function uniq(ar){var a=[],i,j;o:for(i=0;i<ar.length;++i){for(j=0;j<a.length;++j)if(a[j]==ar[i])continue o;a[a.length]=ar[i]}return a}function arrayLike(o){return typeof o==="object"&&isFinite(o.length)}function normalizeRoot(root){if(!root)return doc;if(typeof root=="string")return qwery(root)[0];if(!root[nodeType]&&arrayLike(root))return root[0];return root}function byId(root,id,el){return root[nodeType]===9?root.getElementById(id):root.ownerDocument&&((el=root.ownerDocument.getElementById(id))&&isAncestor(el,root)&&el||!isAncestor(root,root.ownerDocument)&&select('[id="'+id+'"]',root)[0])}function qwery(selector,_root){var m,el,root=normalizeRoot(_root);if(!root||!selector)return[];if(selector===window||isNode(selector)){return!_root||selector!==window&&isNode(root)&&isAncestor(selector,root)?[selector]:[]}if(selector&&arrayLike(selector))return flatten(selector);if(m=selector.match(easy)){if(m[1])return(el=byId(root,m[1]))?[el]:[];if(m[2])return arrayify(root[byTag](m[2]));if(hasByClass&&m[3])return arrayify(root[byClass](m[3]))}return select(selector,root)}function collectSelector(root,collector){return function(s){var oid,nid;if(splittable.test(s)){if(root[nodeType]!==9){if(!(nid=oid=root.getAttribute("id")))root.setAttribute("id",nid="__qwerymeupscotty");s='[id="'+nid+'"]'+s;collector(root.parentNode||root,s,true);oid||root.removeAttribute("id")}return}s.length&&collector(root,s,false)}}var isAncestor="compareDocumentPosition"in html?function(element,container){return(container.compareDocumentPosition(element)&16)==16}:"contains"in html?function(element,container){container=container[nodeType]===9||container==window?html:container;return container!==element&&container.contains(element)}:function(element,container){while(element=element.parentNode)if(element===container)return 1;return 0},getAttr=function(){var e=doc.createElement("p");return(e.innerHTML='<a href="#x">x</a>')&&e.firstChild.getAttribute("href")!="#x"?function(e,a){return a==="class"?e.className:a==="href"||a==="src"?e.getAttribute(a,2):e.getAttribute(a)}:function(e,a){return e.getAttribute(a)}}(),hasByClass=!!doc[byClass],hasQSA=doc.querySelector&&doc[qSA],selectQSA=function(selector,root){var result=[],ss,e;try{if(root[nodeType]===9||!splittable.test(selector)){return arrayify(root[qSA](selector))}each(ss=selector.split(","),collectSelector(root,function(ctx,s){e=ctx[qSA](s);if(e.length==1)result[result.length]=e.item(0);else if(e.length)result=result.concat(arrayify(e))}));return ss.length>1&&result.length>1?uniq(result):result}catch(ex){}return selectNonNative(selector,root)},selectNonNative=function(selector,root){var result=[],items,m,i,l,r,ss;selector=selector.replace(normalizr,"$1");if(m=selector.match(tagAndOrClass)){r=classRegex(m[2]);items=root[byTag](m[1]||"*");for(i=0,l=items.length;i<l;i++){if(r.test(items[i].className))result[result.length]=items[i]}return result}each(ss=selector.split(","),collectSelector(root,function(ctx,s,rewrite){r=_qwery(s,ctx);for(i=0,l=r.length;i<l;i++){if(ctx[nodeType]===9||rewrite||isAncestor(r[i],root))result[result.length]=r[i]}}));return ss.length>1&&result.length>1?uniq(result):result},configure=function(options){if(typeof options[useNativeQSA]!=="undefined")select=!options[useNativeQSA]?selectNonNative:hasQSA?selectQSA:selectNonNative};configure({useNativeQSA:true});qwery.configure=configure;qwery.uniq=uniq;qwery.is=is;qwery.pseudos={};return qwery})},{}],29:[function(require,module,exports){var toCamelCase=require("to-camel-case");module.exports=style;module.exports.hide=effect("display","none");module.exports.show=effect("display","");function all(element,css){var name;for(name in css){one(element,name,css[name])}}function effect(name,value){return function(element,override){style(element,name,arguments.length>1?override:value)}}function one(element,name,value){element.style[toCamelCase(name)]=value}function style(element){if(arguments.length==3){return one(element,arguments[1],arguments[2])}return all(element,arguments[1])}},{"to-camel-case":30}],30:[function(require,module,exports){var toSpace=require("to-space-case");module.exports=toCamelCase;function toCamelCase(string){return toSpace(string).replace(/\s(\w)/g,function(matches,letter){return letter.toUpperCase()})}},{"to-space-case":31}],31:[function(require,module,exports){var clean=require("to-no-case");module.exports=toSpaceCase;function toSpaceCase(string){return clean(string).replace(/[\W_]+(.|$)/g,function(matches,match){return match?" "+match:""})}},{"to-no-case":32}],32:[function(require,module,exports){module.exports=toNoCase;var hasSpace=/\s/;var hasCamel=/[a-z][A-Z]/;var hasSeparator=/[\W_]/;function toNoCase(string){if(hasSpace.test(string))return string.toLowerCase();if(hasSeparator.test(string))string=unseparate(string);if(hasCamel.test(string))string=uncamelize(string);return string.toLowerCase()}var separatorSplitter=/[\W_]+(.|$)/g;function unseparate(string){return string.replace(separatorSplitter,function(m,next){return next?" "+next:""})}var camelSplitter=/(.)([A-Z]+)/g;function uncamelize(string){return string.replace(camelSplitter,function(m,previous,uppers){return previous+" "+uppers.toLowerCase().split("").join(" ")})}},{}],33:[function(require,module,exports){exports=module.exports=trim;function trim(str){return str.replace(/^\s*|\s*$/g,"")}exports.left=function(str){return str.replace(/^\s*/,"")};exports.right=function(str){return str.replace(/\s*$/,"")}},{}]},{},[]);var domready=require("domready"),dom=require("domquery");dom("body").html("<button>This is a button</button>");
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"domready": "1.0.5",
"domquery": "1.0.1"
}
}
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; }
body, html { height: 100%; width: 100%; }</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment