Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cash-dom

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cash-dom - npm Package Compare versions

Comparing version 0.0.3 to 1.0.0

src/_wrapper.js

2

bower.json
{
"name": "cash",
"main": ["dist/cash.min.js", "dist/cash.js"],
"version": "0.0.3",
"version": "1.0.0",
"homepage": "https://github.com/kenwheeler/cash",

@@ -6,0 +6,0 @@ "authors": [

@@ -1,661 +0,662 @@

(function () {
"use strict";
cash = $ = function (selector, context) {
return new cash.fn.init(selector, context);
};
(function (root, factory) {
if (typeof define === "function" && define.amd) {
define(factory);
} else if (typeof exports !== "undefined") {
module.exports = factory();
} else {
root.cash = root.$ = factory();
}
})(this, function () {
var doc = document, win = window, ArrayProto = Array.prototype, slice = ArrayProto.slice, filter = ArrayProto.filter;
cash.fn = cash.prototype = {
cash: true,
length: 0
};
var idMatch = /^#[\w-]*$/, classMatch = /^\.[\w-]*$/, singlet = /^[\w-]*$/;
var idMatch = /^#[\w-]*$/,
classMatch = /^\.[\w-]*$/,
singlet = /^[\w-]*$/;
function cash(selector, context) {
return new cash.fn.init(selector, context);
}
cash.fn.init = function (selector, context) {
var result = [],
matcher, elem;
if (!selector) {
return this;
}
this.length = 1;
if (typeof selector !== "string") {
if (selector.cash) {
return selector;
}
this[0] = selector;
return this;
}
if (selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">" && selector.length >= 3) {
result = $.parseHTML(selector);
} else {
matcher = idMatch.test(selector);
elem = selector.slice(1);
if (!context && matcher) {
this[0] = document.getElementById(elem);
return this;
} else {
context = ($(context)[0] || document);
result = [].slice.call(
singlet.test(elem) ? classMatch.test(selector) ? document.getElementsByClassName(elem) : document.getElementsByTagName(selector) : context.querySelectorAll(selector));
}
}
this.length = 0;
$.merge(this, result);
return this;
};
var fn = cash.fn = cash.prototype = {
cash: true,
length: 0
};
cash.fn.init.prototype = cash.fn;
fn.init = function (selector, context) {
var result = [], matcher, elem;
cash.each = function (collection, callback) {
var i = 0,
l = collection.length;
for (; i < l; i++) {
callback.call(collection[i], collection[i], i, collection);
}
};
if (!selector) {
return this;
}
cash.extend = cash.fn.extend = function (target, source) {
var prop;
if (!source) {
source = target;
target = this;
}
for (prop in source) {
if (source.hasOwnProperty(prop)) {
target[prop] = source[prop];
}
}
this.length = 1;
if (typeof selector !== "string") {
if (selector.cash) {
return selector;
}
this[0] = selector;
return this;
}
if (selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">" && selector.length >= 3) {
result = cash.parseHTML(selector);
} else {
matcher = idMatch.test(selector);
elem = selector.slice(1);
if (!context && matcher) {
this[0] = doc.getElementById(elem);
return this;
};
} else {
context = (cash(context)[0] || doc);
cash.matches = function (el, selector) {
return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector);
};
result = slice.call(singlet.test(elem) ? classMatch.test(selector) ? doc.getElementsByClassName(elem) : doc.getElementsByTagName(selector) : context.querySelectorAll(selector));
}
}
cash.merge = function (first, second) {
var len = +second.length,
j = 0,
i = first.length;
for (; j < len; j++) {
first[i++] = second[j];
}
first.length = i;
return first;
};
this.length = 0;
cash.merge(this, result);
return this;
};
cash.parseHTML = function (str) {
var parsed = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/).exec(str);
if (parsed) {
return [document.createElement(parsed[1])];
}
parsed = buildFragment(str);
return [].slice.call(parsed.childNodes);
};
fn.init.prototype = fn;
cash.unique = function (collection) {
return cash.merge(cash(), [].slice.call(collection).filter(function (item, index, self) {
return self.indexOf(item) === index;
}));
};
function buildFragment(str) {
var fragment = fragment || doc.createDocumentFragment(), tmp = tmp || fragment.appendChild(doc.createElement("div"));
tmp.innerHTML = str;
return tmp;
}
function buildFragment(str) {
var fragment, tmp;
fragment = fragment || document.createDocumentFragment();
tmp = tmp || fragment.appendChild(document.createElement("div"));
tmp.innerHTML = str;
return tmp;
cash.each = function (collection, callback) {
var l = collection.length, i = 0;
for (; i < l; i++) {
callback.call(collection[i], collection[i], i, collection);
}
};
cash.extend = fn.extend = function (target, source) {
var prop;
cash.ajax = function (options) {
var request = new XMLHttpRequest();
request.open(options.type, options.url, true);
request.onload = function () {
if (request.status >= 200 && request.status < 400) {
if (options.success) {
options.success.call(this, request.responseText);
}
} else {
if (options.error) {
options.error.call(this, request.statusText);
}
}
};
request.onerror = function () {
if (options.error) {
options.error.call(this, request.statusText);
}
};
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
request.send(options.data || "");
};
if (!source) {
source = target;
target = this;
}
var notWhiteMatch = /\S+/g;
for (prop in source) {
if (source.hasOwnProperty(prop)) {
target[prop] = source[prop];
}
}
cash.fn.extend({
return target;
};
addClass: function (className) { // TODO: tear out into module for IE9
var classes = className.match(notWhiteMatch),
spacedName, l;
this.each(function (v) {
l = classes.length;
if (v.classList) {
while (l--) {
v.classList.add(classes[l]);
}
} else {
while (l--) {
spacedName = " " + v.className + " ";
if (spacedName.indexOf(" " + classes[l] + " ") === -1) {
v.className += " " + classes[l];
}
}
}
});
return this;
},
cash.matches = function (el, selector) {
return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector);
};
attr: function (attr, value) {
if (!value) {
return this[0].getAttribute(attr);
} else {
this.each(function (v) {
v.setAttribute(attr, value);
});
return this;
}
},
cash.merge = function (first, second) {
var len = +second.length, i = first.length, j = 0;
hasClass: function (className) { // TODO: tear out into module for IE9
if (this[0].classList) {
return this[0].classList.contains(className);
} else {
return this[0].className.indexOf(className) !== -1;
}
},
for (; j < len; i++, j++) {
first[i] = second[j];
}
prop: function (prop) {
return this[0][prop];
},
first.length = i;
return first;
};
removeAttr: function (attr) {
this.each(function (v) {
v.removeAttribute(attr);
});
return this;
},
cash.parseHTML = function (str) {
var parsed = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/).exec(str);
removeClass: function (className) { // TODO: tear out into module for IE9
var classes = className.match(notWhiteMatch),
l, newClassName;
this.each(function (v) {
l = classes.length;
if (v.classList) {
while (l--) {
v.classList.remove(classes[l]);
}
} else {
newClassName = " " + v.className + " ";
while (l--) {
newClassName = newClassName.replace(" " + classes[l] + " ", " ");
}
v.className = newClassName.trim();
}
});
return this;
}
if (parsed) {
return [doc.createElement(parsed[1])];
}
});
parsed = buildFragment(str);
return slice.call(parsed.childNodes);
};
cash.unique = function (collection) {
return cash.merge(cash(), slice.call(collection).filter(function (item, index, self) {
return self.indexOf(item) === index;
}));
};
cash.fn.extend({
var notWhiteMatch = /\S+/g;
add: function () {
var arr = [],
i = 0;
arr = [].slice.call(this);
for (var l = arguments.length; i < l; i++) {
arr = arr.concat([].slice.call(cash(arguments[i])));
}
return cash.unique(arr);
},
fn.extend({
addClass: function (className) {
// TODO: tear out into module for IE9
var classes = className.match(notWhiteMatch), spacedName, l;
each: function (callback) {
cash.each(this, callback);
},
this.each(function (v) {
l = classes.length;
eq: function (index) {
return $(this[index]);
},
if (v.classList) {
while (l--) {
v.classList.add(classes[l]);
}
} else {
while (l--) {
spacedName = " " + v.className + " ";
filter: function () {
if (typeof arguments[0] === "string") {
var selector = arguments[0];
return Array.prototype.filter.call(this, function (e) {
return cash.matches(e, selector);
});
} else {
return Array.prototype.filter.call(this, arguments[0]);
if (spacedName.indexOf(" " + classes[l] + " ") === -1) {
v.className += " " + classes[l];
}
},
}
}
});
first: function () {
return $(this[0]);
},
return this;
},
get: function (num) {
return this[num];
},
attr: function (name, value) {
if (!value) {
return this[0].getAttribute(name);
} else {
this.each(function (v) {
return v.setAttribute(name, value);
});
index: function (elem) {
if (!elem) {
return Array.prototype.slice.call(cash(this[0]).parent().children()).indexOf(this[0]);
} else {
return Array.prototype.slice.call(cash(elem).children()).indexOf(this[0]);
}
},
return this;
}
},
last: function () {
return $(this[this.length - 1]);
}
hasClass: function (className) {
// TODO: tear out into module for IE9
if (this[0].classList) {
return this[0].classList.contains(className);
} else {
return this[0].className.indexOf(className) !== -1;
}
},
});
prop: function (name) {
return this[0][name];
},
cash.fn.extend({
css: function () {
var computed, prop, value, collection;
if (typeof arguments[0] === "object") {
collection = arguments[0];
this.each(function (v) {
for (var key in collection) {
if (collection.hasOwnProperty(key)) {
v.style[key] = collection[key];
}
}
});
} else {
prop = arguments[0];
value = arguments[1];
if (arguments.length > 1) {
this.each(function (v) {
v.style[prop] = value;
});
return this;
} else {
computed = window.getComputedStyle(this[0], null);
return computed[prop];
}
}
}
});
removeAttr: function (name) {
this.each(function (v) {
return v.removeAttribute(name);
});
return this;
},
cash.fn.extend({
removeClass: function (className) {
// TODO: tear out into module for IE9
var classes = className.match(notWhiteMatch), l, newClassName;
data: function (key, value) { // TODO: tear out into module for IE9
if (!value) {
return this[0].dataset ? this[0].dataset[key] : $(this[0]).attr("data-" + key);
} else {
this.each(function (v) {
if (v.dataset) {
v.dataset[key] = value;
} else {
$(v).attr("data-" + key, value);
}
});
return this;
}
},
this.each(function (v) {
l = classes.length;
removeData: function (name) { // TODO: tear out into module for IE9
this.each(function (v) {
if (v.dataset) {
delete v.dataset[name];
} else {
$(v).removeAttr("data-" + name);
}
});
return this;
if (v.classList) {
while (l--) {
v.classList.remove(classes[l]);
}
} else {
newClassName = " " + v.className + " ";
while (l--) {
newClassName = newClassName.replace(" " + classes[l] + " ", " ");
}
v.className = newClassName.trim();
}
});
});
return this;
}
cash.fn.extend({
});
height: function () {
return this[0].getBoundingClientRect().height;
},
fn.extend({
add: function () {
var arr = slice.call(this), i = 0, l;
innerWidth: function () {
return this[0].clientWidth;
},
for (l = arguments.length; i < l; i++) {
arr = arr.concat(slice.call(cash(arguments[i])));
}
innerHeight: function () {
return this[0].clientHeight;
},
return cash.unique(arr);
},
outerWidth: function (margins) {
if (margins === true) {
return this[0].offsetWidth + (parseInt(getComputed(this, "margin-left"), 10) || parseInt(getComputed(this, "marginLeft"), 10) || 0) + (parseInt(getComputed(this, "margin-right"), 10) || parseInt(getComputed(this, "marginRight"), 10) || 0);
}
return this[0].offsetWidth;
},
each: function (callback) {
cash.each(this, callback);
},
outerHeight: function (margins) {
if (margins === true) {
return this[0].offsetHeight + (parseInt(getComputed(this, "margin-top"), 10) || parseInt(getComputed(this, "marginTop"), 10) || 0) + (parseInt(getComputed(this, "margin-bottom"), 10) || parseInt(getComputed(this, "marginBottom"), 10) || 0);
eq: function (index) {
return cash(this[index]);
},
filter: function (selector) {
if (typeof selector === "string") {
return filter.call(this, function (e) {
return cash.matches(e, selector);
});
} else {
return filter.call(this, selector);
}
},
first: function () {
return cash(this[0]);
},
get: function (num) {
return this[num];
},
index: function (elem) {
if (!elem) {
return slice.call(cash(this[0]).parent().children()).indexOf(this[0]);
} else {
return slice.call(cash(elem).children()).indexOf(this[0]);
}
},
last: function () {
return cash(this[this.length - 1]);
}
});
fn.extend({
css: function (prop, value) {
if (typeof prop === "object") {
this.each(function (v) {
for (var key in prop) {
if (prop.hasOwnProperty(key)) {
v.style[key] = prop[key];
}
return this[0].offsetHeight;
},
}
});
} else if (value) {
this.each(function (v) {
return v.style[prop] = value;
});
return this;
} else {
return win.getComputedStyle(this[0], null)[prop];
}
}
width: function () {
return this[0].getBoundingClientRect().width;
});
fn.extend({
data: function (key, value) {
// TODO: tear out into module for IE9
if (!value) {
return this[0].dataset ? this[0].dataset[key] : cash(this[0]).attr("data-" + key);
} else {
this.each(function (v) {
if (v.dataset) {
v.dataset[key] = value;
} else {
cash(v).attr("data-" + key, value);
}
});
return this;
}
},
removeData: function (name) {
// TODO: tear out into module for IE9
this.each(function (v) {
if (v.dataset) {
delete v.dataset[name];
} else {
cash(v).removeAttr("data-" + name);
}
});
});
function getComputed(el, prop) {
var computed;
computed = window.getComputedStyle(el[0], null);
return computed[prop];
return this;
}
var _eventCache = {};
});
cash.fn.extend({
function compute(el, prop) {
return parseInt(win.getComputedStyle(el[0], null)[prop], 10);
}
off: function () {
var eventName = arguments[0],
callback = arguments[1];
this.each(function (v) {
if (callback) {
v.removeEventListener(eventName, callback);
} else {
for (var i in _eventCache[$(v).data("cshid")][eventName]) {
v.removeEventListener(eventName, _eventCache[$(v).data("cshid")][eventName][i]);
}
}
});
return this;
},
fn.extend({
height: function () {
return this[0].getBoundingClientRect().height;
},
on: function () {
var eventName, delegate, callback;
innerWidth: function () {
return this[0].clientWidth;
},
if (typeof arguments[1] === "function") {
eventName = arguments[0];
callback = arguments[1];
this.each(function (v) {
registerEvent($(v), eventName, callback);
v.addEventListener(eventName, callback);
});
return this;
} else {
eventName = arguments[0];
delegate = arguments[1];
callback = arguments[2];
this.each(function (v) {
var handler = function (e) {
var t = e.target;
if ($.matches(t, delegate)) {
callback.call(t);
} else {
while (!$.matches(t, delegate)) {
if (t === v) {
return t = false;
}
t = t.parentNode;
}
if (t) {
callback.call(t);
}
}
};
registerEvent($(v), eventName, handler);
v.addEventListener(eventName, handler);
});
return this;
}
},
innerHeight: function () {
return this[0].clientHeight;
},
ready: function (callback) {
this[0].addEventListener("DOMContentLoaded", callback);
},
outerWidth: function (margins) {
if (margins === true) {
return this[0].offsetWidth + (compute(this, "margin-left") || compute(this, "marginLeft") || 0) + (compute(this, "margin-right") || compute(this, "marginRight") || 0);
}
trigger: function (eventName) {
var evt = document.createEvent("HTMLEvents");
evt.initEvent(eventName, true, false);
this.each(function (v) {
v.dispatchEvent(evt);
});
return this;
}
return this[0].offsetWidth;
},
});
outerHeight: function (margins) {
if (margins === true) {
return this[0].offsetHeight + (compute(this, "margin-top") || compute(this, "marginTop") || 0) + (compute(this, "margin-bottom") || compute(this, "marginBottom") || 0);
}
function registerEvent(node, eventName, callback) {
var nid = $(node).data("cshid") || guid();
$(node).data("cshid", nid);
if (!(nid in _eventCache)) {
_eventCache[nid] = {};
}
if (!(eventName in _eventCache[nid])) {
_eventCache[nid][eventName] = [];
}
_eventCache[nid][eventName].push(callback);
return this[0].offsetHeight;
},
width: function () {
return this[0].getBoundingClientRect().width;
}
function guid() {
function _p8(s) {
var p = (Math.random().toString(16) + "000000000").substr(2, 8);
return s ? "-" + p.substr(0, 4) + "-" + p.substr(4, 4) : p;
}
return _p8() + _p8(true) + _p8(true) + _p8();
});
var _eventCache = {};
function guid() {
function _p8(s) {
var p = (Math.random().toString(16) + "000000000").substr(2, 8);
return s ? "-" + p.substr(0, 4) + "-" + p.substr(4, 4) : p;
}
cash.fn.extend({
return _p8() + _p8(true) + _p8(true) + _p8();
}
serialize: function () {
var form = this[0];
var field, query = "";
for (var i = form.elements.length - 1; i >= 0; i--) {
field = form.elements[i];
if (field.name && field.type !== "file" && field.type !== "reset") {
if (field.type === "select-multiple") {
for (var j = form.elements[i].options.length - 1; j >= 0; j--) {
if (field.options[j].selected) {
query += "&" + field.name + "=" + encodeURIComponent(field.options[j].value).replace(/%20/g, "+");
}
}
}
else {
if ((field.type !== "submit" && field.type !== "button")) {
query += "&" + field.name + "=" + encodeURIComponent(field.value).replace(/%20/g, "+");
}
}
}
}
return query.substr(1);
},
function registerEvent(node, eventName, callback) {
var nid = cash(node).data("cshid") || guid();
val: function (value) {
if (value === undefined) {
return this[0].value;
} else {
this.each(function (v) {
v.value = value;
});
return this;
}
}
cash(node).data("cshid", nid);
});
if (!(nid in _eventCache)) {
_eventCache[nid] = {};
}
cash.fn.extend({
if (!(eventName in _eventCache[nid])) {
_eventCache[nid][eventName] = [];
}
append: function (content) {
this[0].appendChild($(content)[0]);
return this;
},
_eventCache[nid][eventName].push(callback);
}
appendTo: function (content) {
$(content)[0].appendChild(this[0]);
return this;
},
fn.extend({
off: function (eventName, callback) {
this.each(function (v) {
if (callback) {
v.removeEventListener(eventName, callback);
} else {
for (var i in _eventCache[cash(v).data("cshid")][eventName]) {
v.removeEventListener(eventName, _eventCache[cash(v).data("cshid")][eventName][i]);
}
}
});
clone: function () {
return $(this[0].cloneNode(true));
},
return this;
},
empty: function () {
this.each(function (v) {
v.innerHTML = "";
});
return this;
},
on: function (eventName, delegate, callback) {
if (typeof delegate === "function") {
callback = delegate;
html: function (content) {
var source;
if (content === "undefined") {
return this[0].innerHTML;
this.each(function (v) {
registerEvent(cash(v), eventName, callback);
v.addEventListener(eventName, callback);
});
return this;
} else {
this.each(function (v) {
function handler(e) {
var t = e.target;
if (cash.matches(t, delegate)) {
callback.call(t);
} else {
source = typeof content === "object" ? $(content)[0].outerHTML : content;
this.each(function (v) {
v.innerHTML = "" + source;
});
return this;
while (!cash.matches(t, delegate)) {
if (t === v) {
return (t = false);
}
t = t.parentNode;
}
if (t) {
callback.call(t);
}
}
},
}
insertAfter: function (selector) {
$(selector)[0].insertAdjacentHTML("afterend", this[0].outerHTML);
return this;
},
registerEvent(cash(v), eventName, handler);
v.addEventListener(eventName, handler);
});
insertBefore: function (selector) {
$(selector)[0].insertAdjacentHTML("beforebegin", this[0].outerHTML);
return this;
},
return this;
}
},
prepend: function (selector) {
$(this)[0].insertAdjacentHTML("afterBegin", $(selector)[0].outerHTML);
return this;
},
ready: function (callback) {
this[0].addEventListener("DOMContentLoaded", callback);
},
prependTo: function (selector) {
$(selector)[0].insertAdjacentHTML("afterBegin", this[0].outerHTML);
return this;
},
trigger: function (eventName) {
var evt = doc.createEvent("HTMLEvents");
evt.initEvent(eventName, true, false);
this.each(function (v) {
return v.dispatchEvent(evt);
});
return this;
}
remove: function () {
this.each(function (v) {
v.parentNode.removeChild(v);
});
},
});
text: function (content) {
if (!content) {
return this[0].textContent;
} else {
this.each(function (v) {
v.textContent = content;
});
return this;
var encode = encodeURIComponent;
fn.extend({
serialize: function () {
var form = this[0], query = "", field, i, j;
for (i = form.elements.length - 1; i >= 0; i--) {
field = form.elements[i];
if (field.name && field.type !== "file" && field.type !== "reset") {
if (field.type === "select-multiple") {
for (j = form.elements[i].options.length - 1; j >= 0; j--) {
if (field.options[j].selected) {
query += "&" + field.name + "=" + encode(field.options[j].value).replace(/%20/g, "+");
}
}
} else if ((field.type !== "submit" && field.type !== "button")) {
query += "&" + field.name + "=" + encode(field.value).replace(/%20/g, "+");
}
}
}
});
return query.substr(1);
},
cash.fn.extend({
val: function (value) {
if (value === undefined) {
return this[0].value;
} else {
this.each(function (v) {
return v.value = value;
});
return this;
}
}
children: function (selector) {
if (!selector) {
var children = this[0].children;
cash.fn.extend(children, cash.fn);
return children;
} else {
return cash(this[0].children).filter(function (v) {
return cash.matches(v, selector);
});
}
},
});
closest: function (selector) {
if (!selector || cash.matches(this[0], selector)) {
return this;
} else {
return this.parent().closest(selector);
}
},
fn.extend({
append: function (content) {
this[0].appendChild(cash(content)[0]);
return this;
},
is: function (selector) {
if (!selector) {
return false;
}
if (selector.cash) {
return this[0] === selector[0];
}
return typeof selector === "string" ? cash.matches(this[0], selector) : false;
},
appendTo: function (content) {
cash(content)[0].appendChild(this[0]);
return this;
},
find: function (selector) {
var result;
result = this[0].querySelectorAll(selector);
cash.fn.extend(result, cash.fn);
return result;
},
clone: function () {
return cash(this[0].cloneNode(true));
},
has: function (selector) {
return Array.prototype.filter.call(this, function (el) {
return cash(el).find(selector).length !== 0;
});
},
empty: function () {
this.each(function (v) {
return v.innerHTML = "";
});
return this;
},
next: function () {
return cash(this[0].nextElementSibling);
},
html: function (content) {
var source;
not: function (selector) {
return Array.prototype.filter.call(this, function (el) {
return !cash.matches(el, selector);
});
},
if (content === "undefined") {
return this[0].innerHTML;
} else {
source = typeof content === "object" ? cash(content)[0].outerHTML : content;
this.each(function (v) {
return v.innerHTML = "" + source;
});
return this;
}
},
parent: function () {
var result = Array.prototype.map.call(this, function (item) {
return item.parentElement || document.body.parentNode;
});
return cash.unique(result);
},
insertAfter: function (selector) {
cash(selector)[0].insertAdjacentHTML("afterend", this[0].outerHTML);
return this;
},
parents: function (selector) {
var last, result = [],
count = 0;
this.each(function (item) {
last = item;
while (last !== document.body.parentNode) {
last = last.parentElement;
if (!selector || (selector && cash.matches(last, selector))) {
result[count] = last;
count++;
}
}
});
return cash.unique(result);
},
insertBefore: function (selector) {
cash(selector)[0].insertAdjacentHTML("beforebegin", this[0].outerHTML);
return this;
},
prev: function () {
return cash(this[0].previousElementSibling);
},
prepend: function (selector) {
cash(this)[0].insertAdjacentHTML("afterBegin", cash(selector)[0].outerHTML);
return this;
},
siblings: function () {
var collection = this.parent().children(),
el = this[0];
return Array.prototype.filter.call(collection, function (i) {
return i !== el;
});
prependTo: function (selector) {
cash(selector)[0].insertAdjacentHTML("afterBegin", this[0].outerHTML);
return this;
},
remove: function () {
this.each(function (v) {
return v.parentNode.removeChild(v);
});
},
text: function (content) {
if (!content) {
return this[0].textContent;
} else {
this.each(function (v) {
return v.textContent = content;
});
return this;
}
}
});
fn.extend({
children: function (selector) {
if (!selector) {
return cash.fn.extend(this[0].children, cash.fn);
} else {
return cash(this[0].children).filter(function (v) {
return cash.matches(v, selector);
});
}
},
closest: function (selector) {
if (!selector || cash.matches(this[0], selector)) {
return this;
} else {
return this.parent().closest(selector);
}
},
is: function (selector) {
if (!selector) {
return false;
}
if (selector.cash) {
return this[0] === selector[0];
}
return typeof selector === "string" ? cash.matches(this[0], selector) : false;
},
find: function (selector) {
return cash.fn.extend(this[0].querySelectorAll(selector), cash.fn);
},
has: function (selector) {
return filter.call(this, function (el) {
return cash(el).find(selector).length !== 0;
});
},
next: function () {
return cash(this[0].nextElementSibling);
},
not: function (selector) {
return filter.call(this, function (el) {
return !cash.matches(el, selector);
});
},
parent: function () {
var result = ArrayProto.map.call(this, function (item) {
return item.parentElement || doc.body.parentNode;
});
return cash.unique(result);
},
parents: function (selector) {
var last, result = [], count = 0;
this.each(function (item) {
last = item;
while (last !== doc.body.parentNode) {
last = last.parentElement;
if (!selector || (selector && cash.matches(last, selector))) {
result[count] = last;
count++;
}
}
});
});
}.call(window));
return cash.unique(result);
},
prev: function () {
return cash(this[0].previousElementSibling);
},
siblings: function () {
var collection = this.parent().children(), el = this[0];
return filter.call(collection, function (i) {
return i !== el;
});
}
});
return cash;
});

@@ -1,1 +0,1 @@

(function(){function t(t){var e,n;return e=e||document.createDocumentFragment(),n=n||e.appendChild(document.createElement("div")),n.innerHTML=t,n}function e(t,e){var n;return n=window.getComputedStyle(t[0],null),n[e]}function n(t,e,n){var i=$(t).data("cshid")||r();$(t).data("cshid",i),i in h||(h[i]={}),e in h[i]||(h[i][e]=[]),h[i][e].push(n)}function r(){function t(t){var e=(Math.random().toString(16)+"000000000").substr(2,8);return t?"-"+e.substr(0,4)+"-"+e.substr(4,4):e}return t()+t(!0)+t(!0)+t()}cash=$=function(t,e){return new cash.fn.init(t,e)},cash.fn=cash.prototype={cash:!0,length:0};var i=/^#[\w-]*$/,s=/^\.[\w-]*$/,a=/^[\w-]*$/;cash.fn.init=function(t,e){var n,r,c=[];if(!t)return this;if(this.length=1,"string"!=typeof t)return t.cash?t:(this[0]=t,this);if("<"===t.charAt(0)&&">"===t.charAt(t.length-1)&&t.length>=3)c=$.parseHTML(t);else{if(n=i.test(t),r=t.slice(1),!e&&n)return this[0]=document.getElementById(r),this;e=$(e)[0]||document,c=[].slice.call(a.test(r)?s.test(t)?document.getElementsByClassName(r):document.getElementsByTagName(t):e.querySelectorAll(t))}return this.length=0,$.merge(this,c),this},cash.fn.init.prototype=cash.fn,cash.each=function(t,e){for(var n=0,r=t.length;r>n;n++)e.call(t[n],t[n],n,t)},cash.extend=cash.fn.extend=function(t,e){var n;e||(e=t,t=this);for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return this},cash.matches=function(t,e){return(t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector).call(t,e)},cash.merge=function(t,e){for(var n=+e.length,r=0,i=t.length;n>r;r++)t[i++]=e[r];return t.length=i,t},cash.parseHTML=function(e){var n=/^<(\w+)\s*\/?>(?:<\/\1>|)$/.exec(e);return n?[document.createElement(n[1])]:(n=t(e),[].slice.call(n.childNodes))},cash.unique=function(t){return cash.merge(cash(),[].slice.call(t).filter(function(t,e,n){return n.indexOf(t)===e}))},cash.ajax=function(t){var e=new XMLHttpRequest;e.open(t.type,t.url,!0),e.onload=function(){e.status>=200&&e.status<400?t.success&&t.success.call(this,e.responseText):t.error&&t.error.call(this,e.statusText)},e.onerror=function(){t.error&&t.error.call(this,e.statusText)},e.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),e.send(t.data||"")};var c=/\S+/g;cash.fn.extend({addClass:function(t){var e,n,r=t.match(c);return this.each(function(t){if(n=r.length,t.classList)for(;n--;)t.classList.add(r[n]);else for(;n--;)e=" "+t.className+" ",-1===e.indexOf(" "+r[n]+" ")&&(t.className+=" "+r[n])}),this},attr:function(t,e){return e?(this.each(function(n){n.setAttribute(t,e)}),this):this[0].getAttribute(t)},hasClass:function(t){return this[0].classList?this[0].classList.contains(t):-1!==this[0].className.indexOf(t)},prop:function(t){return this[0][t]},removeAttr:function(t){return this.each(function(e){e.removeAttribute(t)}),this},removeClass:function(t){var e,n,r=t.match(c);return this.each(function(t){if(e=r.length,t.classList)for(;e--;)t.classList.remove(r[e]);else{for(n=" "+t.className+" ";e--;)n=n.replace(" "+r[e]+" "," ");t.className=n.trim()}}),this}}),cash.fn.extend({add:function(){var t=[],e=0;t=[].slice.call(this);for(var n=arguments.length;n>e;e++)t=t.concat([].slice.call(cash(arguments[e])));return cash.unique(t)},each:function(t){cash.each(this,t)},eq:function(t){return $(this[t])},filter:function(){if("string"==typeof arguments[0]){var t=arguments[0];return Array.prototype.filter.call(this,function(e){return cash.matches(e,t)})}return Array.prototype.filter.call(this,arguments[0])},first:function(){return $(this[0])},get:function(t){return this[t]},index:function(t){return t?Array.prototype.slice.call(cash(t).children()).indexOf(this[0]):Array.prototype.slice.call(cash(this[0]).parent().children()).indexOf(this[0])},last:function(){return $(this[this.length-1])}}),cash.fn.extend({css:function(){var t,e,n,r;return"object"!=typeof arguments[0]?(e=arguments[0],n=arguments[1],arguments.length>1?(this.each(function(t){t.style[e]=n}),this):(t=window.getComputedStyle(this[0],null),t[e])):(r=arguments[0],void this.each(function(t){for(var e in r)r.hasOwnProperty(e)&&(t.style[e]=r[e])}))}}),cash.fn.extend({data:function(t,e){return e?(this.each(function(n){n.dataset?n.dataset[t]=e:$(n).attr("data-"+t,e)}),this):this[0].dataset?this[0].dataset[t]:$(this[0]).attr("data-"+t)},removeData:function(t){return this.each(function(e){e.dataset?delete e.dataset[t]:$(e).removeAttr("data-"+t)}),this}}),cash.fn.extend({height:function(){return this[0].getBoundingClientRect().height},innerWidth:function(){return this[0].clientWidth},innerHeight:function(){return this[0].clientHeight},outerWidth:function(t){return t===!0?this[0].offsetWidth+(parseInt(e(this,"margin-left"),10)||parseInt(e(this,"marginLeft"),10)||0)+(parseInt(e(this,"margin-right"),10)||parseInt(e(this,"marginRight"),10)||0):this[0].offsetWidth},outerHeight:function(t){return t===!0?this[0].offsetHeight+(parseInt(e(this,"margin-top"),10)||parseInt(e(this,"marginTop"),10)||0)+(parseInt(e(this,"margin-bottom"),10)||parseInt(e(this,"marginBottom"),10)||0):this[0].offsetHeight},width:function(){return this[0].getBoundingClientRect().width}});var h={};cash.fn.extend({off:function(){var t=arguments[0],e=arguments[1];return this.each(function(n){if(e)n.removeEventListener(t,e);else for(var r in h[$(n).data("cshid")][t])n.removeEventListener(t,h[$(n).data("cshid")][t][r])}),this},on:function(){var t,e,r;return"function"==typeof arguments[1]?(t=arguments[0],r=arguments[1],this.each(function(e){n($(e),t,r),e.addEventListener(t,r)}),this):(t=arguments[0],e=arguments[1],r=arguments[2],this.each(function(i){var s=function(t){var n=t.target;if($.matches(n,e))r.call(n);else{for(;!$.matches(n,e);){if(n===i)return n=!1;n=n.parentNode}n&&r.call(n)}};n($(i),t,s),i.addEventListener(t,s)}),this)},ready:function(t){this[0].addEventListener("DOMContentLoaded",t)},trigger:function(t){var e=document.createEvent("HTMLEvents");return e.initEvent(t,!0,!1),this.each(function(t){t.dispatchEvent(e)}),this}}),cash.fn.extend({serialize:function(){for(var t,e=this[0],n="",r=e.elements.length-1;r>=0;r--)if(t=e.elements[r],t.name&&"file"!==t.type&&"reset"!==t.type)if("select-multiple"===t.type)for(var i=e.elements[r].options.length-1;i>=0;i--)t.options[i].selected&&(n+="&"+t.name+"="+encodeURIComponent(t.options[i].value).replace(/%20/g,"+"));else"submit"!==t.type&&"button"!==t.type&&(n+="&"+t.name+"="+encodeURIComponent(t.value).replace(/%20/g,"+"));return n.substr(1)},val:function(t){return void 0===t?this[0].value:(this.each(function(e){e.value=t}),this)}}),cash.fn.extend({append:function(t){return this[0].appendChild($(t)[0]),this},appendTo:function(t){return $(t)[0].appendChild(this[0]),this},clone:function(){return $(this[0].cloneNode(!0))},empty:function(){return this.each(function(t){t.innerHTML=""}),this},html:function(t){var e;return"undefined"===t?this[0].innerHTML:(e="object"==typeof t?$(t)[0].outerHTML:t,this.each(function(t){t.innerHTML=""+e}),this)},insertAfter:function(t){return $(t)[0].insertAdjacentHTML("afterend",this[0].outerHTML),this},insertBefore:function(t){return $(t)[0].insertAdjacentHTML("beforebegin",this[0].outerHTML),this},prepend:function(t){return $(this)[0].insertAdjacentHTML("afterBegin",$(t)[0].outerHTML),this},prependTo:function(t){return $(t)[0].insertAdjacentHTML("afterBegin",this[0].outerHTML),this},remove:function(){this.each(function(t){t.parentNode.removeChild(t)})},text:function(t){return t?(this.each(function(e){e.textContent=t}),this):this[0].textContent}}),cash.fn.extend({children:function(t){if(t)return cash(this[0].children).filter(function(e){return cash.matches(e,t)});var e=this[0].children;return cash.fn.extend(e,cash.fn),e},closest:function(t){return!t||cash.matches(this[0],t)?this:this.parent().closest(t)},is:function(t){return t?t.cash?this[0]===t[0]:"string"==typeof t?cash.matches(this[0],t):!1:!1},find:function(t){var e;return e=this[0].querySelectorAll(t),cash.fn.extend(e,cash.fn),e},has:function(t){return Array.prototype.filter.call(this,function(e){return 0!==cash(e).find(t).length})},next:function(){return cash(this[0].nextElementSibling)},not:function(t){return Array.prototype.filter.call(this,function(e){return!cash.matches(e,t)})},parent:function(){var t=Array.prototype.map.call(this,function(t){return t.parentElement||document.body.parentNode});return cash.unique(t)},parents:function(t){var e,n=[],r=0;return this.each(function(i){for(e=i;e!==document.body.parentNode;)e=e.parentElement,(!t||t&&cash.matches(e,t))&&(n[r]=e,r++)}),cash.unique(n)},prev:function(){return cash(this[0].previousElementSibling)},siblings:function(){var t=this.parent().children(),e=this[0];return Array.prototype.filter.call(t,function(t){return t!==e})}})}).call(window);
"use strict";!function(t,e){"function"==typeof define&&define.amd?define(e):"undefined"!=typeof exports?module.exports=e():t.cash=t.$=e()}(this,function(){function t(e,n){return new t.fn.init(e,n)}function e(t){var e=e||s.createDocumentFragment(),n=n||e.appendChild(s.createElement("div"));return n.innerHTML=t,n}function n(t,e){return parseInt(u.getComputedStyle(t[0],null)[e],10)}function i(){function t(t){var e=(Math.random().toString(16)+"000000000").substr(2,8);return t?"-"+e.substr(0,4)+"-"+e.substr(4,4):e}return t()+t(!0)+t(!0)+t()}function r(e,n,r){var s=t(e).data("cshid")||i();t(e).data("cshid",s),s in p||(p[s]={}),n in p[s]||(p[s][n]=[]),p[s][n].push(r)}var s=document,u=window,c=Array.prototype,a=c.slice,h=c.filter,o=/^#[\w-]*$/,f=/^\.[\w-]*$/,l=/^[\w-]*$/,d=t.fn=t.prototype={cash:!0,length:0};d.init=function(e,n){var i,r,u=[];if(!e)return this;if(this.length=1,"string"!=typeof e)return e.cash?e:(this[0]=e,this);if("<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3)u=t.parseHTML(e);else{if(i=o.test(e),r=e.slice(1),!n&&i)return this[0]=s.getElementById(r),this;n=t(n)[0]||s,u=a.call(l.test(r)?f.test(e)?s.getElementsByClassName(r):s.getElementsByTagName(e):n.querySelectorAll(e))}return this.length=0,t.merge(this,u),this},d.init.prototype=d,t.each=function(t,e){for(var n=t.length,i=0;n>i;i++)e.call(t[i],t[i],i,t)},t.extend=d.extend=function(t,e){var n;e||(e=t,t=this);for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t},t.matches=function(t,e){return(t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector).call(t,e)},t.merge=function(t,e){for(var n=+e.length,i=t.length,r=0;n>r;i++,r++)t[i]=e[r];return t.length=i,t},t.parseHTML=function(t){var n=/^<(\w+)\s*\/?>(?:<\/\1>|)$/.exec(t);return n?[s.createElement(n[1])]:(n=e(t),a.call(n.childNodes))},t.unique=function(e){return t.merge(t(),a.call(e).filter(function(t,e,n){return n.indexOf(t)===e}))};var m=/\S+/g;d.extend({addClass:function(t){var e,n,i=t.match(m);return this.each(function(t){if(n=i.length,t.classList)for(;n--;)t.classList.add(i[n]);else for(;n--;)e=" "+t.className+" ",-1===e.indexOf(" "+i[n]+" ")&&(t.className+=" "+i[n])}),this},attr:function(t,e){return e?(this.each(function(n){return n.setAttribute(t,e)}),this):this[0].getAttribute(t)},hasClass:function(t){return this[0].classList?this[0].classList.contains(t):-1!==this[0].className.indexOf(t)},prop:function(t){return this[0][t]},removeAttr:function(t){return this.each(function(e){return e.removeAttribute(t)}),this},removeClass:function(t){var e,n,i=t.match(m);return this.each(function(t){if(e=i.length,t.classList)for(;e--;)t.classList.remove(i[e]);else{for(n=" "+t.className+" ";e--;)n=n.replace(" "+i[e]+" "," ");t.className=n.trim()}}),this}}),d.extend({add:function(){var e,n=a.call(this),i=0;for(e=arguments.length;e>i;i++)n=n.concat(a.call(t(arguments[i])));return t.unique(n)},each:function(e){t.each(this,e)},eq:function(e){return t(this[e])},filter:function(e){return"string"==typeof e?h.call(this,function(n){return t.matches(n,e)}):h.call(this,e)},first:function(){return t(this[0])},get:function(t){return this[t]},index:function(e){return e?a.call(t(e).children()).indexOf(this[0]):a.call(t(this[0]).parent().children()).indexOf(this[0])},last:function(){return t(this[this.length-1])}}),d.extend({css:function(t,e){return"object"!=typeof t?e?(this.each(function(n){return n.style[t]=e}),this):u.getComputedStyle(this[0],null)[t]:void this.each(function(e){for(var n in t)t.hasOwnProperty(n)&&(e.style[n]=t[n])})}}),d.extend({data:function(e,n){return n?(this.each(function(i){i.dataset?i.dataset[e]=n:t(i).attr("data-"+e,n)}),this):this[0].dataset?this[0].dataset[e]:t(this[0]).attr("data-"+e)},removeData:function(e){return this.each(function(n){n.dataset?delete n.dataset[e]:t(n).removeAttr("data-"+e)}),this}}),d.extend({height:function(){return this[0].getBoundingClientRect().height},innerWidth:function(){return this[0].clientWidth},innerHeight:function(){return this[0].clientHeight},outerWidth:function(t){return t===!0?this[0].offsetWidth+(n(this,"margin-left")||n(this,"marginLeft")||0)+(n(this,"margin-right")||n(this,"marginRight")||0):this[0].offsetWidth},outerHeight:function(t){return t===!0?this[0].offsetHeight+(n(this,"margin-top")||n(this,"marginTop")||0)+(n(this,"margin-bottom")||n(this,"marginBottom")||0):this[0].offsetHeight},width:function(){return this[0].getBoundingClientRect().width}});var p={};d.extend({off:function(e,n){return this.each(function(i){if(n)i.removeEventListener(e,n);else for(var r in p[t(i).data("cshid")][e])i.removeEventListener(e,p[t(i).data("cshid")][e][r])}),this},on:function(e,n,i){return"function"==typeof n?(i=n,this.each(function(n){r(t(n),e,i),n.addEventListener(e,i)}),this):(this.each(function(s){function u(e){var r=e.target;if(t.matches(r,n))i.call(r);else{for(;!t.matches(r,n);){if(r===s)return r=!1;r=r.parentNode}r&&i.call(r)}}r(t(s),e,u),s.addEventListener(e,u)}),this)},ready:function(t){this[0].addEventListener("DOMContentLoaded",t)},trigger:function(t){var e=s.createEvent("HTMLEvents");return e.initEvent(t,!0,!1),this.each(function(t){return t.dispatchEvent(e)}),this}});var g=encodeURIComponent;return d.extend({serialize:function(){var t,e,n,i=this[0],r="";for(e=i.elements.length-1;e>=0;e--)if(t=i.elements[e],t.name&&"file"!==t.type&&"reset"!==t.type)if("select-multiple"===t.type)for(n=i.elements[e].options.length-1;n>=0;n--)t.options[n].selected&&(r+="&"+t.name+"="+g(t.options[n].value).replace(/%20/g,"+"));else"submit"!==t.type&&"button"!==t.type&&(r+="&"+t.name+"="+g(t.value).replace(/%20/g,"+"));return r.substr(1)},val:function(t){return void 0===t?this[0].value:(this.each(function(e){return e.value=t}),this)}}),d.extend({append:function(e){return this[0].appendChild(t(e)[0]),this},appendTo:function(e){return t(e)[0].appendChild(this[0]),this},clone:function(){return t(this[0].cloneNode(!0))},empty:function(){return this.each(function(t){return t.innerHTML=""}),this},html:function(e){var n;return"undefined"===e?this[0].innerHTML:(n="object"==typeof e?t(e)[0].outerHTML:e,this.each(function(t){return t.innerHTML=""+n}),this)},insertAfter:function(e){return t(e)[0].insertAdjacentHTML("afterend",this[0].outerHTML),this},insertBefore:function(e){return t(e)[0].insertAdjacentHTML("beforebegin",this[0].outerHTML),this},prepend:function(e){return t(this)[0].insertAdjacentHTML("afterBegin",t(e)[0].outerHTML),this},prependTo:function(e){return t(e)[0].insertAdjacentHTML("afterBegin",this[0].outerHTML),this},remove:function(){this.each(function(t){return t.parentNode.removeChild(t)})},text:function(t){return t?(this.each(function(e){return e.textContent=t}),this):this[0].textContent}}),d.extend({children:function(e){return e?t(this[0].children).filter(function(n){return t.matches(n,e)}):t.fn.extend(this[0].children,t.fn)},closest:function(e){return!e||t.matches(this[0],e)?this:this.parent().closest(e)},is:function(e){return e?e.cash?this[0]===e[0]:"string"==typeof e?t.matches(this[0],e):!1:!1},find:function(e){return t.fn.extend(this[0].querySelectorAll(e),t.fn)},has:function(e){return h.call(this,function(n){return 0!==t(n).find(e).length})},next:function(){return t(this[0].nextElementSibling)},not:function(e){return h.call(this,function(n){return!t.matches(n,e)})},parent:function(){var e=c.map.call(this,function(t){return t.parentElement||s.body.parentNode});return t.unique(e)},parents:function(e){var n,i=[],r=0;return this.each(function(u){for(n=u;n!==s.body.parentNode;)n=n.parentElement,(!e||e&&t.matches(n,e))&&(i[r]=n,r++)}),t.unique(i)},prev:function(){return t(this[0].previousElementSibling)},siblings:function(){var t=this.parent().children(),e=this[0];return h.call(t,function(t){return t!==e})}}),t});
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
gulp.task('build', function () {
return gulp.src(['./src/core.js','./src/util.js','./src/*.js'])
.pipe($.concat("cash.js"))
return gulp.src('./src/_wrapper.js')
.pipe($.preprocess())
.pipe($.rename('cash.js'))
.pipe($['6to5']())
.pipe($.size())
.pipe($.wrap('(function(){<%= contents %>}.call(window));'))
.pipe($.beautify())
.pipe(gulp.dest('./dist/'));
});
gulp.task('minify', ['build'], function () {
gulp.task('minify', ['build'], function() {
return gulp.src(['./dist/cash.js'])
.pipe($.uglify())
.pipe($.size())
.pipe($.rename("cash.min.js"))
.pipe($.rename('cash.min.js'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('lint', ['build'], function() {
return gulp.src('./dist/cash.js')
gulp.task('lint', function() {
return gulp.src(['src/*.js', '!src/_*.js'])
.pipe($.jshint())

@@ -30,6 +29,6 @@ .pipe($.jshint.reporter('default'));

gulp.task('default', ['build','minify','lint']);
gulp.task('default', ['build', 'minify', 'lint']);
gulp.task('watch', function () {
gulp.watch(['src/*.js','test/src/*.js'], ['build','minify','lint']);
});
gulp.task('watch', function() {
gulp.watch(['src/*.js', 'test/src/*.js'], ['build', 'minify', 'lint']);
});
{
"name": "cash-dom",
"main": "./dist/cash.min.js",
"version": "0.0.3",
"dependencies": {},
"version": "1.0.0",
"description": "An absurdly small jQuery alternative for modern browsers.",
"main": "./dist/cash.js",
"repository": {
"type": "git",
"url": "https://github.com/kenwheeler/cash.git"
},
"author": "Ken Wheeler <ken_wheeler@me.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/kenwheeler/cash/issues"
},
"homepage": "https://github.com/kenwheeler/cash",
"scripts": {
"build": "gulp",
"test": "gulp test"
},
"devDependencies": {
"6to5": "^1.14.11",
"gulp": "~3.5.0",
"gulp-6to5": "^1.0.2",
"gulp-connect": "~1.0.0",
"gulp-jshint": "~1.8.4",
"gulp-load-plugins": "~0.3.0",
"gulp-util": "~2.2.9",
"gulp-preprocess": "^1.1.1",
"gulp-rename": "^1.2.0",
"gulp-size": "~0.1.2",
"gulp-connect": "~1.0.0",
"gulp-concat": "~2.1.7",
"gulp-uglify": "~1.0.1",
"gulp-jshint": "~1.8.4",
"gulp-rename": "~1.2.0",
"gulp-wrap": "~0.3.0",
"gulp-beautify": "~1.1.0"
"gulp-util": "~2.2.9",
"gulp-wrap": "~0.3.0"
},
"engines": {
"node": ">=0.10.0"
}
"dependencies": {}
}

@@ -1,550 +0,518 @@

# cash
Cash
====
http://kenwheeler.github.io/cash
An absurdly small jQuery alternative for modern browsers
## An absurdly small jQuery alternative for modern browsers
## Usage
Add cash to your project via the jsDelivr CDN:
<script type="text/javascript" src="//cdn.jsdelivr.net/cash/0.0.3/cash.min.js"></script>
```html
<script type="text/javascript" src="//cdn.jsdelivr.net/cash/0.0.3/cash.min.js"></script>
```
### what is cash?
### What is Cash?
cash is a small library for modern browsers that provides jQuery style syntax to wrap modern Vanilla JS features.
Cash is a small library for modern browsers that provides jQuery style syntax
to wrap modern Vanilla JS features. It allows developers to use the jQuery
syntax they already know, and utilizes modern browser features to minimize the
codebase. 100% feature parity with jQuery isn't a goal, but cash comes helpfully
close, covering most day to day use cases.
It allows developers to use the jQuery syntax they already know, and utilizes modern browser features to minimize the codebase.
## Documentation
100% feature parity with jQuery isn't a goal, but cash comes helpfully close, covering most day to day use cases.
## documentation
### $()
This is the main selector method for cash. It returns an actionable collection
of nodes.
$(selector,[context]) => collection
$(collection) => self
$(DOM elements) => collection
$(HTML) => collection
```js
$(selector,[context]) // => collection
$(collection) // => self
$(DOM elements) // => collection
$(HTML) // => collection
```
This is the main selector method for cash. It returns an actionable collection of nodes.
### $.ajax
$.ajax(options)
Initiates an AJAX request with the given options and triggers the appropriate callback.
#####Options
* type : String- ie: 'POST', 'GET'
* url : String- The target url
* data - Serialized data or object
* success(response) : Function- Success callback
* error : Function Error callback
### $.each
Iterates through a collection and calls the callback method on each.
$.each(collection, callback) => collection
```js
$.each(collection, callback) // => collection
```
Iterates through a collection and calls the callback method on each.
### $.extend
$.extend(target,source) => object
Extends target object with properties from the source object.
```js
$.extend(target,source) // => object
```
### $.matches
$.matches(element, selector) => boolean
Checks a selector against an element, returning a boolean value for match.
```js
$.matches(element, selector) // => boolean
```
### $.parseHTML
$.parseHTML(htmlString) => collection
Returns a collection from an HTML string.
```js
$.parseHTML(htmlString) // => Collection
```
### $.fn
$.fn => cash.prototype
The main prototype. Adding properties and methods will add it to all collections
```js
$.fn // => cash.prototype
```
### add
### $.fn.add
Returns a new collection with the element added to the end, will accept any
amount of arguments and add them all in sequence.
```js
$(element).add(element) // => collection
$(element).add(selector) // => collection
```
add(element) => collection
add(selector) => collection
### $.fn.addClass
Returns a new collection with the element added to the end, will accept any amount of arguments and add them all in sequence.
### addClass
addClass(className) => collection
Adds the className argument to collection elements.
### append
```js
$(element).addClass(className) // => collection
```
append(element) => collection
### $.fn.append
Appends the target element to the first element in the collection.
### appendTo
```js
$(element).append(element) // => collection
```
appendTo(element) => collection
### $.fn.appendTo
Adds the first element in a collection to the target element.
### attr
```js
$(element).appendTo(element) // => collection
```
### $.fn.attr
Without attrValue, returns the attribute value of the first element in the
collection. With attrValue, sets the attribute value of each element of the
collection.
attr(attrName) => AttributeValue
attr(attrName, attrValue) => collection
```js
$(element).attr(attrName) // => AttributeValue
$(element).attr(attrName, attrValue) // => collection
```
### $.fn.children
Without attrValue, returns the attribute value of the first element in the collection. With attrValue, sets the attribute value of each element of the collection.
Without a selector specified, returns a collection of child elements. With a
selector, returns child elements that match the selector.
### children
```js
$(element).children() // => collection
$(element).children(selector) // => collection
```
### $.fn.closest
children() => collection
children(selector) => collection
Without a selector specified, returns a collection of child elements
. With a selector, returns child elements that match the selector.
### closest
closest() => collection
closest(selector) => collection
Returns the closest matching selector up the DOM tree.
### clone
```js
$(element).closest() // => collection
$(element).closest(selector) // => collection
```
### $.fn.clone
clone() => collection
Returns a clone of the collection.
### css
```js
$(element).clone() // => collection
```
### $.fn.css
Returns a CSS property value when just property is supplied. Sets a CSS property
when property and value are supplied, and set multiple properties when an object
is supplied.
css(property) => value
css(property,value) => collection
css(object) => collection
```js
$(element).css(property) // => value
$(element).css(property, value) // => collection
$(element).css(object) // => collection
```
### $.fn.data
Returns a CSS property value when just property is supplied.
Sets a CSS property when property and value are supplied, and set multiple properties when an object is supplied.
Returns data attribute value when key is supplied. Sets data attribute value
when both key and value are supplied.
### data
```js
$(element).data(key) // => value
$(element).data(key, value) // => collection
```
### $.fn.each
data(key) => value
data(key,value) => collection
Returns data attribute value when key is supplied. Sets data attribute
value when both key and value are supplied.
### each
each(callback) => collection
Iterates over a collection with callback(value, index, array).
### empty
```js
$(element).each(callback) // => collection
```
### $.fn.empty
empty() => collection
Empties an elements interior markup.
### eq
```js
$(element).empty() // => collection
```
### $.fn.eq
eq(index) => collection
Returns a collection with the element at index.
### filter
```js
$(element).eq(index) // => collection
```
### $.fn.filter
filter(function) => collection
Returns the collection that results from applying the filter method.
### find
```js
$(element).filter(function) // => collection
```
### $.fn.find
find(selector) => collection
Returns selector match descendants from the first element in the collection.
### first
```js
$(element).find(selector) // => collection
```
### $.fn.first
first() => collection
Returns the first element in the collection.
### get
```js
$(element).first() // => collection
```
### $.fn.get
get(index) => domNode
Returns the element at the index.
### has
```js
$(element).get(index) // => domNode
```
### $.fn.has
has(selector) => boolean
Returns boolean result of the selector argument against the collection.
### hasClass
```js
$(element).has(selector) // => boolean
```
### $.fn.hasClass
Returns the boolean result of checking if the first element in the collection
has the className attribute.
hasClass(className) => boolean
```js
$(element).hasClass(className) // => boolean
```
### $.fn.height
Returns the boolean result of checking if the first element in
the collection has the className attribute.
### height
height() => Integer
Returns the height of the element.
### html
```js
$(element).height() // => Integer
```
### $.fn.html
Returns the HTML text of the first element in the collection, sets the HTML if
provided.
html() => HTML Text
html(HTML) => HTML Text
```js
$(element).html() // => HTML Text
$(element).html(HTML) // => HTML Text
```
### $.fn.index
Returns the HTML text of the first element in the collection,
sets the HTML if provided.
Returns the index of the element in its parent if an element or selector isn't
provided. Returns index within element or selector if it is.
### index
```js
$(element).index() // => Integer
$(element).index(element) // => Integer
```
### $.fn.innerHeight
index() => Integer
index(element) => Integer
Returns the index of the element in its parent if an element or selector isn't provided. Returns index within element or selector if it is.
### innerHeight
innerHeight() => Integer
Returns the height of the element + padding.
### innerWidth
```js
$(element).innerHeight() // => Integer
```
### $.fn.innerWidth
innerWidth() => Integer
Returns the width of the element + padding.
### insertAfter
```js
$(element).innerWidth() // => Integer
```
### $.fn.insertAfter
insertAfter(element) => collection
Inserts collection after specified element.
### insertBefore
```js
$(element).insertAfter(element) // => collection
```
### $.fn.insertBefore
insertBefore(element) => collection
Inserts collection before specified element.
### last
```js
$(element).insertBefore(element) // => collection
```
### $.fn.is
Returns whether the provided selector matches the first element in the collection.
last() => collection
```js
$(element).is(selector) // => boolean
```
### $.fn.last
Returns last element in the collection.
### next
```js
$(element).last() // => collection
```
### $.fn.next
next() => collection
Returns next sibling.
### not
```js
$(element).next() // => collection
```
### $.fn.not
not(selector) => collection
Filters collection by false match on selector.
### off
```js
$(element).not(selector) // => collection
```
### $.fn.off
off(eventName,eventHandler) => collection
Removes event listener from collection elments.
### on
```js
$(element).off(eventName,eventHandler) // => collection
```
### $.fn.on
Adds event listener to collection elments. Event is delegated if delegate is
supplied.
on(eventName,eventHandler) => collection
on(eventName, delegate, eventHandler) => collection
```js
$(element).on(eventName, eventHandler) // => collection
$(element).on(eventName, delegate, eventHandler) // => collection
```
### $.fn.outerHeight
Adds event listener to collection elments. Event is delegated if
delegate is supplied.
### outerHeight
outerHeight() => Integer
outerHeight(includeMargin) => Integer
Returns the outer height of the element. Includes margins if margin is set to true.
### outerWidth
```js
$(element).outerHeight() // => Integer
$(element).outerHeight(includeMargin) // => Integer
```
### $.fn.outerWidth
outerWidth() => Integer
outerWidth(includeMargin) => Integer
Returns the outer width of the element. Includes margins if margin is set to true.
### parent
```js
$(element).outerWidth() // => Integer
$(element).outerWidth(includeMargin) // => Integer
```
### $.fn.parent
parent() => collection
Returns parent element.
### parents
```js
$(element).parent() // => collection
```
### $.fn.parents
parents() => collection
parents(selector) => collection
Returns collection of elements who are parents of element. Optionally filtering by selector.
### prepend
```js
$(element).parents() // => collection
$(element).parents(selector) // => collection
```
### $.fn.prepend
prepend(element) => collection
Prepends element to the first element in collection.
### prependTo
```js
$(element).prepend(element) // => collection
```
### $.fn.prependTo
prependTo(element) => collection
Prepends first element in collection to the element.
### prev
```js
$(element).prependTo(element) // => collection
```
### $.fn.prev
prev() => collection
Returns the previous adjacent element.
### prepend
```js
$(element).prev() // => collection
```
### $.fn.prepend
prepend(element) => collection
Prepends element to the first element in collection.
### prop
```js
$(element).prepend(element) // => collection
```
### $.fn.prop
prop(property) => Property value
Returns property value.
### ready
```js
$(element).prop(property) // => Property value
```
### $.fn.ready
ready(callback) => collection/span>
Calls callback method on DOMContentLoaded.
### remove
```js
$(document).ready(callback) // => collection/span
```
### $.fn.remove
remove() => collection
Removes collection elements from the DOM.
### removeAttr
```js
$(element).remove() // => collection
```
### $.fn.removeAttr
removeAttr(attrName) => collection
Removes attribute from collection elements.
### removeClass
```js
$(element).removeAttr(attrName) // => collection
```
### $.fn.removeClass
removeClass(className) => collection
Removes className from collection elements. Accepts space-separated classNames for removing multiple classes.
### removeData
```js
$(element).removeClass(className) // => collection
```
### $.fn.removeData
removeData(name) => collection
Removes data attribute from collection elements.
### serialize
```js
$(element).removeData(name) // => collection
```
serialize() => String
### $.fn.serialize
When called on a form, serializes and returns form data.
### siblings
```js
$(form).serialize() // => String
```
### $.fn.siblings
siblings() => collection
Returns a collection of sibling elements.
### text
```js
$(element).siblings() // => collection
```
### $.fn.text
Returns the inner text of the first element in the collection, sets the text if
textContent is provided.
text() => text
text(textContent) => collection
```js
$(element).text() // => text
$(element).text(textContent) // => collection
```
### $.fn.trigger
Returns the inner text of the first element in the collection,
sets the text if textContent is provided.
### trigger
trigger(eventName) => collection
Triggers supplied event on elements in collection.
### val
```js
$(element).trigger(eventName) // => collection
```
### $.fn.val
Returns an inputs value. If value is supplied, sets all inputs in collection's
value to the value argument.
val() => value
val(value) => collection
```js
$(input).val() // => value
$(input).val(value) // => collection
```
### $.fn.width
Returns an inputs value. If value is supplied, sets all inputs
in collection's value to the value argument.
Returns the width of the element.
### width
width() => Integer
Returns the width of the element.
```js
$(element).width() // => number
```

@@ -1,19 +0,22 @@

var notWhiteMatch = /\S+/g;
cash.fn.extend({
fn.extend({
addClass: function(className){ // TODO: tear out into module for IE9
var classes = className.match( notWhiteMatch ), spacedName, l;
this.each(function(v){
addClass(className) { // TODO: tear out into module for IE9
var classes = className.match(notWhiteMatch),
spacedName, l;
this.each(v => {
l = classes.length;
if(v.classList) {
while(l--) {
if (v.classList) {
while (l--) {
v.classList.add(classes[l]);
}
} else {
while(l--) {
spacedName = " "+v.className+" ";
if(spacedName.indexOf(" "+classes[l]+" ") === -1) {
v.className += " " + classes[l];
while (l--) {
spacedName = ` ${v.className} `;
if (spacedName.indexOf(` ${classes[l]} `) === -1) {
v.className += ' ' + classes[l];
}

@@ -23,12 +26,12 @@ }

});
return this;
},
attr: function(attr,value) {
if(!value){
return this[0].getAttribute(attr);
attr(name, value) {
if (!value) {
return this[0].getAttribute(name);
} else {
this.each(function(v){
v.setAttribute(attr,value);
});
this.each(v => v.setAttribute(name, value));
return this;

@@ -38,4 +41,4 @@ }

hasClass: function(className){ // TODO: tear out into module for IE9
if(this[0].classList) {
hasClass(className) { // TODO: tear out into module for IE9
if (this[0].classList) {
return this[0].classList.contains(className);

@@ -47,30 +50,33 @@ } else {

prop: function(prop){
return this[0][prop];
prop(name) {
return this[0][name];
},
removeAttr: function(attr){
this.each(function(v){
v.removeAttribute(attr);
});
removeAttr(name) {
this.each(v => v.removeAttribute(name));
return this;
},
removeClass: function(className) { // TODO: tear out into module for IE9
var classes = className.match( notWhiteMatch ),
l, newClassName;
this.each(function(v){
removeClass(className) { // TODO: tear out into module for IE9
var classes = className.match(notWhiteMatch),
l, newClassName;
this.each(v => {
l = classes.length;
if(v.classList) {
while(l--) {
if (v.classList) {
while (l--) {
v.classList.remove(classes[l]);
}
} else {
newClassName = " "+v.className+" ";
while(l--) {
newClassName = newClassName.replace(" "+classes[l]+" "," ");
newClassName = ` ${v.className} `;
while (l--) {
newClassName = newClassName.replace(` ${classes[l]} `, ' ');
}
v.className = newClassName.trim();
}
});
return this;

@@ -77,0 +83,0 @@ }

@@ -0,52 +1,50 @@

fn.extend({
cash.fn.extend({
add() {
var arr = slice.call(this),
i = 0, l;
add: function(){
var arr = [], i = 0;
arr = [].slice.call(this);
for(var l=arguments.length; i < l; i++) {
arr = arr.concat([].slice.call(cash(arguments[i])));
for (l = arguments.length; i < l; i++) {
arr = arr.concat(slice.call(cash(arguments[i])));
}
return cash.unique(arr);
},
each: function(callback){
each(callback) {
cash.each(this, callback);
},
eq: function(index){
return $(this[index]);
eq(index) {
return cash(this[index]);
},
filter: function(){
if(typeof arguments[0] === "string") {
var selector = arguments[0];
return Array.prototype.filter.call(this, function(e){
return cash.matches(e, selector);
});
filter(selector) {
if (typeof selector === 'string') {
return filter.call(this, e => cash.matches(e, selector));
} else {
return Array.prototype.filter.call(this, arguments[0]);
return filter.call(this, selector);
}
},
first: function(){
return $(this[0]);
first() {
return cash(this[0]);
},
get: function( num ) {
get(num) {
return this[num];
},
index: function(elem){
if(!elem) {
return Array.prototype.slice.call(cash(this[0]).parent().children()).indexOf(this[0]);
index(elem) {
if (!elem) {
return slice.call(cash(this[0]).parent().children()).indexOf(this[0]);
} else {
return Array.prototype.slice.call(cash(elem).children()).indexOf(this[0]);
return slice.call(cash(elem).children()).indexOf(this[0]);
}
},
last: function(){
return $(this[this.length -1]);
last() {
return cash(this[this.length - 1]);
}
});
});

@@ -0,34 +1,51 @@

var idMatch = /^#[\w-]*$/,
classMatch = /^\.[\w-]*$/,
singlet = /^[\w-]*$/;
function cash(selector, context) {
return new cash.fn.init(selector, context);
}
cash = $ = function(selector, context){
return new cash.fn.init(selector, context);
var fn = cash.fn = cash.prototype = {
cash: true,
length: 0
};
cash.fn = cash.prototype = {cash: true, length: 0};
fn.init = function(selector, context) {
var result = [],
matcher, elem;
var idMatch = /^#[\w-]*$/, classMatch = /^\.[\w-]*$/, singlet = /^[\w-]*$/;
if (!selector) {
return this;
}
cash.fn.init = function(selector, context){
var result =[], matcher, elem;
if(!selector) { return this; }
this.length = 1;
if(typeof selector !== "string") {
if(selector.cash) { return selector; }
if (typeof selector !== 'string') {
if (selector.cash) {
return selector;
}
this[0] = selector;
return this;
}
if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
result = $.parseHTML(selector);
if (selector.charAt(0) === '<' &&
selector.charAt(selector.length - 1) === '>' &&
selector.length >= 3) {
result = cash.parseHTML(selector);
} else {
matcher = idMatch.test(selector);
elem = selector.slice(1);
if(!context && matcher) {
this[0] = document.getElementById(elem);
if (!context && matcher) {
this[0] = doc.getElementById(elem);
return this;
} else {
context = ($(context)[0] || document);
result = [].slice.call(
context = (cash(context)[0] || doc);
result = slice.call(
singlet.test(elem) ?
classMatch.test(selector) ? document.getElementsByClassName(elem) :
document.getElementsByTagName(selector) :
classMatch.test(selector) ? doc.getElementsByClassName(elem) :
doc.getElementsByTagName(selector) :
context.querySelectorAll(selector)

@@ -38,7 +55,8 @@ );

}
this.length = 0;
$.merge(this,result);
cash.merge(this, result);
return this;
};
cash.fn.init.prototype = cash.fn;
fn.init.prototype = fn;

@@ -0,28 +1,20 @@

fn.extend({
cash.fn.extend({
css: function(){
var computed, prop, value, collection;
if(typeof arguments[0] === "object") {
collection = arguments[0];
this.each(function(v){
for (var key in collection) {
if (collection.hasOwnProperty(key)) {
v.style[key] = collection[key];
css(prop, value) {
if (typeof prop === 'object') {
this.each(v => {
for (var key in prop) {
if (prop.hasOwnProperty(key)) {
v.style[key] = prop[key];
}
}
});
} else if (value) {
this.each(v => v.style[prop] = value);
return this;
} else {
prop = arguments[0];
value = arguments[1];
if(arguments.length > 1) {
this.each(function(v){
v.style[prop] = value;
});
return this;
} else {
computed = window.getComputedStyle(this[0],null);
return computed[prop];
}
return win.getComputedStyle(this[0], null)[prop];
}
}
});
});

@@ -0,15 +1,15 @@

fn.extend({
cash.fn.extend({
data: function(key,value){ // TODO: tear out into module for IE9
if(!value){
return this[0].dataset ? this[0].dataset[key] : $(this[0]).attr("data-"+key);
data(key, value) { // TODO: tear out into module for IE9
if (!value) {
return this[0].dataset ? this[0].dataset[key] : cash(this[0]).attr('data-' + key);
} else {
this.each(function(v){
if(v.dataset) {
this.each(v => {
if (v.dataset) {
v.dataset[key] = value;
} else {
$(v).attr("data-"+key,value);
cash(v).attr('data-' + key, value);
}
});
return this;

@@ -19,13 +19,14 @@ }

removeData: function(name){ // TODO: tear out into module for IE9
this.each(function(v){
if(v.dataset) {
removeData(name) { // TODO: tear out into module for IE9
this.each(v => {
if (v.dataset) {
delete v.dataset[name];
} else {
$(v).removeAttr("data-"+name);
cash(v).removeAttr('data-' + name);
}
});
return this;
}
});
});

@@ -0,35 +1,40 @@

function compute(el, prop) {
return parseInt(win.getComputedStyle(el[0], null)[prop], 10);
}
cash.fn.extend({
fn.extend({
height: function(){
height() {
return this[0].getBoundingClientRect().height;
},
innerWidth: function(){
innerWidth() {
return this[0].clientWidth;
},
innerHeight: function(){
innerHeight() {
return this[0].clientHeight;
},
outerWidth: function(margins){
if(margins === true){
outerWidth(margins) {
if (margins === true) {
return this[0].offsetWidth +
(parseInt(getComputed(this,"margin-left"), 10) || parseInt(getComputed(this,"marginLeft"), 10) || 0) +
(parseInt(getComputed(this,"margin-right"), 10) || parseInt(getComputed(this,"marginRight"), 10) || 0);
(compute(this, 'margin-left') || compute(this, 'marginLeft') || 0) +
(compute(this, 'margin-right') || compute(this, 'marginRight') || 0);
}
return this[0].offsetWidth;
},
outerHeight: function(margins){
if(margins === true){
outerHeight(margins) {
if (margins === true) {
return this[0].offsetHeight +
(parseInt(getComputed(this,"margin-top"), 10) || parseInt(getComputed(this,"marginTop"), 10) || 0 ) +
(parseInt(getComputed(this,"margin-bottom"), 10) || parseInt(getComputed(this,"marginBottom"), 10) || 0 );
(compute(this, 'margin-top') || compute(this, 'marginTop') || 0) +
(compute(this, 'margin-bottom') || compute(this, 'marginBottom') || 0);
}
return this[0].offsetHeight;
},
width: function(){
width() {
return this[0].getBoundingClientRect().width;

@@ -39,7 +44,1 @@ }

});
function getComputed(el, prop) {
var computed;
computed = window.getComputedStyle(el[0],null);
return computed[prop];
}

@@ -1,28 +0,50 @@

var _eventCache = {};
cash.fn.extend({
function guid() {
function _p8(s) {
var p = (Math.random().toString(16) + '000000000').substr(2, 8);
return s ? '-' + p.substr(0, 4) + '-' + p.substr(4, 4) : p ;
}
off: function(){
var eventName = arguments[0], callback = arguments[1];
this.each(function(v){
if(callback){
return _p8() + _p8(true) + _p8(true) + _p8();
}
function registerEvent(node, eventName, callback) {
var nid = cash(node).data('cshid') || guid();
cash(node).data('cshid', nid);
if (!(nid in _eventCache)) {
_eventCache[nid] = {};
}
if (!(eventName in _eventCache[nid])) {
_eventCache[nid][eventName] = [];
}
_eventCache[nid][eventName].push(callback);
}
fn.extend({
off(eventName, callback) {
this.each(v => {
if (callback) {
v.removeEventListener(eventName, callback);
} else {
for(var i in _eventCache[$(v).data("cshid")][eventName]) {
v.removeEventListener(eventName, _eventCache[$(v).data("cshid")][eventName][i]);
for (var i in _eventCache[cash(v).data('cshid')][eventName]) {
v.removeEventListener(eventName, _eventCache[cash(v).data('cshid')][eventName][i]);
}
}
});
return this;
},
on: function(){
var eventName, delegate, callback;
on(eventName, delegate, callback) {
if (typeof delegate === 'function') {
callback = delegate;
if(typeof arguments[1] === "function") {
eventName = arguments[0];
callback = arguments[1];
this.each(function(v){
registerEvent($(v),eventName,callback);
this.each(v => {
registerEvent(cash(v), eventName, callback);
v.addEventListener(eventName, callback);

@@ -32,23 +54,26 @@ });

} else {
eventName = arguments[0];
delegate = arguments[1];
callback = arguments[2];
this.each(function(v){
var handler = function(e){
this.each(v => {
function handler(e) {
var t = e.target;
if($.matches(t,delegate)){
if (cash.matches(t, delegate)) {
callback.call(t);
} else {
while (!$.matches(t,delegate)) {
if ( t === v ) {
return t = false;
while (!cash.matches(t, delegate)) {
if (t === v) {
return (t = false);
}
t = t.parentNode;
}
if (t) { callback.call(t); }
if (t) {
callback.call(t);
}
}
};
registerEvent($(v), eventName, handler);
}
registerEvent(cash(v), eventName, handler);
v.addEventListener(eventName, handler);
});
return this;

@@ -58,12 +83,10 @@ }

ready: function(callback){
this[0].addEventListener("DOMContentLoaded", callback);
ready(callback) {
this[0].addEventListener('DOMContentLoaded', callback);
},
trigger: function(eventName){
var evt = document.createEvent("HTMLEvents");
trigger(eventName) {
var evt = doc.createEvent('HTMLEvents');
evt.initEvent(eventName, true, false);
this.each(function(v){
v.dispatchEvent(evt);
});
this.each(v => v.dispatchEvent(evt));
return this;

@@ -73,21 +96,1 @@ }

});
function registerEvent(node,eventName,callback){
var nid = $(node).data("cshid") || guid();
$(node).data("cshid", nid);
if(!(nid in _eventCache)) {
_eventCache[nid] = {};
}
if(!(eventName in _eventCache[nid])) {
_eventCache[nid][eventName] = [];
}
_eventCache[nid][eventName].push(callback);
}
function guid() {
function _p8(s) {
var p = (Math.random().toString(16)+"000000000").substr(2,8);
return s ? "-" + p.substr(0,4) + "-" + p.substr(4,4) : p ;
}
return _p8() + _p8(true) + _p8(true) + _p8();
}

@@ -0,38 +1,38 @@

var encode = encodeURIComponent;
cash.fn.extend({
fn.extend({
serialize: function(){
var form = this[0];
var field, query="";
for(var i=form.elements.length-1; i>=0; i--){
field = form.elements[i];
if(field.name && field.type !== "file" && field.type !== "reset"){
if(field.type === "select-multiple"){
for(var j=form.elements[i].options.length-1; j>=0; j--){
if(field.options[j].selected){
query += "&" + field.name + "=" + encodeURIComponent(field.options[j].value).replace(/%20/g,"+");
}
}
}
else{
if((field.type !== "submit" && field.type !== "button")){
query += "&" + field.name + "=" + encodeURIComponent(field.value).replace(/%20/g,"+");
}
}
serialize() {
var form = this[0],
query = '',
field, i, j;
for (i = form.elements.length - 1; i >= 0; i--) {
field = form.elements[i];
if (field.name && field.type !== 'file' && field.type !== 'reset') {
if (field.type === 'select-multiple') {
for (j = form.elements[i].options.length - 1; j >= 0; j--) {
if (field.options[j].selected) {
query += '&' + field.name + '=' + encode(field.options[j].value).replace(/%20/g, '+');
}
}
} else if ((field.type !== 'submit' && field.type !== 'button')) {
query += '&' + field.name + '=' + encode(field.value).replace(/%20/g, '+');
}
return query.substr(1);
},
}
}
val: function(value){
if(value === undefined) {
return this[0].value;
} else {
this.each(function(v){
v.value = value;
});
return this;
}
return query.substr(1);
},
val(value) {
if (value === undefined) {
return this[0].value;
} else {
this.each(v => v.value = value);
return this;
}
}
});
});

@@ -0,34 +1,30 @@

fn.extend({
cash.fn.extend({
append: function(content) {
this[0].appendChild($(content)[0]);
append(content) {
this[0].appendChild(cash(content)[0]);
return this;
},
appendTo: function(content) {
$(content)[0].appendChild(this[0]);
appendTo(content) {
cash(content)[0].appendChild(this[0]);
return this;
},
clone: function() {
return $(this[0].cloneNode(true));
clone() {
return cash(this[0].cloneNode(true));
},
empty: function(){
this.each(function(v){
v.innerHTML = "";
});
empty() {
this.each(v => v.innerHTML = '');
return this;
},
html: function(content){
html(content) {
var source;
if(content === "undefined") {
if (content === 'undefined') {
return this[0].innerHTML;
} else {
source = typeof content === "object" ? $(content)[0].outerHTML : content;
this.each(function(v){
v.innerHTML = "" + source;
});
source = typeof content === 'object' ? cash(content)[0].outerHTML : content;
this.each(v => v.innerHTML = `${source}`);
return this;

@@ -38,35 +34,31 @@ }

insertAfter: function(selector){
$(selector)[0].insertAdjacentHTML("afterend",this[0].outerHTML);
insertAfter(selector) {
cash(selector)[0].insertAdjacentHTML('afterend', this[0].outerHTML);
return this;
},
insertBefore: function(selector){
$(selector)[0].insertAdjacentHTML("beforebegin",this[0].outerHTML);
insertBefore(selector) {
cash(selector)[0].insertAdjacentHTML('beforebegin', this[0].outerHTML);
return this;
},
prepend: function(selector){
$(this)[0].insertAdjacentHTML("afterBegin",$(selector)[0].outerHTML);
prepend(selector) {
cash(this)[0].insertAdjacentHTML('afterBegin', cash(selector)[0].outerHTML);
return this;
},
prependTo: function(selector){
$(selector)[0].insertAdjacentHTML("afterBegin",this[0].outerHTML);
prependTo(selector) {
cash(selector)[0].insertAdjacentHTML('afterBegin', this[0].outerHTML);
return this;
},
remove: function(){
this.each(function(v){
v.parentNode.removeChild(v);
});
remove() {
this.each(v => v.parentNode.removeChild(v));
},
text: function(content){
if(!content) {
text(content) {
if (!content) {
return this[0].textContent;
} else {
this.each(function(v){
v.textContent = content;
});
this.each(v => v.textContent = content);
return this;

@@ -76,2 +68,2 @@ }

});
});

@@ -0,12 +1,9 @@

fn.extend({
cash.fn.extend({
children: function(selector) {
if(!selector){
var children = this[0].children;
cash.fn.extend(children, cash.fn);
return children;
children(selector) {
if (!selector) {
return cash.fn.extend(this[0].children, cash.fn);
} else {
return cash(this[0].children).filter(function(v){
return cash.matches(v,selector);
return cash(this[0].children).filter(v => {
return cash.matches(v, selector);
});

@@ -16,4 +13,4 @@ }

closest: function(selector){
if(!selector || cash.matches(this[0], selector)) {
closest(selector) {
if (!selector || cash.matches(this[0], selector)) {
return this;

@@ -25,19 +22,20 @@ } else {

is: function(selector){
if (!selector) { return false; }
is(selector) {
if (!selector) {
return false;
}
if (selector.cash) {
return this[0] === selector[0];
}
return typeof selector === "string" ? cash.matches(this[0], selector) : false;
return typeof selector === 'string' ? cash.matches(this[0], selector) : false;
},
find: function(selector){
var result;
result = this[0].querySelectorAll(selector);
cash.fn.extend(result, cash.fn);
return result;
find(selector) {
return cash.fn.extend(this[0].querySelectorAll(selector), cash.fn);
},
has: function(selector){
return Array.prototype.filter.call(this, function(el){
has(selector) {
return filter.call(this, el => {
return cash(el).find(selector).length !== 0;

@@ -47,8 +45,8 @@ });

next: function(){
next() {
return cash(this[0].nextElementSibling);
},
not: function(selector) {
return Array.prototype.filter.call(this, function(el){
not(selector) {
return filter.call(this, el => {
return !cash.matches(el, selector);

@@ -58,16 +56,22 @@ });

parent: function(){
var result = Array.prototype.map.call( this, function(item) {
return item.parentElement || document.body.parentNode;
});
parent() {
var result = ArrayProto.map.call(this, item => {
return item.parentElement || doc.body.parentNode;
});
return cash.unique(result);
},
parents: function(selector){
var last, result = [], count = 0;
this.each(function(item) {
parents(selector) {
var last,
result = [],
count = 0;
this.each(item => {
last = item;
while(last !== document.body.parentNode) {
while (last !== doc.body.parentNode) {
last = last.parentElement;
if(!selector || (selector && cash.matches(last, selector))) {
if (!selector || (selector && cash.matches(last, selector))) {
result[count] = last;

@@ -78,16 +82,17 @@ count++;

});
return cash.unique(result);
},
prev: function(){
prev() {
return cash(this[0].previousElementSibling);
},
siblings: function(){
var collection = this.parent().children(), el = this[0];
return Array.prototype.filter.call(collection,function(i){
return i !== el;
});
siblings() {
var collection = this.parent().children(),
el = this[0];
return filter.call(collection, i => i !== el);
}
});

@@ -0,32 +1,54 @@

function buildFragment(str) {
var fragment = fragment || doc.createDocumentFragment(),
tmp = tmp || fragment.appendChild(doc.createElement('div'));
tmp.innerHTML = str;
return tmp;
}
cash.each = function(collection,callback){
var i = 0, l = collection.length;
for( ; i < l; i++){
callback.call(collection[i],collection[i],i,collection);
cash.each = function(collection, callback) {
var l = collection.length,
i = 0;
for (; i < l; i++) {
callback.call(collection[i], collection[i], i, collection);
}
};
cash.extend = cash.fn.extend = function(target,source) {
var prop;
if(!source) {
source = target;
target = this;
cash.extend = fn.extend = function(target, source) {
var prop;
if (!source) {
source = target;
target = this;
}
for (prop in source) {
if (source.hasOwnProperty(prop)) {
target[prop] = source[prop];
}
for(prop in source) {
if(source.hasOwnProperty(prop)) { target[prop] = source[prop]; }
}
return this;
}
return target;
};
cash.matches = function(el, selector) {
return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector);
return (
el.matches ||
el.matchesSelector ||
el.msMatchesSelector ||
el.mozMatchesSelector ||
el.webkitMatchesSelector ||
el.oMatchesSelector
).call(el, selector);
};
cash.merge = function( first, second ) {
cash.merge = function(first, second) {
var len = +second.length,
j = 0,
i = first.length;
for ( ; j < len; j++ ) {
first[ i++ ] = second[ j ];
i = first.length,
j = 0;
for (; j < len; i++, j++) {
first[i] = second[j];
}
first.length = i;

@@ -38,21 +60,15 @@ return first;

var parsed = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/).exec(str);
if(parsed) {
return [document.createElement(parsed[1])];
if (parsed) {
return [doc.createElement(parsed[1])];
}
parsed = buildFragment(str);
return [].slice.call(parsed.childNodes);
return slice.call(parsed.childNodes);
};
cash.unique = function(collection) {
return cash.merge(cash(),[].slice.call(collection).filter(function(item,index,self){
return cash.merge(cash(), slice.call(collection).filter((item, index, self) => {
return self.indexOf(item) === index;
}));
};
function buildFragment(str){
var fragment, tmp;
fragment = fragment || document.createDocumentFragment();
tmp = tmp || fragment.appendChild(document.createElement("div"));
tmp.innerHTML = str;
return tmp;
}

@@ -27,30 +27,2 @@ // Core

// AJAX
QUnit.test( "Ajax", function( assert ) {
QUnit.stop();
$.ajax({
type: 'GET',
url: 'ajax-fixture.html',
success: function(data) {
QUnit.ok(true, "Ajax Success Passed");
QUnit.start();
}
});
QUnit.stop();
$.ajax({
type: 'GET',
url: 'missing-fixture.html',
error: function(error) {
QUnit.ok(true, "Ajax Error Passed = " + error);
QUnit.start();
}
});
});
//Attributes

@@ -57,0 +29,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc