Skip to content

Instantly share code, notes, and snippets.

@kaiinui
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaiinui/022162ef47e90748d9f4 to your computer and use it in GitHub Desktop.
Save kaiinui/022162ef47e90748d9f4 to your computer and use it in GitHub Desktop.
Experimental. (465bytes when compressed, 247bytes when gzipped.)
var W=window,E=W.Element,P="prototype";
W.$$ = function(s, c){
return (c ? c : document)['querySelectorAll'](s);
};
W.NodeList[P].each = Array[P].forEach;
W.NodeList[P].forEach = Array[P].forEach;
E[P].find=function(q){
return $$(q, this);
};
E[P].attr=function(key, value){
if(value){
this.setAttribute(key, value);
return this;
}else{
return this.getAttribute(key);
}
};
E[P].css=function(prop, value){
if(value){
this.style[prop]=value;
return this;
}else{
return this.style[prop];
}
};
E[P].on=function(type, callback){
this.addEventListener(type, callback);
return this;
};
@kaiinui
Copy link
Author

kaiinui commented May 31, 2014

To verify minimal jQuery interface.
Working in less dependance to jQuery API is always better.
Mobile networks are still poor.

Supported Methods

  • Selector: $()
  • Selector: $.find()
  • Iterate: $.each(f)
  • Manipulate: $.attr()
  • Manipulate: $.css()
  • Event: $.on()
  • XHR: _.get()
  • XHR: _.post()
  • _.ready(f)

Issues:

  • WIP
  • I haven't done any test.
  • there are no .addClass(), .removeClass(), hasClass()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment