 				dom.setAttribute 'style', styleText
 			@
 
-		@hasClass = (name) ->
-			if doms.length == 0
+		@hasClass = (name) =>
+			if @length == 0
 				return false
 			# if multiple, every DOM should have the class
 			i = 0
-			while i < doms.length
-				classText = doms[i].getAttribute('class') or ''
+			while i < @length
+				classText = @[i].getAttribute 'class' or ''
 				# not use ' ' to avoid multiple spaces like 'a   b'
-				classes = classText.split(RegExp(' +'))
-				if !classes.contains(name)
+				classes = classText.split RegExp ' +'
+				if !classes.contains name
 					return false
 				i++
 			@
 
-		@toggleClass = (name) ->
-			doms.each (dom) ->
+		@addClass = (name) =>
+			@each (dom) ->
+				classText = dom.getAttribute 'class' or ''
+				classes = classText.split RegExp ' +'
+				if not classes.contains name
+					classes.push name
+					dom.setAttribute 'class', classes.join ' '
+			@
+
+		@removeClass = (name) =>
+			@each (dom) ->
 				classText = dom.getAttribute('class') or ''
-				classes = classText.split(RegExp(' +'))
-				if classes.contains(name)
+				classes = classText.split RegExp ' +'
+				if classes.contains name
+					classes.remove name
+					if classes.length > 0
+						dom.setAttribute 'class', classes.join ' '
+					else
+						dom.removeAttribute 'class'
+			@
+
+		@toggleClass = (name) =>
+			@each (dom) ->
+				classText = dom.getAttribute 'class'  or ''
+				classes = classText.split RegExp ' +'
+				if classes.contains name
 					classes.remove name
 				else
 					classes.push name
 				if classes.length > 0
-					dom.setAttribute 'class', classes.join(' ')
+					dom.setAttribute 'class', classes.join ' '
 				else
 					dom.removeAttribute 'class'
-			@
-
-		@addClass = (name) ->
-			doms.each (dom) ->
-				classText = dom.getAttribute('class') or ''
-				classes = classText.split(RegExp(' +'))
-				if !classes.contains(name)
-					classes.push name
-					dom.setAttribute 'class', classes.join(' ')
-			@
-
-		@removeClass = (name) ->
-			doms.each (dom) ->
-				classText = dom.getAttribute('class') or ''
-				classes = classText.split(RegExp(' +'))
-				if classes.contains(name)
-					classes.remove name
-					if classes.length > 0
-						dom.setAttribute 'class', classes.join(' ')
-					else
-						dom.removeAttribute 'class'
 			@
 
 		# Not giving the attribute value means just add the attribute name
 		# or clear the existing attribute value.
 		# No, jQuery is to GET the value
 
-		@attr = (name, value) ->
-			value = value or ''
-			doms.each (dom) ->
+		@attr = (name, value) =>
+			value or= ''
+			@each (dom) ->
 				dom.setAttribute name, value
 			@
 
-		@hasAttr = (name) ->
-			if doms.length == 0
+		@hasAttr = (name) =>
+			if @length == 0
 				return false
 			i = 0
-			while i < doms.length
-				if !doms[i].hasAttribute(name)
+			while i < @length
+				if not @[i].hasAttribute name
 					return false
 				i++
 			@
 
-		@removeAttr = (name) ->
-			doms.each (dom) ->
+		@removeAttr = (name) =>
+			@each (dom) ->
 				dom.removeAttribute name
 			@
 
-		# append
-		SVG_TAGS = 'svg line rect circle ellipse polyline polygon path text'
-
-		@append = (tag) ->
-			doms.each (dom, i) ->
-				newDom = undefined
-				if SVG_TAGS.indexOf(tag.toLowerCase()) > -1
-					newDom = document.createElementNS('http://www.w3.org/2000/svg', tag)
-				else
-					newDom = document.createElement(tag)
-				doms[i] = dom.appendChild(newDom)
-			@
-
-		# event
-
-		@on = (type, callback) ->
-			doms.each (dom) ->
-				dom.addEventListener type, callback
-			@
-
-		@off = (type, callback) ->
-			doms.each (dom) ->
-				dom.removeEventListener type, callback
-			@
-
-	global.$ = (selector) ->
-		selections = []
-		if typeof selector == 'string'
-			selections = [].slice.call(document.querySelectorAll(selector))
-		jQuery.apply selections
-		selections
-
 	# $.ready()
-
 	global.$.ready = (onLoad) ->
 		document.addEventListener 'DOMContentLoaded', onLoad
 

((global) ->

	jQuery = ->
		doms = this

		@text = (str) ->
			doms.each (dom) ->
				dom.textContent = str
			@

		@html = (str) ->
			doms.each (dom) ->
				dom.innerHTML = str
			@

		# == DOM ==
		# this.style
		# this.css( { name: value } )
		# this.hasClass
		# this.addClass
		# this.toggleClass
		# this.removeClass
		# this.attr
		# this.hasAttr
		# this.removeAttr
		# this.append

		@style = (name, value) ->
			doms.each (dom) ->
				styleText = dom.getAttribute('style')
				styles = {}
				if styleText
					styleText.split(';').each (n) ->
						nv = n.split(':')
						styles[nv[0]] = nv[1]
				styles[name] = value
				# concat

			error: function
			complete: function
	###
	global.$.ajax = (url, ops) ->
		if !ops
			if typeof url == 'object'
