Comparing version 2.3.9 to 3.0.0-beta.0
1187
dist/cash.esm.js
/* MIT https://github.com/kenwheeler/cash */ | ||
"use strict"; | ||
exports.__esModule = true; | ||
var doc = document, | ||
win = window, | ||
_Array$prototype = Array.prototype, | ||
filter = _Array$prototype.filter, | ||
indexOf = _Array$prototype.indexOf, | ||
map = _Array$prototype.map, | ||
push = _Array$prototype.push, | ||
reverse = _Array$prototype.reverse, | ||
slice = _Array$prototype.slice, | ||
splice = _Array$prototype.splice; | ||
div = doc.createElement('div'), | ||
_a = Array.prototype, | ||
filter = _a.filter, | ||
indexOf = _a.indexOf, | ||
map = _a.map, | ||
push = _a.push, | ||
reverse = _a.reverse, | ||
slice = _a.slice, | ||
some = _a.some, | ||
splice = _a.splice; | ||
var idRe = /^#[\w-]*$/, | ||
classRe = /^\.[\w-]*$/, | ||
htmlRe = /<.+>/, | ||
tagRe = /^\w+$/; // @require ./variables.js | ||
tagRe = /^\w+$/; // @require ./variables.ts | ||
@@ -25,124 +28,112 @@ function find(selector, context) { | ||
return classRe.test(selector) ? context.getElementsByClassName(selector.slice(1)) : tagRe.test(selector) ? context.getElementsByTagName(selector) : context.querySelectorAll(selector); | ||
} // @require ./find.js | ||
// @require ./variables.js | ||
} // @require ./find.ts | ||
// @require ./variables.ts | ||
function Cash(selector, context) { | ||
if (context === void 0) { | ||
context = doc; | ||
} | ||
var Cash = | ||
/** @class */ | ||
function () { | ||
function Cash(selector, context) { | ||
if (context === void 0) { | ||
context = doc; | ||
} | ||
if (!selector) return; | ||
if (selector.__cash) return selector; | ||
var eles = selector; | ||
if (!selector) return; | ||
if (isCash(selector)) return selector; | ||
var eles = selector; | ||
if (isString(selector)) { | ||
if (context.__cash) context = context[0]; | ||
eles = idRe.test(selector) ? context.getElementById(selector.slice(1)) : htmlRe.test(selector) ? parseHTML(selector) : find(selector, context); | ||
if (!eles) return; | ||
} else if (isFunction(selector)) { | ||
return this.ready(selector); //FIXME: `fn.ready` is not included in `core`, but it's actually a core functionality | ||
} | ||
if (isString(selector)) { | ||
var ctx = isCash(context) ? context[0] : context; | ||
eles = idRe.test(selector) ? ctx.getElementById(selector.slice(1)) : htmlRe.test(selector) ? parseHTML(selector) : find(selector, ctx); | ||
if (!eles) return; | ||
} else if (isFunction(selector)) { | ||
return this.ready(selector); //FIXME: `fn.ready` is not included in `core`, but it's actually a core functionality | ||
} | ||
if (eles.nodeType || eles === win) eles = [eles]; | ||
this.length = eles.length; | ||
if (eles.nodeType || eles === win) eles = [eles]; | ||
this.length = eles.length; | ||
for (var i = 0, l = this.length; i < l; i++) { | ||
this[i] = eles[i]; | ||
for (var i = 0, l = this.length; i < l; i++) { | ||
this[i] = eles[i]; | ||
} | ||
} | ||
} | ||
function cash(selector, context) { | ||
return new Cash(selector, context); | ||
} | ||
/* PROTOTYPE */ | ||
Cash.prototype.init = function (selector, context) { | ||
return new Cash(selector, context); | ||
}; | ||
return Cash; | ||
}(); | ||
var fn = cash.fn = cash.prototype = Cash.prototype = { | ||
constructor: cash, | ||
__cash: true, | ||
length: 0, | ||
splice: splice // Ensures a cash collection gets printed as array-like in Chrome | ||
var cash = Cash.prototype.init; | ||
cash.fn = cash.prototype = Cash.prototype; // Ensuring that `cash () instanceof cash` | ||
}; // @require core/cash.js | ||
// @require core/variables.js | ||
Cash.prototype.length = 0; | ||
Cash.prototype.splice = splice; // Ensuring a cash collection gets printed as array-like in Chrome | ||
fn.get = function (index) { | ||
Cash.prototype.get = function (index) { | ||
if (index === undefined) return slice.call(this); | ||
return this[index < 0 ? index + this.length : index]; | ||
}; // @require core/cash.js | ||
// @require ./get.js | ||
}; | ||
fn.eq = function (index) { | ||
Cash.prototype.eq = function (index) { | ||
return cash(this.get(index)); | ||
}; // @require core/cash.js | ||
// @require ./eq.js | ||
}; | ||
fn.first = function () { | ||
Cash.prototype.first = function () { | ||
return this.eq(0); | ||
}; // @require core/cash.js | ||
// @require ./eq.js | ||
}; | ||
fn.last = function () { | ||
Cash.prototype.last = function () { | ||
return this.eq(-1); | ||
}; // @require core/cash.js | ||
// @require core/variables.js | ||
}; | ||
fn.map = function (callback) { | ||
Cash.prototype.map = function (callback) { | ||
return cash(map.call(this, function (ele, i) { | ||
return callback.call(ele, i, ele); | ||
})); | ||
}; // @require core/cash.js | ||
// @require core/variables.js | ||
}; | ||
fn.slice = function () { | ||
Cash.prototype.slice = function () { | ||
return cash(slice.apply(this, arguments)); | ||
}; // @require ./cash.js | ||
}; // @require ./cash.ts | ||
var camelCaseRe = /(?:^\w|[A-Z]|\b\w)/g, | ||
camelCaseWhitespaceRe = /[\s-_]+/g; | ||
var dashAlphaRe = /-([a-z])/g; | ||
function camelCaseReplace(all, letter) { | ||
return letter.toUpperCase(); | ||
} | ||
function camelCase(str) { | ||
return str.replace(camelCaseRe, function (letter, index) { | ||
return letter[!index ? 'toLowerCase' : 'toUpperCase'](); | ||
}).replace(camelCaseWhitespaceRe, ''); | ||
return str.replace(dashAlphaRe, camelCaseReplace); | ||
} | ||
; | ||
cash.camelCase = camelCase; // @require ./cash.js | ||
cash.camelCase = camelCase; // @require ./cash.ts | ||
function each(arr, callback) { | ||
for (var i = 0, l = arr.length; i < l; i++) { | ||
if (callback.call(arr[i], arr[i], i, arr) === false) break; | ||
if (callback.call(arr[i], i, arr[i]) === false) break; | ||
} | ||
} | ||
cash.each = each; // @require core/cash.js | ||
// @require core/each.js | ||
cash.each = each; | ||
fn.each = function (callback) { | ||
each(this, function (ele, i) { | ||
return callback.call(ele, i, ele); | ||
}); | ||
Cash.prototype.each = function (callback) { | ||
each(this, callback); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
}; | ||
fn.removeProp = function (prop) { | ||
Cash.prototype.removeProp = function (prop) { | ||
return this.each(function (i, ele) { | ||
delete ele[prop]; | ||
}); | ||
}; // @require ./cash.js | ||
}; // @require ./cash.ts | ||
function extend(target) { | ||
if (target === void 0) { | ||
target = this; | ||
var objs = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
objs[_i - 1] = arguments[_i]; | ||
} | ||
@@ -162,15 +153,30 @@ | ||
; | ||
cash.extend = fn.extend = extend; // @require ./cash.js | ||
Cash.prototype.extend = function (plugins) { | ||
return extend(cash.fn, plugins); | ||
}; | ||
cash.extend = extend; // @require ./cash.ts | ||
var guid = 1; | ||
cash.guid = guid; // @require ./cash.js | ||
cash.guid = guid; // @require ./cash.ts | ||
function matches(ele, selector) { | ||
var matches = ele && (ele.matches || ele.webkitMatchesSelector || ele.mozMatchesSelector || ele.msMatchesSelector || ele.oMatchesSelector); | ||
return !!matches && matches.call(ele, selector); | ||
return !!ele && !!ele.matches && ele.matches(selector); | ||
} | ||
cash.matches = matches; // @require ./cash.js | ||
cash.matches = matches; // @require ./variables.ts | ||
function pluck(arr, prop) { | ||
return filter.call(map.call(arr, function (ele) { | ||
return ele[prop]; | ||
}), function (ele) { | ||
return ele != null; | ||
}); | ||
} // @require ./cash.ts | ||
function isCash(x) { | ||
return x instanceof Cash; | ||
} | ||
function isFunction(x) { | ||
@@ -180,4 +186,2 @@ return typeof x === 'function'; | ||
cash.isFunction = isFunction; | ||
function isString(x) { | ||
@@ -187,4 +191,2 @@ return typeof x === 'string'; | ||
cash.isString = isString; | ||
function isNumeric(x) { | ||
@@ -194,9 +196,9 @@ return !isNaN(parseFloat(x)) && isFinite(x); | ||
var isArray = Array.isArray; | ||
cash.isFunction = isFunction; | ||
cash.isString = isString; | ||
cash.isNumeric = isNumeric; | ||
var isArray = Array.isArray; | ||
cash.isArray = isArray; // @require core/cash.js | ||
// @require core/type_checking.js | ||
// @require collection/each.js | ||
cash.isArray = isArray; | ||
fn.prop = function (prop, value) { | ||
Cash.prototype.prop = function (prop, value) { | ||
if (!prop) return; | ||
@@ -216,28 +218,23 @@ | ||
return this; | ||
}; // @require ./matches.js | ||
// @require ./type_checking.js | ||
}; // @require ./matches.ts | ||
// @require ./type_checking.ts | ||
function getCompareFunction(selector) { | ||
return isString(selector) ? function (i, ele) { | ||
return matches(ele, selector); | ||
} : selector.__cash ? function (i, ele) { | ||
return selector.is(ele); | ||
} : function (i, ele, selector) { | ||
return ele === selector; | ||
function getCompareFunction(comparator) { | ||
return isString(comparator) ? function (i, ele) { | ||
return matches(ele, comparator); | ||
} : isFunction(comparator) ? comparator : isCash(comparator) ? function (i, ele) { | ||
return comparator.is(ele); | ||
} : function (i, ele) { | ||
return ele === comparator; | ||
}; | ||
} // @require core/cash.js | ||
// @require core/get_compare_function.js | ||
// @require core/type_checking.js | ||
// @require core/variables.js | ||
// @require collection/get.js | ||
} | ||
fn.filter = function (selector) { | ||
if (!selector) return cash(); | ||
var comparator = isFunction(selector) ? selector : getCompareFunction(selector); | ||
Cash.prototype.filter = function (comparator) { | ||
if (!comparator) return cash(); | ||
var compare = getCompareFunction(comparator); | ||
return cash(filter.call(this, function (ele, i) { | ||
return comparator.call(ele, i, ele, selector); | ||
return compare.call(ele, i, ele); | ||
})); | ||
}; // @require ./type_checking.js | ||
}; // @require ./type_checking.ts | ||
@@ -249,39 +246,21 @@ | ||
return isString(str) ? str.match(splitValuesRe) || [] : []; | ||
} // @require core/cash.js | ||
// @require core/get_split_values.js | ||
// @require collection/each.js | ||
} | ||
Cash.prototype.hasClass = function (cls) { | ||
return some.call(this, function (ele) { | ||
return ele.classList.contains(cls); | ||
}); | ||
}; | ||
fn.hasClass = function (cls) { | ||
var classes = getSplitValues(cls); | ||
var check = false; | ||
if (classes.length) { | ||
this.each(function (i, ele) { | ||
check = ele.classList.contains(classes[0]); | ||
return !check; | ||
}); | ||
} | ||
return check; | ||
}; // @require core/cash.js | ||
// @require core/get_split_values.js | ||
// @require collection/each.js | ||
fn.removeAttr = function (attr) { | ||
Cash.prototype.removeAttr = function (attr) { | ||
var attrs = getSplitValues(attr); | ||
if (!attrs.length) return this; | ||
return this.each(function (i, ele) { | ||
each(attrs, function (a) { | ||
each(attrs, function (i, a) { | ||
ele.removeAttribute(a); | ||
}); | ||
}); | ||
}; // @require core/cash.js | ||
// @require core/type_checking.js | ||
// @require collection/each.js | ||
// @require ./remove_attr.js | ||
}; | ||
fn.attr = function (attr, value) { | ||
function attr(attr, value) { | ||
if (!attr) return; | ||
@@ -292,6 +271,4 @@ | ||
if (!this[0]) return; | ||
var _value = this[0].getAttribute(attr); | ||
return _value === null ? undefined : _value; | ||
var value_1 = this[0].getAttribute(attr); | ||
return value_1 === null ? undefined : value_1; | ||
} | ||
@@ -310,9 +287,7 @@ | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/each.js | ||
// @require core/get_split_values.js | ||
// @require collection/each.js | ||
} | ||
Cash.prototype.attr = attr; | ||
fn.toggleClass = function (cls, force) { | ||
Cash.prototype.toggleClass = function (cls, force) { | ||
var classes = getSplitValues(cls), | ||
@@ -322,3 +297,3 @@ isForce = force !== undefined; | ||
return this.each(function (i, ele) { | ||
each(classes, function (c) { | ||
each(classes, function (i, c) { | ||
if (isForce) { | ||
@@ -331,46 +306,40 @@ force ? ele.classList.add(c) : ele.classList.remove(c); | ||
}); | ||
}; // @require core/cash.js | ||
// @require ./toggle_class.js | ||
}; | ||
fn.addClass = function (cls) { | ||
Cash.prototype.addClass = function (cls) { | ||
return this.toggleClass(cls, true); | ||
}; // @require core/cash.js | ||
// @require ./attr.js | ||
// @require ./toggle_class.js | ||
}; | ||
fn.removeClass = function (cls) { | ||
Cash.prototype.removeClass = function (cls) { | ||
return !arguments.length ? this.attr('class', '') : this.toggleClass(cls, false); | ||
}; // @optional ./add_class.js | ||
// @optional ./attr.js | ||
// @optional ./has_class.js | ||
// @optional ./prop.js | ||
// @optional ./remove_attr.js | ||
// @optional ./remove_class.js | ||
// @optional ./remove_prop.js | ||
// @optional ./toggle_class.js | ||
// @require ./cash.js | ||
}; // @optional ./add_class.ts | ||
// @optional ./attr.ts | ||
// @optional ./has_class.ts | ||
// @optional ./prop.ts | ||
// @optional ./remove_attr.ts | ||
// @optional ./remove_class.ts | ||
// @optional ./remove_prop.ts | ||
// @optional ./toggle_class.ts | ||
// @require ./cash.ts | ||
// @require ./variables | ||
function unique(arr) { | ||
return arr.filter(function (item, index, self) { | ||
return self.indexOf(item) === index; | ||
}); | ||
return arr.length > 1 ? filter.call(arr, function (item, index, self) { | ||
return indexOf.call(self, item) === index; | ||
}) : arr; | ||
} | ||
cash.unique = unique; // @require core/cash.js | ||
// @require core/unique.js | ||
// @require ./get.js | ||
cash.unique = unique; | ||
fn.add = function (selector, context) { | ||
Cash.prototype.add = function (selector, context) { | ||
return cash(unique(this.get().concat(cash(selector, context).get()))); | ||
}; // @require core/variables.js | ||
}; // @require core/variables.ts | ||
function computeStyle(ele, prop, isVariable) { | ||
if (ele.nodeType !== 1) return; | ||
if (ele.nodeType !== 1 || !prop) return; | ||
var style = win.getComputedStyle(ele, null); | ||
return prop ? isVariable ? style.getPropertyValue(prop) : style[prop] : style; | ||
} // @require ./compute_style.js | ||
return prop ? isVariable ? style.getPropertyValue(prop) || undefined : style[prop] : style; | ||
} // @require ./compute_style.ts | ||
@@ -382,16 +351,15 @@ | ||
var cssVariableRe = /^--/; // @require ./variables.js | ||
var cssVariableRe = /^--/; // @require ./variables.ts | ||
function isCSSVariable(prop) { | ||
return cssVariableRe.test(prop); | ||
} // @require core/camel_case.js | ||
// @require core/cash.js | ||
// @require core/each.js | ||
// @require core/variables.js | ||
// @require ./is_css_variable.js | ||
} // @require core/camel_case.ts | ||
// @require core/cash.ts | ||
// @require core/each.ts | ||
// @require core/variables.ts | ||
// @require ./is_css_variable.ts | ||
var prefixedProps = {}, | ||
_doc$createElement = doc.createElement('div'), | ||
style = _doc$createElement.style, | ||
style = div.style, | ||
vendorsPrefixes = ['webkit', 'moz', 'ms', 'o']; | ||
@@ -410,3 +378,3 @@ | ||
props = (propCC + " " + vendorsPrefixes.join(propUC + " ") + propUC).split(' '); | ||
each(props, function (p) { | ||
each(props, function (i, p) { | ||
if (p in style) { | ||
@@ -423,4 +391,4 @@ prefixedProps[prop] = p; | ||
; | ||
cash.prefixedProp = getPrefixedProp; // @require core/type_checking.js | ||
// @require ./is_css_variable.js | ||
cash.prefixedProp = getPrefixedProp; // @require core/type_checking.ts | ||
// @require ./is_css_variable.ts | ||
@@ -447,25 +415,18 @@ var numericProps = { | ||
return !isVariable && !numericProps[prop] && isNumeric(value) ? value + "px" : value; | ||
} // @require core/cash.js | ||
// @require core/type_checking.js | ||
// @require collection/each.js | ||
// @require ./helpers/compute_style.js | ||
// @require ./helpers/get_prefixed_prop.js | ||
// @require ./helpers/get_suffixed_value.js | ||
// @require ./helpers/is_css_variable.js | ||
} | ||
fn.css = function (prop, value) { | ||
function css(prop, value) { | ||
if (isString(prop)) { | ||
var isVariable = isCSSVariable(prop); | ||
prop = getPrefixedProp(prop, isVariable); | ||
if (arguments.length < 2) return this[0] && computeStyle(this[0], prop, isVariable); | ||
var isVariable_1 = isCSSVariable(prop); | ||
prop = getPrefixedProp(prop, isVariable_1); | ||
if (arguments.length < 2) return this[0] && computeStyle(this[0], prop, isVariable_1); | ||
if (!prop) return this; | ||
value = getSuffixedValue(prop, value, isVariable); | ||
value = getSuffixedValue(prop, value, isVariable_1); | ||
return this.each(function (i, ele) { | ||
if (ele.nodeType !== 1) return; | ||
if (isVariable) { | ||
if (isVariable_1) { | ||
ele.style.setProperty(prop, value); | ||
} else { | ||
ele.style[prop] = value; | ||
ele.style[prop] = value; //TSC | ||
} | ||
@@ -480,18 +441,21 @@ }); | ||
return this; | ||
}; // @optional ./css.js | ||
} | ||
; | ||
Cash.prototype.css = css; // @optional ./css.ts | ||
var dataNamespace = '__cashData', | ||
dataAttributeRe = /^data-(.*)/; // @require core/cash.js | ||
// @require ./helpers/variables.js | ||
dataAttributeRe = /^data-(.*)/; // @require core/cash.ts | ||
// @require ./helpers/variables.ts | ||
cash.hasData = function (ele) { | ||
function hasData(ele) { | ||
return dataNamespace in ele; | ||
}; // @require ./variables.js | ||
} | ||
cash.hasData = hasData; // @require ./variables.ts | ||
function getDataCache(ele) { | ||
return ele[dataNamespace] = ele[dataNamespace] || {}; | ||
} // @require attributes/attr.js | ||
// @require ./get_data_cache.js | ||
} // @require attributes/attr.ts | ||
// @require ./get_data_cache.ts | ||
@@ -519,4 +483,4 @@ | ||
return cache; | ||
} // @require ./variables.js | ||
// @require ./get_data_cache.js | ||
} // @require ./variables.ts | ||
// @require ./get_data_cache.ts | ||
@@ -530,3 +494,3 @@ | ||
} | ||
} // @require ./get_data_cache.js | ||
} // @require ./get_data_cache.ts | ||
@@ -536,11 +500,5 @@ | ||
getDataCache(ele)[key] = value; | ||
} // @require core/cash.js | ||
// @require core/type_checking.js | ||
// @require collection/each.js | ||
// @require ./helpers/get_data.js | ||
// @require ./helpers/set_data.js | ||
// @require ./helpers/variables.js | ||
} | ||
fn.data = function (name, value) { | ||
function data(name, value) { | ||
var _this = this; | ||
@@ -550,3 +508,3 @@ | ||
if (!this[0]) return; | ||
each(this[0].attributes, function (attr) { | ||
each(this[0].attributes, function (i, attr) { | ||
var match = attr.name.match(dataAttributeRe); | ||
@@ -572,14 +530,13 @@ if (!match) return; | ||
return this; | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
// @require ./helpers/remove_data.js | ||
} | ||
Cash.prototype.data = data; | ||
fn.removeData = function (key) { | ||
Cash.prototype.removeData = function (key) { | ||
return this.each(function (i, ele) { | ||
return removeData(ele, key); | ||
}); | ||
}; // @optional ./data.js | ||
// @optional ./remove_data.js | ||
// @require css/helpers/compute_style_int.js | ||
}; // @optional ./data.ts | ||
// @optional ./remove_data.ts | ||
// @require css/helpers/compute_style_int.ts | ||
@@ -589,9 +546,6 @@ | ||
return computeStyleInt(ele, "border" + (xAxis ? 'Left' : 'Top') + "Width") + computeStyleInt(ele, "padding" + (xAxis ? 'Left' : 'Top')) + computeStyleInt(ele, "padding" + (xAxis ? 'Right' : 'Bottom')) + computeStyleInt(ele, "border" + (xAxis ? 'Right' : 'Bottom') + "Width"); | ||
} // @require core/cash.js | ||
// @require core/each.js | ||
// @require core/variables.js | ||
} | ||
each(['Width', 'Height'], function (prop) { | ||
fn["inner" + prop] = function () { | ||
each(['Width', 'Height'], function (i, prop) { | ||
Cash.prototype["inner" + prop] = function () { | ||
if (!this[0]) return; | ||
@@ -601,12 +555,5 @@ if (this[0] === win) return win["inner" + prop]; | ||
}; | ||
}); // @require core/camel_case.js | ||
// @require core/cash.js | ||
// @require core/each.js | ||
// @require core/variables.js | ||
// @require css/helpers/compute_style.js | ||
// @require css/helpers/get_suffixed_value.js | ||
// @require ./helpers/get_extra_space.js | ||
each(['width', 'height'], function (prop, index) { | ||
fn[prop] = function (value) { | ||
}); | ||
each(['width', 'height'], function (index, prop) { | ||
Cash.prototype[prop] = function (value) { | ||
if (!this[0]) return value === undefined ? undefined : this; | ||
@@ -619,16 +566,12 @@ | ||
value = parseInt(value, 10); | ||
var valueNumber = parseInt(value, 10); | ||
return this.each(function (i, ele) { | ||
if (ele.nodeType !== 1) return; | ||
var boxSizing = computeStyle(ele, 'boxSizing'); | ||
ele.style[prop] = getSuffixedValue(prop, value + (boxSizing === 'border-box' ? getExtraSpace(ele, !index) : 0)); | ||
ele.style[prop] = getSuffixedValue(prop, valueNumber + (boxSizing === 'border-box' ? getExtraSpace(ele, !index) : 0)); | ||
}); | ||
}; | ||
}); // @require core/cash.js | ||
// @require core/each.js | ||
// @require core/variables.js | ||
// @require css/helpers/compute_style_int.js | ||
each(['Width', 'Height'], function (prop, index) { | ||
fn["outer" + prop] = function (includeMargins) { | ||
}); | ||
each(['Width', 'Height'], function (index, prop) { | ||
Cash.prototype["outer" + prop] = function (includeMargins) { | ||
if (!this[0]) return; | ||
@@ -638,40 +581,28 @@ if (this[0] === win) return win["outer" + prop]; | ||
}; | ||
}); // @optional ./inner.js | ||
// @optional ./normal.js | ||
// @optional ./outer.js | ||
}); // @optional ./inner.ts | ||
// @optional ./normal.ts | ||
// @optional ./outer.ts | ||
function hasNamespaces(ns1, ns2) { | ||
for (var i = 0, l = ns2.length; i < l; i++) { | ||
if (ns1.indexOf(ns2[i]) < 0) return false; | ||
} | ||
return true; | ||
} // @require core/each.js | ||
function removeEventListeners(cache, ele, name) { | ||
each(cache[name], function (_ref) { | ||
var namespaces = _ref[0], | ||
callback = _ref[1]; | ||
ele.removeEventListener(name, callback); | ||
return !ns2 || !some.call(ns2, function (ns) { | ||
return ns1.indexOf(ns) < 0; | ||
}); | ||
delete cache[name]; | ||
} | ||
var eventsNamespace = '__cashEvents', | ||
eventsNamespacesSeparator = '.'; // @require ./variables.js | ||
eventsNamespacesSeparator = '.'; // @require ./variables.ts | ||
function getEventsCache(ele) { | ||
return ele[eventsNamespace] = ele[eventsNamespace] || {}; | ||
} // @require core/guid.js | ||
// @require events/helpers/get_events_cache.js | ||
} // @require core/guid.ts | ||
// @require events/helpers/get_events_cache.ts | ||
function addEvent(ele, name, namespaces, callback) { | ||
callback.guid = callback.guid || guid++; | ||
callback['guid'] = callback['guid'] || guid++; | ||
var eventCache = getEventsCache(ele); | ||
eventCache[name] = eventCache[name] || []; | ||
eventCache[name].push([namespaces, callback]); | ||
ele.addEventListener(name, callback); | ||
} // @require ./variables.js | ||
ele.addEventListener(name, callback); //TSC | ||
} // @require ./variables.ts | ||
@@ -681,8 +612,6 @@ | ||
var parts = eventName.split(eventsNamespacesSeparator); | ||
return [parts[0], parts.slice(1).sort()]; // [name, namespaces] | ||
} // @require core/guid.js | ||
// @require ./get_events_cache.js | ||
// @require ./has_namespaces.js | ||
// @require ./parse_event_name.js | ||
// @require ./remove_event_listeners.js | ||
return [parts[0], parts.slice(1).sort()]; // [name, namespace[]] | ||
} // @require ./get_events_cache.ts | ||
// @require ./has_namespaces.ts | ||
// @require ./parse_event_name.ts | ||
@@ -694,32 +623,20 @@ | ||
if (!name) { | ||
if (!namespaces || !namespaces.length) { | ||
for (name in cache) { | ||
removeEventListeners(cache, ele, name); | ||
} | ||
} else { | ||
for (name in cache) { | ||
removeEvent(ele, name, namespaces, callback); | ||
} | ||
for (name in cache) { | ||
removeEvent(ele, name, namespaces, callback); | ||
} | ||
} else { | ||
var eventCache = cache[name]; | ||
if (!eventCache) return; | ||
if (callback) callback.guid = callback.guid || guid++; | ||
cache[name] = eventCache.filter(function (_ref2) { | ||
var ns = _ref2[0], | ||
cb = _ref2[1]; | ||
if (callback && cb.guid !== callback.guid || !hasNamespaces(ns, namespaces)) return true; | ||
delete ele[eventsNamespace]; | ||
} else if (cache[name]) { | ||
cache[name] = cache[name].filter(function (_a) { | ||
var ns = _a[0], | ||
cb = _a[1]; | ||
if (callback && cb['guid'] !== callback['guid'] || !hasNamespaces(ns, namespaces)) return true; | ||
ele.removeEventListener(name, cb); | ||
}); | ||
} | ||
} // @require core/cash.js | ||
// @require core/each.js | ||
// @require collection/each.js | ||
// @require ./helpers/parse_event_name.js | ||
// @require ./helpers/remove_event.js | ||
} | ||
Cash.prototype.off = function (eventFullName, callback) { | ||
var _this = this; | ||
fn.off = function (eventFullName, callback) { | ||
var _this2 = this; | ||
if (eventFullName === undefined) { | ||
@@ -730,8 +647,8 @@ this.each(function (i, ele) { | ||
} else { | ||
each(getSplitValues(eventFullName), function (eventFullName) { | ||
var _parseEventName = parseEventName(eventFullName), | ||
name = _parseEventName[0], | ||
namespaces = _parseEventName[1]; | ||
each(getSplitValues(eventFullName), function (i, eventFullName) { | ||
var _a = parseEventName(eventFullName), | ||
name = _a[0], | ||
namespaces = _a[1]; | ||
_this2.each(function (i, ele) { | ||
_this.each(function (i, ele) { | ||
return removeEvent(ele, name, namespaces, callback); | ||
@@ -743,18 +660,7 @@ }); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/get_split_values.js | ||
// @require core/guid.js | ||
// @require core/matches.js | ||
// @require core/type_checking.js | ||
// @require collection/each.js | ||
// @require ./helpers/variables.js | ||
// @require ./helpers/add_event.js | ||
// @require ./helpers/has_namespaces.js | ||
// @require ./helpers/parse_event_name.js | ||
// @require ./helpers/remove_event.js | ||
}; | ||
function on(eventFullName, selector, callback, _one) { | ||
var _this = this; | ||
fn.on = function (eventFullName, selector, callback, _one) { | ||
var _this3 = this; | ||
if (!isString(eventFullName)) { | ||
@@ -770,11 +676,11 @@ for (var key in eventFullName) { | ||
callback = selector; | ||
selector = false; | ||
selector = ''; | ||
} | ||
each(getSplitValues(eventFullName), function (eventFullName) { | ||
var _parseEventName2 = parseEventName(eventFullName), | ||
name = _parseEventName2[0], | ||
namespaces = _parseEventName2[1]; | ||
each(getSplitValues(eventFullName), function (i, eventFullName) { | ||
var _a = parseEventName(eventFullName), | ||
name = _a[0], | ||
namespaces = _a[1]; | ||
_this3.each(function (i, ele) { | ||
_this.each(function (i, ele) { | ||
var finalCallback = function finalCallback(event) { | ||
@@ -788,2 +694,3 @@ if (event.namespace && !hasNamespaces(namespaces, event.namespace.split(eventsNamespacesSeparator))) return; | ||
while (!matches(target, selector)) { | ||
//TSC | ||
if (target === ele) return; | ||
@@ -798,3 +705,3 @@ target = target.parentNode; | ||
event.namespace = event.namespace || ''; | ||
var returnValue = callback.call(thisArg, event, event.data); | ||
var returnValue = callback.call(thisArg, event, event.data); //TSC | ||
@@ -811,3 +718,3 @@ if (_one) { | ||
finalCallback.guid = callback.guid = callback.guid || guid++; | ||
finalCallback['guid'] = callback['guid'] = callback['guid'] || guid++; | ||
addEvent(ele, name, namespaces, finalCallback); | ||
@@ -817,13 +724,14 @@ }); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require ./on.js | ||
} | ||
Cash.prototype.on = on; | ||
fn.one = function (eventFullName, delegate, callback) { | ||
return this.on(eventFullName, delegate, callback, true); | ||
}; // @require core/cash.js | ||
// @require core/variables.js | ||
function one(eventFullName, selector, callback) { | ||
return this.on(eventFullName, selector, callback, true); //TSC | ||
} | ||
; | ||
Cash.prototype.one = one; | ||
fn.ready = function (callback) { | ||
Cash.prototype.ready = function (callback) { | ||
var finalCallback = function finalCallback() { | ||
@@ -840,59 +748,35 @@ return callback(cash); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/type_checking.js | ||
// @require core/variables.js | ||
// @require collection/each.js | ||
// @require ./helpers/parse_event_name.js | ||
// @require ./helpers/variables.js | ||
}; | ||
fn.trigger = function (eventFullName, data) { | ||
Cash.prototype.trigger = function (eventFullName, data) { | ||
var evt = eventFullName; | ||
if (isString(eventFullName)) { | ||
var _parseEventName3 = parseEventName(eventFullName), | ||
name = _parseEventName3[0], | ||
namespaces = _parseEventName3[1]; | ||
var _a = parseEventName(eventFullName), | ||
name_1 = _a[0], | ||
namespaces = _a[1]; | ||
evt = doc.createEvent('HTMLEvents'); | ||
evt.initEvent(name, true, true); | ||
evt.namespace = namespaces.join(eventsNamespacesSeparator); | ||
evt.initEvent(name_1, true, true); | ||
evt['namespace'] = namespaces.join(eventsNamespacesSeparator); | ||
} | ||
evt.data = data; | ||
evt['data'] = data; | ||
return this.each(function (i, ele) { | ||
ele.dispatchEvent(evt); | ||
}); | ||
}; // @optional ./off.js | ||
// @optional ./on.js | ||
// @optional ./one.js | ||
// @optional ./ready.js | ||
// @optional ./trigger.js | ||
// @require core/each.js | ||
}; // @optional ./off.ts | ||
// @optional ./on.ts | ||
// @optional ./one.ts | ||
// @optional ./ready.ts | ||
// @optional ./trigger.ts | ||
// @require core/pluck.ts | ||
// @require core/variables.ts | ||
function getValueSelectMultiple(ele) { | ||
var values = []; | ||
each(ele.options, function (option) { | ||
if (option.selected && !option.disabled && !option.parentNode.disabled) { | ||
values.push(option.value); | ||
} | ||
}); | ||
return values; | ||
} | ||
function getValueSelectSingle(ele) { | ||
return ele.selectedIndex < 0 ? null : ele.options[ele.selectedIndex].value; | ||
} // @require ./get_value_select_single.js | ||
// @require ./get_value_select_multiple.js | ||
var selectOneRe = /select-one/i, | ||
selectMultipleRe = /select-multiple/i; | ||
function getValue(ele) { | ||
var type = ele.type; | ||
if (selectOneRe.test(type)) return getValueSelectSingle(ele); | ||
if (selectMultipleRe.test(type)) return getValueSelectMultiple(ele); | ||
return ele.value; | ||
if (ele.multiple) return pluck(filter.call(ele.options, function (option) { | ||
return option.selected && !option.disabled && !option.parentNode.disabled; | ||
}), 'value'); | ||
return ele.value || ''; | ||
} | ||
@@ -904,7 +788,7 @@ | ||
return "&" + encodeURIComponent(prop) + "=" + encodeURIComponent(value).replace(queryEncodeSpaceRe, '+'); | ||
} // @require core/cash.js | ||
// @require core/each.js | ||
// @require core/type_checking.js | ||
// @require ./helpers/get_value.js | ||
// @require ./helpers/query_encode.js | ||
} // @require core/cash.ts | ||
// @require core/each.ts | ||
// @require core/type_checking.ts | ||
// @require ./helpers/get_value.ts | ||
// @require ./helpers/query_encode.ts | ||
@@ -915,13 +799,11 @@ | ||
fn.serialize = function () { | ||
Cash.prototype.serialize = function () { | ||
var query = ''; | ||
this.each(function (i, ele) { | ||
each(ele.elements || [ele], function (ele) { | ||
if (ele.disabled || !ele.name || ele.tagName === 'FIELDSET') return; | ||
if (skippableRe.test(ele.type)) return; | ||
if (checkableRe.test(ele.type) && !ele.checked) return; | ||
each(ele.elements || [ele], function (i, ele) { | ||
if (ele.disabled || !ele.name || ele.tagName === 'FIELDSET' || skippableRe.test(ele.type) || checkableRe.test(ele.type) && !ele.checked) return; | ||
var value = getValue(ele); | ||
if (value === undefined) return; | ||
var values = isArray(value) ? value : [value]; | ||
each(values, function (value) { | ||
each(values, function (i, value) { | ||
query += queryEncode(ele.name, value); | ||
@@ -932,17 +814,12 @@ }); | ||
return query.substr(1); | ||
}; // @require core/cash.js | ||
// @require core/each.js | ||
// @require core/type_checking.js | ||
// @require collection/each.js | ||
// @require ./helpers/get_value.js | ||
}; | ||
fn.val = function (value) { | ||
function val(value) { | ||
if (value === undefined) return this[0] && getValue(this[0]); | ||
return this.each(function (i, ele) { | ||
var isMultiple = selectMultipleRe.test(ele.type), | ||
var isMultiple = ele.multiple, | ||
eleValue = value === null ? isMultiple ? [] : '' : value; | ||
if (isMultiple && isArray(eleValue)) { | ||
each(ele.options, function (option) { | ||
each(ele.options, function (i, option) { | ||
option.selected = eleValue.indexOf(option.value) >= 0; | ||
@@ -954,17 +831,13 @@ }); | ||
}); | ||
}; // @optional ./serialize.js | ||
// @optional ./val.js | ||
// @require core/cash.js | ||
// @require collection/map.js | ||
} | ||
Cash.prototype.val = val; | ||
fn.clone = function () { | ||
Cash.prototype.clone = function () { | ||
return this.map(function (i, ele) { | ||
return ele.cloneNode(true); | ||
}); | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
}; | ||
fn.detach = function () { | ||
Cash.prototype.detach = function () { | ||
return this.each(function (i, ele) { | ||
@@ -975,7 +848,7 @@ if (ele.parentNode) { | ||
}); | ||
}; // @require ./cash.js | ||
// @require ./variables.js | ||
// @require ./type_checking.js | ||
// @require collection/get.js | ||
// @require manipulation/detach.js | ||
}; // @require ./cash.ts | ||
// @require ./variables.ts | ||
// @require ./type_checking.ts | ||
// @require collection/get.ts | ||
// @require manipulation/detach.ts | ||
@@ -992,3 +865,3 @@ | ||
containers = { | ||
'*': doc.createElement('div'), | ||
'*': div, | ||
tr: doc.createElement('tbody'), | ||
@@ -1013,19 +886,5 @@ td: tr, | ||
cash.parseHTML = parseHTML; // @optional ./camel_case.js | ||
// @optional ./each.js | ||
// @optional ./export.js | ||
// @optional ./extend.js | ||
// @optional ./find.js | ||
// @optional ./get_compare_function.js | ||
// @optional ./get_split_values.js | ||
// @optional ./guid.js | ||
// @optional ./matches.js | ||
// @optional ./parse_html.js | ||
// @optional ./unique.js | ||
// @optional ./variables.js | ||
// @require ./cash.js | ||
// @require ./type_checking.js | ||
// @require core/cash.js | ||
cash.parseHTML = parseHTML; | ||
fn.empty = function () { | ||
Cash.prototype.empty = function () { | ||
var ele = this[0]; | ||
@@ -1048,198 +907,143 @@ | ||
} | ||
} // @require core/each.js | ||
// @require core/type_checking.js | ||
// @require ./insert_element.js | ||
} // @require core/each.ts | ||
// @require core/type_checking.ts | ||
// @require ./insert_element.ts | ||
function insertContent(parent, child, prepend) { | ||
if (child === undefined) return; | ||
var isStr = isString(child); | ||
if (!isStr && child.length) { | ||
each(child, function (ele) { | ||
return insertContent(parent, ele, prepend); | ||
each(parent, function (index, parentEle) { | ||
each(child, function (i, childEle) { | ||
insertElement(parentEle, !index ? childEle : childEle.cloneNode(true), prepend); | ||
}); | ||
} else { | ||
each(parent, isStr ? function (ele) { | ||
ele.insertAdjacentHTML(prepend ? 'afterbegin' : 'beforeend', child); | ||
} : function (ele, index) { | ||
return insertElement(ele, !index ? child : child.cloneNode(true), prepend); | ||
}); | ||
} | ||
} // @require core/cash.js | ||
// @require core/each.js | ||
// @require ./helpers/insert_content.js | ||
}); | ||
} | ||
Cash.prototype.append = function () { | ||
var _this = this; | ||
fn.append = function () { | ||
var _this4 = this; | ||
each(arguments, function (content) { | ||
insertContent(_this4, content); | ||
each(arguments, function (i, selector) { | ||
insertContent(_this, cash(selector)); | ||
}); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require ./helpers/insert_content.js | ||
}; | ||
fn.appendTo = function (parent) { | ||
insertContent(cash(parent), this); | ||
Cash.prototype.appendTo = function (selector) { | ||
insertContent(cash(selector), this); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
}; | ||
fn.html = function (content) { | ||
if (content === undefined) return this[0] && this[0].innerHTML; | ||
var source = content.nodeType ? content[0].outerHTML : content; | ||
function html(html) { | ||
if (html === undefined) return this[0] && this[0].innerHTML; | ||
return this.each(function (i, ele) { | ||
ele.innerHTML = source; | ||
ele.innerHTML = html; | ||
}); | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
} | ||
Cash.prototype.html = html; | ||
fn.insertAfter = function (content) { | ||
var _this5 = this; | ||
Cash.prototype.insertAfter = function (selector) { | ||
var _this = this; | ||
cash(content).each(function (index, ele) { | ||
cash(selector).each(function (index, ele) { | ||
var parent = ele.parentNode; | ||
_this5.each(function (i, e) { | ||
parent.insertBefore(!index ? e : e.cloneNode(true), ele.nextSibling); | ||
}); | ||
if (parent) { | ||
_this.each(function (i, e) { | ||
parent.insertBefore(!index ? e : e.cloneNode(true), ele.nextSibling); | ||
}); | ||
} | ||
}); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/each.js | ||
// @require core/variables.js | ||
// @require collection/slice.js | ||
// @require ./insert_after.js | ||
}; | ||
Cash.prototype.after = function () { | ||
var _this = this; | ||
fn.after = function () { | ||
var _this6 = this; | ||
each(reverse.apply(arguments), function (content) { | ||
reverse.apply(cash(content).slice()).insertAfter(_this6); | ||
each(reverse.apply(arguments), function (i, selector) { | ||
reverse.apply(cash(selector).slice()).insertAfter(_this); | ||
}); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
}; | ||
Cash.prototype.insertBefore = function (selector) { | ||
var _this = this; | ||
fn.insertBefore = function (selector) { | ||
var _this7 = this; | ||
cash(selector).each(function (index, ele) { | ||
var parent = ele.parentNode; | ||
_this7.each(function (i, e) { | ||
parent.insertBefore(!index ? e : e.cloneNode(true), ele); | ||
}); | ||
if (parent) { | ||
_this.each(function (i, e) { | ||
parent.insertBefore(!index ? e : e.cloneNode(true), ele); | ||
}); | ||
} | ||
}); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/each.js | ||
// @require ./insert_before.js | ||
}; | ||
Cash.prototype.before = function () { | ||
var _this = this; | ||
fn.before = function () { | ||
var _this8 = this; | ||
each(arguments, function (content) { | ||
cash(content).insertBefore(_this8); | ||
each(arguments, function (i, selector) { | ||
cash(selector).insertBefore(_this); | ||
}); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/each.js | ||
// @require ./helpers/insert_content.js | ||
}; | ||
Cash.prototype.prepend = function () { | ||
var _this = this; | ||
fn.prepend = function () { | ||
var _this9 = this; | ||
each(arguments, function (content) { | ||
insertContent(_this9, content, true); | ||
each(arguments, function (i, selector) { | ||
insertContent(_this, cash(selector), true); | ||
}); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/variables.js | ||
// @require collection/slice.js | ||
// @require ./helpers/insert_content.js | ||
}; | ||
fn.prependTo = function (parent) { | ||
insertContent(cash(parent), reverse.apply(this.slice()), true); | ||
Cash.prototype.prependTo = function (selector) { | ||
insertContent(cash(selector), reverse.apply(this.slice()), true); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require events/off.js | ||
// @require ./detach.js | ||
}; | ||
fn.remove = function () { | ||
Cash.prototype.remove = function () { | ||
return this.detach().off(); | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
// @require collection/slice.js | ||
// @require ./after.js | ||
// @require ./remove.js | ||
}; | ||
Cash.prototype.replaceWith = function (selector) { | ||
return this.before(selector).remove(); | ||
}; | ||
fn.replaceWith = function (content) { | ||
var _this10 = this; | ||
return this.each(function (i, ele) { | ||
var parent = ele.parentNode; | ||
if (!parent) return; | ||
var $eles = i ? cash(content).clone() : cash(content); | ||
if (!$eles[0]) { | ||
_this10.remove(); | ||
return false; | ||
} | ||
parent.replaceChild($eles[0], ele); | ||
cash($eles[0]).after($eles.slice(1)); | ||
}); | ||
}; // @require core/cash.js | ||
// @require ./replace_with.js | ||
fn.replaceAll = function (content) { | ||
cash(content).replaceWith(this); | ||
Cash.prototype.replaceAll = function (selector) { | ||
cash(selector).replaceWith(this); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
}; | ||
fn.text = function (content) { | ||
if (content === undefined) return this[0] ? this[0].textContent : ''; | ||
function text(text) { | ||
if (text === undefined) return this[0] ? this[0].textContent : ''; | ||
return this.each(function (i, ele) { | ||
ele.textContent = content; | ||
ele.textContent = text; | ||
}); | ||
}; // @optional ./after.js | ||
// @optional ./append.js | ||
// @optional ./append_to.js | ||
// @optional ./before.js | ||
// @optional ./clone.js | ||
// @optional ./detach.js | ||
// @optional ./empty.js | ||
// @optional ./html.js | ||
// @optional ./insert_after.js | ||
// @optional ./insert_before.js | ||
// @optional ./prepend.js | ||
// @optional ./prepend_to.js | ||
// @optional ./remove.js | ||
// @optional ./replace_all.js | ||
// @optional ./replace_with.js | ||
// @optional ./text.js | ||
// @require core/cash.js | ||
// @require core/variables.js | ||
} | ||
; | ||
Cash.prototype.text = text; // @optional ./after.ts | ||
// @optional ./append.ts | ||
// @optional ./append_to.ts | ||
// @optional ./before.ts | ||
// @optional ./clone.ts | ||
// @optional ./detach.ts | ||
// @optional ./empty.ts | ||
// @optional ./html.ts | ||
// @optional ./insert_after.ts | ||
// @optional ./insert_before.ts | ||
// @optional ./prepend.ts | ||
// @optional ./prepend_to.ts | ||
// @optional ./remove.ts | ||
// @optional ./replace_all.ts | ||
// @optional ./replace_with.ts | ||
// @optional ./text.ts | ||
// @require core/cash.ts | ||
// @require core/variables.ts | ||
var docEle = doc.documentElement; | ||
fn.offset = function () { | ||
Cash.prototype.offset = function () { | ||
var ele = this[0]; | ||
@@ -1252,11 +1056,9 @@ if (!ele) return; | ||
}; | ||
}; // @require core/cash.js | ||
}; | ||
fn.offsetParent = function () { | ||
Cash.prototype.offsetParent = function () { | ||
return cash(this[0] && this[0].offsetParent); | ||
}; // @require core/cash.js | ||
}; | ||
fn.position = function () { | ||
Cash.prototype.position = function () { | ||
var ele = this[0]; | ||
@@ -1268,13 +1070,5 @@ if (!ele) return; | ||
}; | ||
}; // @optional ./offset.js | ||
// @optional ./offset_parent.js | ||
// @optional ./position.js | ||
// @require core/cash.js | ||
// @require core/matches.js | ||
// @require core/unique.js | ||
// @require collection/each.js | ||
// @require collection/filter.js | ||
}; | ||
fn.children = function (selector) { | ||
Cash.prototype.children = function (selector) { | ||
var result = []; | ||
@@ -1286,11 +1080,6 @@ this.each(function (i, ele) { | ||
if (!selector) return result; | ||
return result.filter(function (i, ele) { | ||
return matches(ele, selector); | ||
}); | ||
}; // @require core/cash.js | ||
// @require core/unique.js | ||
// @require collection/each.js | ||
return result.filter(selector); | ||
}; | ||
fn.contents = function () { | ||
Cash.prototype.contents = function () { | ||
var result = []; | ||
@@ -1300,10 +1089,6 @@ this.each(function (i, ele) { | ||
}); | ||
return cash(result.length && unique(result)); | ||
}; // @require core/cash.js | ||
// @require core/unique.js | ||
// @require core/find.js | ||
// @require core/variables.js | ||
return cash(unique(result)); | ||
}; | ||
fn.find = function (selector) { | ||
Cash.prototype.find = function (selector) { | ||
var result = []; | ||
@@ -1319,10 +1104,6 @@ | ||
return cash(result.length && unique(result)); | ||
}; // @require core/cash.js | ||
// @require core/find.js | ||
// @require core/type_checking.js | ||
// @require collection/filter.js | ||
return cash(unique(result)); | ||
}; | ||
fn.has = function (selector) { | ||
Cash.prototype.has = function (selector) { | ||
var comparator = isString(selector) ? function (i, ele) { | ||
@@ -1334,85 +1115,44 @@ return !!find(selector, ele).length; | ||
return this.filter(comparator); | ||
}; // @require core/cash.js | ||
// @require core/get_compare_function.js | ||
// @require collection/each.js | ||
}; | ||
fn.is = function (selector) { | ||
if (!selector || !this[0]) return false; | ||
var comparator = getCompareFunction(selector); | ||
Cash.prototype.is = function (comparator) { | ||
if (!comparator || !this[0]) return false; | ||
var compare = getCompareFunction(comparator); | ||
var check = false; | ||
this.each(function (i, ele) { | ||
check = comparator(i, ele, selector); | ||
check = compare.call(ele, i, ele); | ||
return !check; | ||
}); | ||
return check; | ||
}; // @require core/cash.js | ||
}; | ||
Cash.prototype.next = function () { | ||
return cash(unique(pluck(this, 'nextElementSibling'))); | ||
}; | ||
fn.next = function () { | ||
return cash(this[0] && this[0].nextElementSibling); | ||
}; // @require core/cash.js | ||
// @require core/get_compare_function.js | ||
// @require collection/filter.js | ||
fn.not = function (selector) { | ||
if (!selector || !this[0]) return this; | ||
var comparator = getCompareFunction(selector); | ||
Cash.prototype.not = function (comparator) { | ||
if (!comparator || !this[0]) return this; | ||
var compare = getCompareFunction(comparator); | ||
return this.filter(function (i, ele) { | ||
return !comparator(i, ele, selector); | ||
return !compare.call(ele, i, ele); | ||
}); | ||
}; // @require core/cash.js | ||
// @require core/unique.js | ||
// @require collection/each.js | ||
}; | ||
Cash.prototype.parent = function () { | ||
return cash(unique(pluck(this, 'parentNode'))); | ||
}; | ||
fn.parent = function () { | ||
var result = []; | ||
this.each(function (i, ele) { | ||
if (ele && ele.parentNode) { | ||
result.push(ele.parentNode); | ||
} | ||
}); | ||
return cash(unique(result)); | ||
}; // @require core/cash.js | ||
// @require core/variables.js | ||
// @require traversal/children.js | ||
// @require traversal/parent.js | ||
// @require ./get.js | ||
//FIXME Ugly file name, is there a better option? | ||
fn.index = function (ele) { | ||
var child = ele ? cash(ele)[0] : this[0], | ||
collection = ele ? this : cash(child).parent().children(); | ||
Cash.prototype.index = function (selector) { | ||
var child = selector ? cash(selector)[0] : this[0], | ||
collection = selector ? this : cash(child).parent().children(); | ||
return indexOf.call(collection, child); | ||
}; // @optional ./add.js | ||
// @optional ./each.js | ||
// @optional ./eq.js | ||
// @optional ./filter.js | ||
// @optional ./first.js | ||
// @optional ./get.js | ||
// @optional ./indexFn.js | ||
// @optional ./last.js | ||
// @optional ./map.js | ||
// @optional ./slice.js | ||
// @require core/cash.js | ||
// @require collection/filter.js | ||
// @require ./is.js | ||
// @require ./parent.js | ||
}; | ||
fn.closest = function (selector) { | ||
Cash.prototype.closest = function (selector) { | ||
if (!selector || !this[0]) return cash(); | ||
if (this.is(selector)) return this.filter(selector); | ||
return this.parent().closest(selector); | ||
}; // @require core/cash.js | ||
// @require core/matches.js | ||
// @require core/unique.js | ||
// @require core/variables.js | ||
// @require collection/each.js | ||
}; | ||
fn.parents = function (selector) { | ||
Cash.prototype.parents = function (selector) { | ||
var result = []; | ||
@@ -1432,14 +1172,9 @@ var last; | ||
return cash(unique(result)); | ||
}; // @require core/cash.js | ||
}; | ||
Cash.prototype.prev = function () { | ||
return cash(unique(pluck(this, 'previousElementSibling'))); | ||
}; | ||
fn.prev = function () { | ||
return cash(this[0] && this[0].previousElementSibling); | ||
}; // @require core/cash.js | ||
// @require collection/filter.js | ||
// @require ./children.js | ||
// @require ./parent.js | ||
fn.siblings = function () { | ||
Cash.prototype.siblings = function () { | ||
var ele = this[0]; | ||
@@ -1449,25 +1184,29 @@ return this.parent().children().filter(function (i, child) { | ||
}); | ||
}; // @optional ./children.js | ||
// @optional ./closest.js | ||
// @optional ./contents.js | ||
// @optional ./find.js | ||
// @optional ./has.js | ||
// @optional ./is.js | ||
// @optional ./next.js | ||
// @optional ./not.js | ||
// @optional ./parent.js | ||
// @optional ./parents.js | ||
// @optional ./prev.js | ||
// @optional ./siblings.js | ||
// @optional attributes/index.js | ||
// @optional collection/index.js | ||
// @optional css/index.js | ||
// @optional data/index.js | ||
// @optional dimensions/index.js | ||
// @optional events/index.js | ||
// @optional forms/index.js | ||
// @optional manipulation/index.js | ||
// @optional offset/index.js | ||
// @optional traversal/index.js | ||
// @require core/index.js | ||
export default cash; | ||
}; // @optional ./children.ts | ||
// @optional ./closest.ts | ||
// @optional ./contents.ts | ||
// @optional ./find.ts | ||
// @optional ./has.ts | ||
// @optional ./is.ts | ||
// @optional ./next.ts | ||
// @optional ./not.ts | ||
// @optional ./parent.ts | ||
// @optional ./parents.ts | ||
// @optional ./prev.ts | ||
// @optional ./siblings.ts | ||
// @optional attributes/index.ts | ||
// @optional collection/index.ts | ||
// @optional css/index.ts | ||
// @optional data/index.ts | ||
// @optional dimensions/index.ts | ||
// @optional events/index.ts | ||
// @optional forms/index.ts | ||
// @optional manipulation/index.ts | ||
// @optional offset/index.ts | ||
// @optional traversal/index.ts | ||
// @require core/index.ts | ||
// @priority -100 | ||
// @require ./cash.ts | ||
exports["default"] = cash; |
1202
dist/cash.js
@@ -7,14 +7,16 @@ /* MIT https://github.com/kenwheeler/cash */ | ||
win = window, | ||
_Array$prototype = Array.prototype, | ||
filter = _Array$prototype.filter, | ||
indexOf = _Array$prototype.indexOf, | ||
map = _Array$prototype.map, | ||
push = _Array$prototype.push, | ||
reverse = _Array$prototype.reverse, | ||
slice = _Array$prototype.slice, | ||
splice = _Array$prototype.splice; | ||
div = doc.createElement('div'), | ||
_a = Array.prototype, | ||
filter = _a.filter, | ||
indexOf = _a.indexOf, | ||
map = _a.map, | ||
push = _a.push, | ||
reverse = _a.reverse, | ||
slice = _a.slice, | ||
some = _a.some, | ||
splice = _a.splice; | ||
var idRe = /^#[\w-]*$/, | ||
classRe = /^\.[\w-]*$/, | ||
htmlRe = /<.+>/, | ||
tagRe = /^\w+$/; // @require ./variables.js | ||
tagRe = /^\w+$/; // @require ./variables.ts | ||
@@ -27,134 +29,112 @@ function find(selector, context) { | ||
return classRe.test(selector) ? context.getElementsByClassName(selector.slice(1)) : tagRe.test(selector) ? context.getElementsByTagName(selector) : context.querySelectorAll(selector); | ||
} // @require ./find.js | ||
// @require ./variables.js | ||
} // @require ./find.ts | ||
// @require ./variables.ts | ||
function Cash(selector, context) { | ||
if (context === void 0) { | ||
context = doc; | ||
} | ||
var Cash = | ||
/** @class */ | ||
function () { | ||
function Cash(selector, context) { | ||
if (context === void 0) { | ||
context = doc; | ||
} | ||
if (!selector) return; | ||
if (selector.__cash) return selector; | ||
var eles = selector; | ||
if (!selector) return; | ||
if (isCash(selector)) return selector; | ||
var eles = selector; | ||
if (isString(selector)) { | ||
if (context.__cash) context = context[0]; | ||
eles = idRe.test(selector) ? context.getElementById(selector.slice(1)) : htmlRe.test(selector) ? parseHTML(selector) : find(selector, context); | ||
if (!eles) return; | ||
} else if (isFunction(selector)) { | ||
return this.ready(selector); //FIXME: `fn.ready` is not included in `core`, but it's actually a core functionality | ||
} | ||
if (isString(selector)) { | ||
var ctx = isCash(context) ? context[0] : context; | ||
eles = idRe.test(selector) ? ctx.getElementById(selector.slice(1)) : htmlRe.test(selector) ? parseHTML(selector) : find(selector, ctx); | ||
if (!eles) return; | ||
} else if (isFunction(selector)) { | ||
return this.ready(selector); //FIXME: `fn.ready` is not included in `core`, but it's actually a core functionality | ||
} | ||
if (eles.nodeType || eles === win) eles = [eles]; | ||
this.length = eles.length; | ||
if (eles.nodeType || eles === win) eles = [eles]; | ||
this.length = eles.length; | ||
for (var i = 0, l = this.length; i < l; i++) { | ||
this[i] = eles[i]; | ||
for (var i = 0, l = this.length; i < l; i++) { | ||
this[i] = eles[i]; | ||
} | ||
} | ||
} | ||
function cash(selector, context) { | ||
return new Cash(selector, context); | ||
} | ||
/* PROTOTYPE */ | ||
Cash.prototype.init = function (selector, context) { | ||
return new Cash(selector, context); | ||
}; | ||
return Cash; | ||
}(); | ||
var fn = cash.fn = cash.prototype = Cash.prototype = { | ||
constructor: cash, | ||
__cash: true, | ||
length: 0, | ||
splice: splice // Ensures a cash collection gets printed as array-like in Chrome | ||
var cash = Cash.prototype.init; | ||
cash.fn = cash.prototype = Cash.prototype; // Ensuring that `cash () instanceof cash` | ||
}; // @require core/cash.js | ||
// @require core/variables.js | ||
Cash.prototype.length = 0; | ||
Cash.prototype.splice = splice; // Ensuring a cash collection gets printed as array-like in Chrome | ||
fn.get = function (index) { | ||
Cash.prototype.get = function (index) { | ||
if (index === undefined) return slice.call(this); | ||
return this[index < 0 ? index + this.length : index]; | ||
}; // @require core/cash.js | ||
// @require ./get.js | ||
}; | ||
fn.eq = function (index) { | ||
Cash.prototype.eq = function (index) { | ||
return cash(this.get(index)); | ||
}; // @require core/cash.js | ||
// @require ./eq.js | ||
}; | ||
fn.first = function () { | ||
Cash.prototype.first = function () { | ||
return this.eq(0); | ||
}; // @require core/cash.js | ||
// @require ./eq.js | ||
}; | ||
fn.last = function () { | ||
Cash.prototype.last = function () { | ||
return this.eq(-1); | ||
}; // @require core/cash.js | ||
// @require core/variables.js | ||
}; | ||
fn.map = function (callback) { | ||
Cash.prototype.map = function (callback) { | ||
return cash(map.call(this, function (ele, i) { | ||
return callback.call(ele, i, ele); | ||
})); | ||
}; // @require core/cash.js | ||
// @require core/variables.js | ||
}; | ||
fn.slice = function () { | ||
Cash.prototype.slice = function () { | ||
return cash(slice.apply(this, arguments)); | ||
}; // @require ./cash.js | ||
}; // @require ./cash.ts | ||
var camelCaseRe = /(?:^\w|[A-Z]|\b\w)/g, | ||
camelCaseWhitespaceRe = /[\s-_]+/g; | ||
var dashAlphaRe = /-([a-z])/g; | ||
function camelCaseReplace(all, letter) { | ||
return letter.toUpperCase(); | ||
} | ||
function camelCase(str) { | ||
return str.replace(camelCaseRe, function (letter, index) { | ||
return letter[!index ? 'toLowerCase' : 'toUpperCase'](); | ||
}).replace(camelCaseWhitespaceRe, ''); | ||
return str.replace(dashAlphaRe, camelCaseReplace); | ||
} | ||
; | ||
cash.camelCase = camelCase; // @require ./cash.js | ||
cash.camelCase = camelCase; // @require ./cash.ts | ||
function each(arr, callback) { | ||
for (var i = 0, l = arr.length; i < l; i++) { | ||
if (callback.call(arr[i], arr[i], i, arr) === false) break; | ||
if (callback.call(arr[i], i, arr[i]) === false) break; | ||
} | ||
} | ||
cash.each = each; // @require core/cash.js | ||
// @require core/each.js | ||
cash.each = each; | ||
fn.each = function (callback) { | ||
each(this, function (ele, i) { | ||
return callback.call(ele, i, ele); | ||
}); | ||
Cash.prototype.each = function (callback) { | ||
each(this, callback); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
}; | ||
fn.removeProp = function (prop) { | ||
Cash.prototype.removeProp = function (prop) { | ||
return this.each(function (i, ele) { | ||
delete ele[prop]; | ||
}); | ||
}; // @require ./cash.js | ||
// @require ./variables.js | ||
}; // @require ./cash.ts | ||
if (typeof exports !== 'undefined') { | ||
// Node.js | ||
module.exports = cash; | ||
} else { | ||
// Browser | ||
win.cash = win.$ = cash; | ||
} // @require ./cash.js | ||
function extend(target) { | ||
var objs = []; | ||
function extend(target) { | ||
if (target === void 0) { | ||
target = this; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
objs[_i - 1] = arguments[_i]; | ||
} | ||
@@ -174,15 +154,30 @@ | ||
; | ||
cash.extend = fn.extend = extend; // @require ./cash.js | ||
Cash.prototype.extend = function (plugins) { | ||
return extend(cash.fn, plugins); | ||
}; | ||
cash.extend = extend; // @require ./cash.ts | ||
var guid = 1; | ||
cash.guid = guid; // @require ./cash.js | ||
cash.guid = guid; // @require ./cash.ts | ||
function matches(ele, selector) { | ||
var matches = ele && (ele.matches || ele.webkitMatchesSelector || ele.mozMatchesSelector || ele.msMatchesSelector || ele.oMatchesSelector); | ||
return !!matches && matches.call(ele, selector); | ||
return !!ele && !!ele.matches && ele.matches(selector); | ||
} | ||
cash.matches = matches; // @require ./cash.js | ||
cash.matches = matches; // @require ./variables.ts | ||
function pluck(arr, prop) { | ||
return filter.call(map.call(arr, function (ele) { | ||
return ele[prop]; | ||
}), function (ele) { | ||
return ele != null; | ||
}); | ||
} // @require ./cash.ts | ||
function isCash(x) { | ||
return x instanceof Cash; | ||
} | ||
function isFunction(x) { | ||
@@ -192,4 +187,2 @@ return typeof x === 'function'; | ||
cash.isFunction = isFunction; | ||
function isString(x) { | ||
@@ -199,4 +192,2 @@ return typeof x === 'string'; | ||
cash.isString = isString; | ||
function isNumeric(x) { | ||
@@ -206,9 +197,9 @@ return !isNaN(parseFloat(x)) && isFinite(x); | ||
var isArray = Array.isArray; | ||
cash.isFunction = isFunction; | ||
cash.isString = isString; | ||
cash.isNumeric = isNumeric; | ||
var isArray = Array.isArray; | ||
cash.isArray = isArray; // @require core/cash.js | ||
// @require core/type_checking.js | ||
// @require collection/each.js | ||
cash.isArray = isArray; | ||
fn.prop = function (prop, value) { | ||
Cash.prototype.prop = function (prop, value) { | ||
if (!prop) return; | ||
@@ -228,28 +219,23 @@ | ||
return this; | ||
}; // @require ./matches.js | ||
// @require ./type_checking.js | ||
}; // @require ./matches.ts | ||
// @require ./type_checking.ts | ||
function getCompareFunction(selector) { | ||
return isString(selector) ? function (i, ele) { | ||
return matches(ele, selector); | ||
} : selector.__cash ? function (i, ele) { | ||
return selector.is(ele); | ||
} : function (i, ele, selector) { | ||
return ele === selector; | ||
function getCompareFunction(comparator) { | ||
return isString(comparator) ? function (i, ele) { | ||
return matches(ele, comparator); | ||
} : isFunction(comparator) ? comparator : isCash(comparator) ? function (i, ele) { | ||
return comparator.is(ele); | ||
} : function (i, ele) { | ||
return ele === comparator; | ||
}; | ||
} // @require core/cash.js | ||
// @require core/get_compare_function.js | ||
// @require core/type_checking.js | ||
// @require core/variables.js | ||
// @require collection/get.js | ||
} | ||
fn.filter = function (selector) { | ||
if (!selector) return cash(); | ||
var comparator = isFunction(selector) ? selector : getCompareFunction(selector); | ||
Cash.prototype.filter = function (comparator) { | ||
if (!comparator) return cash(); | ||
var compare = getCompareFunction(comparator); | ||
return cash(filter.call(this, function (ele, i) { | ||
return comparator.call(ele, i, ele, selector); | ||
return compare.call(ele, i, ele); | ||
})); | ||
}; // @require ./type_checking.js | ||
}; // @require ./type_checking.ts | ||
@@ -261,39 +247,21 @@ | ||
return isString(str) ? str.match(splitValuesRe) || [] : []; | ||
} // @require core/cash.js | ||
// @require core/get_split_values.js | ||
// @require collection/each.js | ||
} | ||
Cash.prototype.hasClass = function (cls) { | ||
return some.call(this, function (ele) { | ||
return ele.classList.contains(cls); | ||
}); | ||
}; | ||
fn.hasClass = function (cls) { | ||
var classes = getSplitValues(cls); | ||
var check = false; | ||
if (classes.length) { | ||
this.each(function (i, ele) { | ||
check = ele.classList.contains(classes[0]); | ||
return !check; | ||
}); | ||
} | ||
return check; | ||
}; // @require core/cash.js | ||
// @require core/get_split_values.js | ||
// @require collection/each.js | ||
fn.removeAttr = function (attr) { | ||
Cash.prototype.removeAttr = function (attr) { | ||
var attrs = getSplitValues(attr); | ||
if (!attrs.length) return this; | ||
return this.each(function (i, ele) { | ||
each(attrs, function (a) { | ||
each(attrs, function (i, a) { | ||
ele.removeAttribute(a); | ||
}); | ||
}); | ||
}; // @require core/cash.js | ||
// @require core/type_checking.js | ||
// @require collection/each.js | ||
// @require ./remove_attr.js | ||
}; | ||
fn.attr = function (attr, value) { | ||
function attr(attr, value) { | ||
if (!attr) return; | ||
@@ -304,6 +272,4 @@ | ||
if (!this[0]) return; | ||
var _value = this[0].getAttribute(attr); | ||
return _value === null ? undefined : _value; | ||
var value_1 = this[0].getAttribute(attr); | ||
return value_1 === null ? undefined : value_1; | ||
} | ||
@@ -322,9 +288,7 @@ | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/each.js | ||
// @require core/get_split_values.js | ||
// @require collection/each.js | ||
} | ||
Cash.prototype.attr = attr; | ||
fn.toggleClass = function (cls, force) { | ||
Cash.prototype.toggleClass = function (cls, force) { | ||
var classes = getSplitValues(cls), | ||
@@ -334,3 +298,3 @@ isForce = force !== undefined; | ||
return this.each(function (i, ele) { | ||
each(classes, function (c) { | ||
each(classes, function (i, c) { | ||
if (isForce) { | ||
@@ -343,46 +307,40 @@ force ? ele.classList.add(c) : ele.classList.remove(c); | ||
}); | ||
}; // @require core/cash.js | ||
// @require ./toggle_class.js | ||
}; | ||
fn.addClass = function (cls) { | ||
Cash.prototype.addClass = function (cls) { | ||
return this.toggleClass(cls, true); | ||
}; // @require core/cash.js | ||
// @require ./attr.js | ||
// @require ./toggle_class.js | ||
}; | ||
fn.removeClass = function (cls) { | ||
Cash.prototype.removeClass = function (cls) { | ||
return !arguments.length ? this.attr('class', '') : this.toggleClass(cls, false); | ||
}; // @optional ./add_class.js | ||
// @optional ./attr.js | ||
// @optional ./has_class.js | ||
// @optional ./prop.js | ||
// @optional ./remove_attr.js | ||
// @optional ./remove_class.js | ||
// @optional ./remove_prop.js | ||
// @optional ./toggle_class.js | ||
// @require ./cash.js | ||
}; // @optional ./add_class.ts | ||
// @optional ./attr.ts | ||
// @optional ./has_class.ts | ||
// @optional ./prop.ts | ||
// @optional ./remove_attr.ts | ||
// @optional ./remove_class.ts | ||
// @optional ./remove_prop.ts | ||
// @optional ./toggle_class.ts | ||
// @require ./cash.ts | ||
// @require ./variables | ||
function unique(arr) { | ||
return arr.filter(function (item, index, self) { | ||
return self.indexOf(item) === index; | ||
}); | ||
return arr.length > 1 ? filter.call(arr, function (item, index, self) { | ||
return indexOf.call(self, item) === index; | ||
}) : arr; | ||
} | ||
cash.unique = unique; // @require core/cash.js | ||
// @require core/unique.js | ||
// @require ./get.js | ||
cash.unique = unique; | ||
fn.add = function (selector, context) { | ||
Cash.prototype.add = function (selector, context) { | ||
return cash(unique(this.get().concat(cash(selector, context).get()))); | ||
}; // @require core/variables.js | ||
}; // @require core/variables.ts | ||
function computeStyle(ele, prop, isVariable) { | ||
if (ele.nodeType !== 1) return; | ||
if (ele.nodeType !== 1 || !prop) return; | ||
var style = win.getComputedStyle(ele, null); | ||
return prop ? isVariable ? style.getPropertyValue(prop) : style[prop] : style; | ||
} // @require ./compute_style.js | ||
return prop ? isVariable ? style.getPropertyValue(prop) || undefined : style[prop] : style; | ||
} // @require ./compute_style.ts | ||
@@ -394,16 +352,15 @@ | ||
var cssVariableRe = /^--/; // @require ./variables.js | ||
var cssVariableRe = /^--/; // @require ./variables.ts | ||
function isCSSVariable(prop) { | ||
return cssVariableRe.test(prop); | ||
} // @require core/camel_case.js | ||
// @require core/cash.js | ||
// @require core/each.js | ||
// @require core/variables.js | ||
// @require ./is_css_variable.js | ||
} // @require core/camel_case.ts | ||
// @require core/cash.ts | ||
// @require core/each.ts | ||
// @require core/variables.ts | ||
// @require ./is_css_variable.ts | ||
var prefixedProps = {}, | ||
_doc$createElement = doc.createElement('div'), | ||
style = _doc$createElement.style, | ||
style = div.style, | ||
vendorsPrefixes = ['webkit', 'moz', 'ms', 'o']; | ||
@@ -422,3 +379,3 @@ | ||
props = (propCC + " " + vendorsPrefixes.join(propUC + " ") + propUC).split(' '); | ||
each(props, function (p) { | ||
each(props, function (i, p) { | ||
if (p in style) { | ||
@@ -435,4 +392,4 @@ prefixedProps[prop] = p; | ||
; | ||
cash.prefixedProp = getPrefixedProp; // @require core/type_checking.js | ||
// @require ./is_css_variable.js | ||
cash.prefixedProp = getPrefixedProp; // @require core/type_checking.ts | ||
// @require ./is_css_variable.ts | ||
@@ -459,25 +416,18 @@ var numericProps = { | ||
return !isVariable && !numericProps[prop] && isNumeric(value) ? value + "px" : value; | ||
} // @require core/cash.js | ||
// @require core/type_checking.js | ||
// @require collection/each.js | ||
// @require ./helpers/compute_style.js | ||
// @require ./helpers/get_prefixed_prop.js | ||
// @require ./helpers/get_suffixed_value.js | ||
// @require ./helpers/is_css_variable.js | ||
} | ||
fn.css = function (prop, value) { | ||
function css(prop, value) { | ||
if (isString(prop)) { | ||
var isVariable = isCSSVariable(prop); | ||
prop = getPrefixedProp(prop, isVariable); | ||
if (arguments.length < 2) return this[0] && computeStyle(this[0], prop, isVariable); | ||
var isVariable_1 = isCSSVariable(prop); | ||
prop = getPrefixedProp(prop, isVariable_1); | ||
if (arguments.length < 2) return this[0] && computeStyle(this[0], prop, isVariable_1); | ||
if (!prop) return this; | ||
value = getSuffixedValue(prop, value, isVariable); | ||
value = getSuffixedValue(prop, value, isVariable_1); | ||
return this.each(function (i, ele) { | ||
if (ele.nodeType !== 1) return; | ||
if (isVariable) { | ||
if (isVariable_1) { | ||
ele.style.setProperty(prop, value); | ||
} else { | ||
ele.style[prop] = value; | ||
ele.style[prop] = value; //TSC | ||
} | ||
@@ -492,18 +442,21 @@ }); | ||
return this; | ||
}; // @optional ./css.js | ||
} | ||
; | ||
Cash.prototype.css = css; // @optional ./css.ts | ||
var dataNamespace = '__cashData', | ||
dataAttributeRe = /^data-(.*)/; // @require core/cash.js | ||
// @require ./helpers/variables.js | ||
dataAttributeRe = /^data-(.*)/; // @require core/cash.ts | ||
// @require ./helpers/variables.ts | ||
cash.hasData = function (ele) { | ||
function hasData(ele) { | ||
return dataNamespace in ele; | ||
}; // @require ./variables.js | ||
} | ||
cash.hasData = hasData; // @require ./variables.ts | ||
function getDataCache(ele) { | ||
return ele[dataNamespace] = ele[dataNamespace] || {}; | ||
} // @require attributes/attr.js | ||
// @require ./get_data_cache.js | ||
} // @require attributes/attr.ts | ||
// @require ./get_data_cache.ts | ||
@@ -531,4 +484,4 @@ | ||
return cache; | ||
} // @require ./variables.js | ||
// @require ./get_data_cache.js | ||
} // @require ./variables.ts | ||
// @require ./get_data_cache.ts | ||
@@ -542,3 +495,3 @@ | ||
} | ||
} // @require ./get_data_cache.js | ||
} // @require ./get_data_cache.ts | ||
@@ -548,11 +501,5 @@ | ||
getDataCache(ele)[key] = value; | ||
} // @require core/cash.js | ||
// @require core/type_checking.js | ||
// @require collection/each.js | ||
// @require ./helpers/get_data.js | ||
// @require ./helpers/set_data.js | ||
// @require ./helpers/variables.js | ||
} | ||
fn.data = function (name, value) { | ||
function data(name, value) { | ||
var _this = this; | ||
@@ -562,3 +509,3 @@ | ||
if (!this[0]) return; | ||
each(this[0].attributes, function (attr) { | ||
each(this[0].attributes, function (i, attr) { | ||
var match = attr.name.match(dataAttributeRe); | ||
@@ -584,14 +531,13 @@ if (!match) return; | ||
return this; | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
// @require ./helpers/remove_data.js | ||
} | ||
Cash.prototype.data = data; | ||
fn.removeData = function (key) { | ||
Cash.prototype.removeData = function (key) { | ||
return this.each(function (i, ele) { | ||
return removeData(ele, key); | ||
}); | ||
}; // @optional ./data.js | ||
// @optional ./remove_data.js | ||
// @require css/helpers/compute_style_int.js | ||
}; // @optional ./data.ts | ||
// @optional ./remove_data.ts | ||
// @require css/helpers/compute_style_int.ts | ||
@@ -601,9 +547,6 @@ | ||
return computeStyleInt(ele, "border" + (xAxis ? 'Left' : 'Top') + "Width") + computeStyleInt(ele, "padding" + (xAxis ? 'Left' : 'Top')) + computeStyleInt(ele, "padding" + (xAxis ? 'Right' : 'Bottom')) + computeStyleInt(ele, "border" + (xAxis ? 'Right' : 'Bottom') + "Width"); | ||
} // @require core/cash.js | ||
// @require core/each.js | ||
// @require core/variables.js | ||
} | ||
each(['Width', 'Height'], function (prop) { | ||
fn["inner" + prop] = function () { | ||
each(['Width', 'Height'], function (i, prop) { | ||
Cash.prototype["inner" + prop] = function () { | ||
if (!this[0]) return; | ||
@@ -613,12 +556,5 @@ if (this[0] === win) return win["inner" + prop]; | ||
}; | ||
}); // @require core/camel_case.js | ||
// @require core/cash.js | ||
// @require core/each.js | ||
// @require core/variables.js | ||
// @require css/helpers/compute_style.js | ||
// @require css/helpers/get_suffixed_value.js | ||
// @require ./helpers/get_extra_space.js | ||
each(['width', 'height'], function (prop, index) { | ||
fn[prop] = function (value) { | ||
}); | ||
each(['width', 'height'], function (index, prop) { | ||
Cash.prototype[prop] = function (value) { | ||
if (!this[0]) return value === undefined ? undefined : this; | ||
@@ -631,16 +567,12 @@ | ||
value = parseInt(value, 10); | ||
var valueNumber = parseInt(value, 10); | ||
return this.each(function (i, ele) { | ||
if (ele.nodeType !== 1) return; | ||
var boxSizing = computeStyle(ele, 'boxSizing'); | ||
ele.style[prop] = getSuffixedValue(prop, value + (boxSizing === 'border-box' ? getExtraSpace(ele, !index) : 0)); | ||
ele.style[prop] = getSuffixedValue(prop, valueNumber + (boxSizing === 'border-box' ? getExtraSpace(ele, !index) : 0)); | ||
}); | ||
}; | ||
}); // @require core/cash.js | ||
// @require core/each.js | ||
// @require core/variables.js | ||
// @require css/helpers/compute_style_int.js | ||
each(['Width', 'Height'], function (prop, index) { | ||
fn["outer" + prop] = function (includeMargins) { | ||
}); | ||
each(['Width', 'Height'], function (index, prop) { | ||
Cash.prototype["outer" + prop] = function (includeMargins) { | ||
if (!this[0]) return; | ||
@@ -650,40 +582,28 @@ if (this[0] === win) return win["outer" + prop]; | ||
}; | ||
}); // @optional ./inner.js | ||
// @optional ./normal.js | ||
// @optional ./outer.js | ||
}); // @optional ./inner.ts | ||
// @optional ./normal.ts | ||
// @optional ./outer.ts | ||
function hasNamespaces(ns1, ns2) { | ||
for (var i = 0, l = ns2.length; i < l; i++) { | ||
if (ns1.indexOf(ns2[i]) < 0) return false; | ||
} | ||
return true; | ||
} // @require core/each.js | ||
function removeEventListeners(cache, ele, name) { | ||
each(cache[name], function (_ref) { | ||
var namespaces = _ref[0], | ||
callback = _ref[1]; | ||
ele.removeEventListener(name, callback); | ||
return !ns2 || !some.call(ns2, function (ns) { | ||
return ns1.indexOf(ns) < 0; | ||
}); | ||
delete cache[name]; | ||
} | ||
var eventsNamespace = '__cashEvents', | ||
eventsNamespacesSeparator = '.'; // @require ./variables.js | ||
eventsNamespacesSeparator = '.'; // @require ./variables.ts | ||
function getEventsCache(ele) { | ||
return ele[eventsNamespace] = ele[eventsNamespace] || {}; | ||
} // @require core/guid.js | ||
// @require events/helpers/get_events_cache.js | ||
} // @require core/guid.ts | ||
// @require events/helpers/get_events_cache.ts | ||
function addEvent(ele, name, namespaces, callback) { | ||
callback.guid = callback.guid || guid++; | ||
callback['guid'] = callback['guid'] || guid++; | ||
var eventCache = getEventsCache(ele); | ||
eventCache[name] = eventCache[name] || []; | ||
eventCache[name].push([namespaces, callback]); | ||
ele.addEventListener(name, callback); | ||
} // @require ./variables.js | ||
ele.addEventListener(name, callback); //TSC | ||
} // @require ./variables.ts | ||
@@ -693,8 +613,6 @@ | ||
var parts = eventName.split(eventsNamespacesSeparator); | ||
return [parts[0], parts.slice(1).sort()]; // [name, namespaces] | ||
} // @require core/guid.js | ||
// @require ./get_events_cache.js | ||
// @require ./has_namespaces.js | ||
// @require ./parse_event_name.js | ||
// @require ./remove_event_listeners.js | ||
return [parts[0], parts.slice(1).sort()]; // [name, namespace[]] | ||
} // @require ./get_events_cache.ts | ||
// @require ./has_namespaces.ts | ||
// @require ./parse_event_name.ts | ||
@@ -706,32 +624,20 @@ | ||
if (!name) { | ||
if (!namespaces || !namespaces.length) { | ||
for (name in cache) { | ||
removeEventListeners(cache, ele, name); | ||
} | ||
} else { | ||
for (name in cache) { | ||
removeEvent(ele, name, namespaces, callback); | ||
} | ||
for (name in cache) { | ||
removeEvent(ele, name, namespaces, callback); | ||
} | ||
} else { | ||
var eventCache = cache[name]; | ||
if (!eventCache) return; | ||
if (callback) callback.guid = callback.guid || guid++; | ||
cache[name] = eventCache.filter(function (_ref2) { | ||
var ns = _ref2[0], | ||
cb = _ref2[1]; | ||
if (callback && cb.guid !== callback.guid || !hasNamespaces(ns, namespaces)) return true; | ||
delete ele[eventsNamespace]; | ||
} else if (cache[name]) { | ||
cache[name] = cache[name].filter(function (_a) { | ||
var ns = _a[0], | ||
cb = _a[1]; | ||
if (callback && cb['guid'] !== callback['guid'] || !hasNamespaces(ns, namespaces)) return true; | ||
ele.removeEventListener(name, cb); | ||
}); | ||
} | ||
} // @require core/cash.js | ||
// @require core/each.js | ||
// @require collection/each.js | ||
// @require ./helpers/parse_event_name.js | ||
// @require ./helpers/remove_event.js | ||
} | ||
Cash.prototype.off = function (eventFullName, callback) { | ||
var _this = this; | ||
fn.off = function (eventFullName, callback) { | ||
var _this2 = this; | ||
if (eventFullName === undefined) { | ||
@@ -742,8 +648,8 @@ this.each(function (i, ele) { | ||
} else { | ||
each(getSplitValues(eventFullName), function (eventFullName) { | ||
var _parseEventName = parseEventName(eventFullName), | ||
name = _parseEventName[0], | ||
namespaces = _parseEventName[1]; | ||
each(getSplitValues(eventFullName), function (i, eventFullName) { | ||
var _a = parseEventName(eventFullName), | ||
name = _a[0], | ||
namespaces = _a[1]; | ||
_this2.each(function (i, ele) { | ||
_this.each(function (i, ele) { | ||
return removeEvent(ele, name, namespaces, callback); | ||
@@ -755,18 +661,7 @@ }); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/get_split_values.js | ||
// @require core/guid.js | ||
// @require core/matches.js | ||
// @require core/type_checking.js | ||
// @require collection/each.js | ||
// @require ./helpers/variables.js | ||
// @require ./helpers/add_event.js | ||
// @require ./helpers/has_namespaces.js | ||
// @require ./helpers/parse_event_name.js | ||
// @require ./helpers/remove_event.js | ||
}; | ||
function on(eventFullName, selector, callback, _one) { | ||
var _this = this; | ||
fn.on = function (eventFullName, selector, callback, _one) { | ||
var _this3 = this; | ||
if (!isString(eventFullName)) { | ||
@@ -782,11 +677,11 @@ for (var key in eventFullName) { | ||
callback = selector; | ||
selector = false; | ||
selector = ''; | ||
} | ||
each(getSplitValues(eventFullName), function (eventFullName) { | ||
var _parseEventName2 = parseEventName(eventFullName), | ||
name = _parseEventName2[0], | ||
namespaces = _parseEventName2[1]; | ||
each(getSplitValues(eventFullName), function (i, eventFullName) { | ||
var _a = parseEventName(eventFullName), | ||
name = _a[0], | ||
namespaces = _a[1]; | ||
_this3.each(function (i, ele) { | ||
_this.each(function (i, ele) { | ||
var finalCallback = function finalCallback(event) { | ||
@@ -800,2 +695,3 @@ if (event.namespace && !hasNamespaces(namespaces, event.namespace.split(eventsNamespacesSeparator))) return; | ||
while (!matches(target, selector)) { | ||
//TSC | ||
if (target === ele) return; | ||
@@ -810,3 +706,3 @@ target = target.parentNode; | ||
event.namespace = event.namespace || ''; | ||
var returnValue = callback.call(thisArg, event, event.data); | ||
var returnValue = callback.call(thisArg, event, event.data); //TSC | ||
@@ -823,3 +719,3 @@ if (_one) { | ||
finalCallback.guid = callback.guid = callback.guid || guid++; | ||
finalCallback['guid'] = callback['guid'] = callback['guid'] || guid++; | ||
addEvent(ele, name, namespaces, finalCallback); | ||
@@ -829,13 +725,14 @@ }); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require ./on.js | ||
} | ||
Cash.prototype.on = on; | ||
fn.one = function (eventFullName, delegate, callback) { | ||
return this.on(eventFullName, delegate, callback, true); | ||
}; // @require core/cash.js | ||
// @require core/variables.js | ||
function one(eventFullName, selector, callback) { | ||
return this.on(eventFullName, selector, callback, true); //TSC | ||
} | ||
; | ||
Cash.prototype.one = one; | ||
fn.ready = function (callback) { | ||
Cash.prototype.ready = function (callback) { | ||
var finalCallback = function finalCallback() { | ||
@@ -852,59 +749,35 @@ return callback(cash); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/type_checking.js | ||
// @require core/variables.js | ||
// @require collection/each.js | ||
// @require ./helpers/parse_event_name.js | ||
// @require ./helpers/variables.js | ||
}; | ||
fn.trigger = function (eventFullName, data) { | ||
Cash.prototype.trigger = function (eventFullName, data) { | ||
var evt = eventFullName; | ||
if (isString(eventFullName)) { | ||
var _parseEventName3 = parseEventName(eventFullName), | ||
name = _parseEventName3[0], | ||
namespaces = _parseEventName3[1]; | ||
var _a = parseEventName(eventFullName), | ||
name_1 = _a[0], | ||
namespaces = _a[1]; | ||
evt = doc.createEvent('HTMLEvents'); | ||
evt.initEvent(name, true, true); | ||
evt.namespace = namespaces.join(eventsNamespacesSeparator); | ||
evt.initEvent(name_1, true, true); | ||
evt['namespace'] = namespaces.join(eventsNamespacesSeparator); | ||
} | ||
evt.data = data; | ||
evt['data'] = data; | ||
return this.each(function (i, ele) { | ||
ele.dispatchEvent(evt); | ||
}); | ||
}; // @optional ./off.js | ||
// @optional ./on.js | ||
// @optional ./one.js | ||
// @optional ./ready.js | ||
// @optional ./trigger.js | ||
// @require core/each.js | ||
}; // @optional ./off.ts | ||
// @optional ./on.ts | ||
// @optional ./one.ts | ||
// @optional ./ready.ts | ||
// @optional ./trigger.ts | ||
// @require core/pluck.ts | ||
// @require core/variables.ts | ||
function getValueSelectMultiple(ele) { | ||
var values = []; | ||
each(ele.options, function (option) { | ||
if (option.selected && !option.disabled && !option.parentNode.disabled) { | ||
values.push(option.value); | ||
} | ||
}); | ||
return values; | ||
} | ||
function getValueSelectSingle(ele) { | ||
return ele.selectedIndex < 0 ? null : ele.options[ele.selectedIndex].value; | ||
} // @require ./get_value_select_single.js | ||
// @require ./get_value_select_multiple.js | ||
var selectOneRe = /select-one/i, | ||
selectMultipleRe = /select-multiple/i; | ||
function getValue(ele) { | ||
var type = ele.type; | ||
if (selectOneRe.test(type)) return getValueSelectSingle(ele); | ||
if (selectMultipleRe.test(type)) return getValueSelectMultiple(ele); | ||
return ele.value; | ||
if (ele.multiple) return pluck(filter.call(ele.options, function (option) { | ||
return option.selected && !option.disabled && !option.parentNode.disabled; | ||
}), 'value'); | ||
return ele.value || ''; | ||
} | ||
@@ -916,7 +789,7 @@ | ||
return "&" + encodeURIComponent(prop) + "=" + encodeURIComponent(value).replace(queryEncodeSpaceRe, '+'); | ||
} // @require core/cash.js | ||
// @require core/each.js | ||
// @require core/type_checking.js | ||
// @require ./helpers/get_value.js | ||
// @require ./helpers/query_encode.js | ||
} // @require core/cash.ts | ||
// @require core/each.ts | ||
// @require core/type_checking.ts | ||
// @require ./helpers/get_value.ts | ||
// @require ./helpers/query_encode.ts | ||
@@ -927,13 +800,11 @@ | ||
fn.serialize = function () { | ||
Cash.prototype.serialize = function () { | ||
var query = ''; | ||
this.each(function (i, ele) { | ||
each(ele.elements || [ele], function (ele) { | ||
if (ele.disabled || !ele.name || ele.tagName === 'FIELDSET') return; | ||
if (skippableRe.test(ele.type)) return; | ||
if (checkableRe.test(ele.type) && !ele.checked) return; | ||
each(ele.elements || [ele], function (i, ele) { | ||
if (ele.disabled || !ele.name || ele.tagName === 'FIELDSET' || skippableRe.test(ele.type) || checkableRe.test(ele.type) && !ele.checked) return; | ||
var value = getValue(ele); | ||
if (value === undefined) return; | ||
var values = isArray(value) ? value : [value]; | ||
each(values, function (value) { | ||
each(values, function (i, value) { | ||
query += queryEncode(ele.name, value); | ||
@@ -944,17 +815,12 @@ }); | ||
return query.substr(1); | ||
}; // @require core/cash.js | ||
// @require core/each.js | ||
// @require core/type_checking.js | ||
// @require collection/each.js | ||
// @require ./helpers/get_value.js | ||
}; | ||
fn.val = function (value) { | ||
function val(value) { | ||
if (value === undefined) return this[0] && getValue(this[0]); | ||
return this.each(function (i, ele) { | ||
var isMultiple = selectMultipleRe.test(ele.type), | ||
var isMultiple = ele.multiple, | ||
eleValue = value === null ? isMultiple ? [] : '' : value; | ||
if (isMultiple && isArray(eleValue)) { | ||
each(ele.options, function (option) { | ||
each(ele.options, function (i, option) { | ||
option.selected = eleValue.indexOf(option.value) >= 0; | ||
@@ -966,17 +832,13 @@ }); | ||
}); | ||
}; // @optional ./serialize.js | ||
// @optional ./val.js | ||
// @require core/cash.js | ||
// @require collection/map.js | ||
} | ||
Cash.prototype.val = val; | ||
fn.clone = function () { | ||
Cash.prototype.clone = function () { | ||
return this.map(function (i, ele) { | ||
return ele.cloneNode(true); | ||
}); | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
}; | ||
fn.detach = function () { | ||
Cash.prototype.detach = function () { | ||
return this.each(function (i, ele) { | ||
@@ -987,7 +849,7 @@ if (ele.parentNode) { | ||
}); | ||
}; // @require ./cash.js | ||
// @require ./variables.js | ||
// @require ./type_checking.js | ||
// @require collection/get.js | ||
// @require manipulation/detach.js | ||
}; // @require ./cash.ts | ||
// @require ./variables.ts | ||
// @require ./type_checking.ts | ||
// @require collection/get.ts | ||
// @require manipulation/detach.ts | ||
@@ -1004,3 +866,3 @@ | ||
containers = { | ||
'*': doc.createElement('div'), | ||
'*': div, | ||
tr: doc.createElement('tbody'), | ||
@@ -1025,19 +887,5 @@ td: tr, | ||
cash.parseHTML = parseHTML; // @optional ./camel_case.js | ||
// @optional ./each.js | ||
// @optional ./export.js | ||
// @optional ./extend.js | ||
// @optional ./find.js | ||
// @optional ./get_compare_function.js | ||
// @optional ./get_split_values.js | ||
// @optional ./guid.js | ||
// @optional ./matches.js | ||
// @optional ./parse_html.js | ||
// @optional ./unique.js | ||
// @optional ./variables.js | ||
// @require ./cash.js | ||
// @require ./type_checking.js | ||
// @require core/cash.js | ||
cash.parseHTML = parseHTML; | ||
fn.empty = function () { | ||
Cash.prototype.empty = function () { | ||
var ele = this[0]; | ||
@@ -1060,198 +908,143 @@ | ||
} | ||
} // @require core/each.js | ||
// @require core/type_checking.js | ||
// @require ./insert_element.js | ||
} // @require core/each.ts | ||
// @require core/type_checking.ts | ||
// @require ./insert_element.ts | ||
function insertContent(parent, child, prepend) { | ||
if (child === undefined) return; | ||
var isStr = isString(child); | ||
if (!isStr && child.length) { | ||
each(child, function (ele) { | ||
return insertContent(parent, ele, prepend); | ||
each(parent, function (index, parentEle) { | ||
each(child, function (i, childEle) { | ||
insertElement(parentEle, !index ? childEle : childEle.cloneNode(true), prepend); | ||
}); | ||
} else { | ||
each(parent, isStr ? function (ele) { | ||
ele.insertAdjacentHTML(prepend ? 'afterbegin' : 'beforeend', child); | ||
} : function (ele, index) { | ||
return insertElement(ele, !index ? child : child.cloneNode(true), prepend); | ||
}); | ||
} | ||
} // @require core/cash.js | ||
// @require core/each.js | ||
// @require ./helpers/insert_content.js | ||
}); | ||
} | ||
Cash.prototype.append = function () { | ||
var _this = this; | ||
fn.append = function () { | ||
var _this4 = this; | ||
each(arguments, function (content) { | ||
insertContent(_this4, content); | ||
each(arguments, function (i, selector) { | ||
insertContent(_this, cash(selector)); | ||
}); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require ./helpers/insert_content.js | ||
}; | ||
fn.appendTo = function (parent) { | ||
insertContent(cash(parent), this); | ||
Cash.prototype.appendTo = function (selector) { | ||
insertContent(cash(selector), this); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
}; | ||
fn.html = function (content) { | ||
if (content === undefined) return this[0] && this[0].innerHTML; | ||
var source = content.nodeType ? content[0].outerHTML : content; | ||
function html(html) { | ||
if (html === undefined) return this[0] && this[0].innerHTML; | ||
return this.each(function (i, ele) { | ||
ele.innerHTML = source; | ||
ele.innerHTML = html; | ||
}); | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
} | ||
Cash.prototype.html = html; | ||
fn.insertAfter = function (content) { | ||
var _this5 = this; | ||
Cash.prototype.insertAfter = function (selector) { | ||
var _this = this; | ||
cash(content).each(function (index, ele) { | ||
cash(selector).each(function (index, ele) { | ||
var parent = ele.parentNode; | ||
_this5.each(function (i, e) { | ||
parent.insertBefore(!index ? e : e.cloneNode(true), ele.nextSibling); | ||
}); | ||
if (parent) { | ||
_this.each(function (i, e) { | ||
parent.insertBefore(!index ? e : e.cloneNode(true), ele.nextSibling); | ||
}); | ||
} | ||
}); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/each.js | ||
// @require core/variables.js | ||
// @require collection/slice.js | ||
// @require ./insert_after.js | ||
}; | ||
Cash.prototype.after = function () { | ||
var _this = this; | ||
fn.after = function () { | ||
var _this6 = this; | ||
each(reverse.apply(arguments), function (content) { | ||
reverse.apply(cash(content).slice()).insertAfter(_this6); | ||
each(reverse.apply(arguments), function (i, selector) { | ||
reverse.apply(cash(selector).slice()).insertAfter(_this); | ||
}); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
}; | ||
Cash.prototype.insertBefore = function (selector) { | ||
var _this = this; | ||
fn.insertBefore = function (selector) { | ||
var _this7 = this; | ||
cash(selector).each(function (index, ele) { | ||
var parent = ele.parentNode; | ||
_this7.each(function (i, e) { | ||
parent.insertBefore(!index ? e : e.cloneNode(true), ele); | ||
}); | ||
if (parent) { | ||
_this.each(function (i, e) { | ||
parent.insertBefore(!index ? e : e.cloneNode(true), ele); | ||
}); | ||
} | ||
}); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/each.js | ||
// @require ./insert_before.js | ||
}; | ||
Cash.prototype.before = function () { | ||
var _this = this; | ||
fn.before = function () { | ||
var _this8 = this; | ||
each(arguments, function (content) { | ||
cash(content).insertBefore(_this8); | ||
each(arguments, function (i, selector) { | ||
cash(selector).insertBefore(_this); | ||
}); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/each.js | ||
// @require ./helpers/insert_content.js | ||
}; | ||
Cash.prototype.prepend = function () { | ||
var _this = this; | ||
fn.prepend = function () { | ||
var _this9 = this; | ||
each(arguments, function (content) { | ||
insertContent(_this9, content, true); | ||
each(arguments, function (i, selector) { | ||
insertContent(_this, cash(selector), true); | ||
}); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require core/variables.js | ||
// @require collection/slice.js | ||
// @require ./helpers/insert_content.js | ||
}; | ||
fn.prependTo = function (parent) { | ||
insertContent(cash(parent), reverse.apply(this.slice()), true); | ||
Cash.prototype.prependTo = function (selector) { | ||
insertContent(cash(selector), reverse.apply(this.slice()), true); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require events/off.js | ||
// @require ./detach.js | ||
}; | ||
fn.remove = function () { | ||
Cash.prototype.remove = function () { | ||
return this.detach().off(); | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
// @require collection/slice.js | ||
// @require ./after.js | ||
// @require ./remove.js | ||
}; | ||
Cash.prototype.replaceWith = function (selector) { | ||
return this.before(selector).remove(); | ||
}; | ||
fn.replaceWith = function (content) { | ||
var _this10 = this; | ||
return this.each(function (i, ele) { | ||
var parent = ele.parentNode; | ||
if (!parent) return; | ||
var $eles = i ? cash(content).clone() : cash(content); | ||
if (!$eles[0]) { | ||
_this10.remove(); | ||
return false; | ||
} | ||
parent.replaceChild($eles[0], ele); | ||
cash($eles[0]).after($eles.slice(1)); | ||
}); | ||
}; // @require core/cash.js | ||
// @require ./replace_with.js | ||
fn.replaceAll = function (content) { | ||
cash(content).replaceWith(this); | ||
Cash.prototype.replaceAll = function (selector) { | ||
cash(selector).replaceWith(this); | ||
return this; | ||
}; // @require core/cash.js | ||
// @require collection/each.js | ||
}; | ||
fn.text = function (content) { | ||
if (content === undefined) return this[0] ? this[0].textContent : ''; | ||
function text(text) { | ||
if (text === undefined) return this[0] ? this[0].textContent : ''; | ||
return this.each(function (i, ele) { | ||
ele.textContent = content; | ||
ele.textContent = text; | ||
}); | ||
}; // @optional ./after.js | ||
// @optional ./append.js | ||
// @optional ./append_to.js | ||
// @optional ./before.js | ||
// @optional ./clone.js | ||
// @optional ./detach.js | ||
// @optional ./empty.js | ||
// @optional ./html.js | ||
// @optional ./insert_after.js | ||
// @optional ./insert_before.js | ||
// @optional ./prepend.js | ||
// @optional ./prepend_to.js | ||
// @optional ./remove.js | ||
// @optional ./replace_all.js | ||
// @optional ./replace_with.js | ||
// @optional ./text.js | ||
// @require core/cash.js | ||
// @require core/variables.js | ||
} | ||
; | ||
Cash.prototype.text = text; // @optional ./after.ts | ||
// @optional ./append.ts | ||
// @optional ./append_to.ts | ||
// @optional ./before.ts | ||
// @optional ./clone.ts | ||
// @optional ./detach.ts | ||
// @optional ./empty.ts | ||
// @optional ./html.ts | ||
// @optional ./insert_after.ts | ||
// @optional ./insert_before.ts | ||
// @optional ./prepend.ts | ||
// @optional ./prepend_to.ts | ||
// @optional ./remove.ts | ||
// @optional ./replace_all.ts | ||
// @optional ./replace_with.ts | ||
// @optional ./text.ts | ||
// @require core/cash.ts | ||
// @require core/variables.ts | ||
var docEle = doc.documentElement; | ||
fn.offset = function () { | ||
Cash.prototype.offset = function () { | ||
var ele = this[0]; | ||
@@ -1264,11 +1057,9 @@ if (!ele) return; | ||
}; | ||
}; // @require core/cash.js | ||
}; | ||
fn.offsetParent = function () { | ||
Cash.prototype.offsetParent = function () { | ||
return cash(this[0] && this[0].offsetParent); | ||
}; // @require core/cash.js | ||
}; | ||
fn.position = function () { | ||
Cash.prototype.position = function () { | ||
var ele = this[0]; | ||
@@ -1280,13 +1071,5 @@ if (!ele) return; | ||
}; | ||
}; // @optional ./offset.js | ||
// @optional ./offset_parent.js | ||
// @optional ./position.js | ||
// @require core/cash.js | ||
// @require core/matches.js | ||
// @require core/unique.js | ||
// @require collection/each.js | ||
// @require collection/filter.js | ||
}; | ||
fn.children = function (selector) { | ||
Cash.prototype.children = function (selector) { | ||
var result = []; | ||
@@ -1298,11 +1081,6 @@ this.each(function (i, ele) { | ||
if (!selector) return result; | ||
return result.filter(function (i, ele) { | ||
return matches(ele, selector); | ||
}); | ||
}; // @require core/cash.js | ||
// @require core/unique.js | ||
// @require collection/each.js | ||
return result.filter(selector); | ||
}; | ||
fn.contents = function () { | ||
Cash.prototype.contents = function () { | ||
var result = []; | ||
@@ -1312,10 +1090,6 @@ this.each(function (i, ele) { | ||
}); | ||
return cash(result.length && unique(result)); | ||
}; // @require core/cash.js | ||
// @require core/unique.js | ||
// @require core/find.js | ||
// @require core/variables.js | ||
return cash(unique(result)); | ||
}; | ||
fn.find = function (selector) { | ||
Cash.prototype.find = function (selector) { | ||
var result = []; | ||
@@ -1331,10 +1105,6 @@ | ||
return cash(result.length && unique(result)); | ||
}; // @require core/cash.js | ||
// @require core/find.js | ||
// @require core/type_checking.js | ||
// @require collection/filter.js | ||
return cash(unique(result)); | ||
}; | ||
fn.has = function (selector) { | ||
Cash.prototype.has = function (selector) { | ||
var comparator = isString(selector) ? function (i, ele) { | ||
@@ -1346,85 +1116,44 @@ return !!find(selector, ele).length; | ||
return this.filter(comparator); | ||
}; // @require core/cash.js | ||
// @require core/get_compare_function.js | ||
// @require collection/each.js | ||
}; | ||
fn.is = function (selector) { | ||
if (!selector || !this[0]) return false; | ||
var comparator = getCompareFunction(selector); | ||
Cash.prototype.is = function (comparator) { | ||
if (!comparator || !this[0]) return false; | ||
var compare = getCompareFunction(comparator); | ||
var check = false; | ||
this.each(function (i, ele) { | ||
check = comparator(i, ele, selector); | ||
check = compare.call(ele, i, ele); | ||
return !check; | ||
}); | ||
return check; | ||
}; // @require core/cash.js | ||
}; | ||
Cash.prototype.next = function () { | ||
return cash(unique(pluck(this, 'nextElementSibling'))); | ||
}; | ||
fn.next = function () { | ||
return cash(this[0] && this[0].nextElementSibling); | ||
}; // @require core/cash.js | ||
// @require core/get_compare_function.js | ||
// @require collection/filter.js | ||
fn.not = function (selector) { | ||
if (!selector || !this[0]) return this; | ||
var comparator = getCompareFunction(selector); | ||
Cash.prototype.not = function (comparator) { | ||
if (!comparator || !this[0]) return this; | ||
var compare = getCompareFunction(comparator); | ||
return this.filter(function (i, ele) { | ||
return !comparator(i, ele, selector); | ||
return !compare.call(ele, i, ele); | ||
}); | ||
}; // @require core/cash.js | ||
// @require core/unique.js | ||
// @require collection/each.js | ||
}; | ||
Cash.prototype.parent = function () { | ||
return cash(unique(pluck(this, 'parentNode'))); | ||
}; | ||
fn.parent = function () { | ||
var result = []; | ||
this.each(function (i, ele) { | ||
if (ele && ele.parentNode) { | ||
result.push(ele.parentNode); | ||
} | ||
}); | ||
return cash(unique(result)); | ||
}; // @require core/cash.js | ||
// @require core/variables.js | ||
// @require traversal/children.js | ||
// @require traversal/parent.js | ||
// @require ./get.js | ||
//FIXME Ugly file name, is there a better option? | ||
fn.index = function (ele) { | ||
var child = ele ? cash(ele)[0] : this[0], | ||
collection = ele ? this : cash(child).parent().children(); | ||
Cash.prototype.index = function (selector) { | ||
var child = selector ? cash(selector)[0] : this[0], | ||
collection = selector ? this : cash(child).parent().children(); | ||
return indexOf.call(collection, child); | ||
}; // @optional ./add.js | ||
// @optional ./each.js | ||
// @optional ./eq.js | ||
// @optional ./filter.js | ||
// @optional ./first.js | ||
// @optional ./get.js | ||
// @optional ./indexFn.js | ||
// @optional ./last.js | ||
// @optional ./map.js | ||
// @optional ./slice.js | ||
// @require core/cash.js | ||
// @require collection/filter.js | ||
// @require ./is.js | ||
// @require ./parent.js | ||
}; | ||
fn.closest = function (selector) { | ||
Cash.prototype.closest = function (selector) { | ||
if (!selector || !this[0]) return cash(); | ||
if (this.is(selector)) return this.filter(selector); | ||
return this.parent().closest(selector); | ||
}; // @require core/cash.js | ||
// @require core/matches.js | ||
// @require core/unique.js | ||
// @require core/variables.js | ||
// @require collection/each.js | ||
}; | ||
fn.parents = function (selector) { | ||
Cash.prototype.parents = function (selector) { | ||
var result = []; | ||
@@ -1444,14 +1173,9 @@ var last; | ||
return cash(unique(result)); | ||
}; // @require core/cash.js | ||
}; | ||
Cash.prototype.prev = function () { | ||
return cash(unique(pluck(this, 'previousElementSibling'))); | ||
}; | ||
fn.prev = function () { | ||
return cash(this[0] && this[0].previousElementSibling); | ||
}; // @require core/cash.js | ||
// @require collection/filter.js | ||
// @require ./children.js | ||
// @require ./parent.js | ||
fn.siblings = function () { | ||
Cash.prototype.siblings = function () { | ||
var ele = this[0]; | ||
@@ -1461,25 +1185,37 @@ return this.parent().children().filter(function (i, child) { | ||
}); | ||
}; // @optional ./children.js | ||
// @optional ./closest.js | ||
// @optional ./contents.js | ||
// @optional ./find.js | ||
// @optional ./has.js | ||
// @optional ./is.js | ||
// @optional ./next.js | ||
// @optional ./not.js | ||
// @optional ./parent.js | ||
// @optional ./parents.js | ||
// @optional ./prev.js | ||
// @optional ./siblings.js | ||
// @optional attributes/index.js | ||
// @optional collection/index.js | ||
// @optional css/index.js | ||
// @optional data/index.js | ||
// @optional dimensions/index.js | ||
// @optional events/index.js | ||
// @optional forms/index.js | ||
// @optional manipulation/index.js | ||
// @optional offset/index.js | ||
// @optional traversal/index.js | ||
// @require core/index.js | ||
}; // @optional ./children.ts | ||
// @optional ./closest.ts | ||
// @optional ./contents.ts | ||
// @optional ./find.ts | ||
// @optional ./has.ts | ||
// @optional ./is.ts | ||
// @optional ./next.ts | ||
// @optional ./not.ts | ||
// @optional ./parent.ts | ||
// @optional ./parents.ts | ||
// @optional ./prev.ts | ||
// @optional ./siblings.ts | ||
// @optional attributes/index.ts | ||
// @optional collection/index.ts | ||
// @optional css/index.ts | ||
// @optional data/index.ts | ||
// @optional dimensions/index.ts | ||
// @optional events/index.ts | ||
// @optional forms/index.ts | ||
// @optional manipulation/index.ts | ||
// @optional offset/index.ts | ||
// @optional traversal/index.ts | ||
// @require core/index.ts | ||
// @priority -100 | ||
// @require ./cash.ts | ||
// @require ./variables.ts | ||
if (typeof exports !== 'undefined') { | ||
// Node.js | ||
module.exports = cash; | ||
} else { | ||
// Browser | ||
win['cash'] = win['$'] = cash; | ||
} | ||
})(); |
/* MIT https://github.com/kenwheeler/cash */ | ||
(function(){ | ||
'use strict';var e=document,g=window,h=Array.prototype,l=h.filter,aa=h.indexOf,ba=h.map,m=h.push,n=h.reverse,q=h.slice,ca=/^#[\w-]*$/,da=/^\.[\w-]*$/,ea=/<.+>/,fa=/^\w+$/;function r(a,b){void 0===b&&(b=e);return da.test(a)?b.getElementsByClassName(a.slice(1)):fa.test(a)?b.getElementsByTagName(a):b.querySelectorAll(a)} | ||
function t(a,b){void 0===b&&(b=e);if(a){if(a.__cash)return a;var c=a;if(u(a)){if(b.__cash&&(b=b[0]),c=ca.test(a)?b.getElementById(a.slice(1)):ea.test(a)?v(a):r(a,b),!c)return}else if(w(a))return this.ready(a);if(c.nodeType||c===g)c=[c];this.length=c.length;a=0;for(b=this.length;a<b;a++)this[a]=c[a]}}function x(a,b){return new t(a,b)}var y=x.fn=x.prototype=t.prototype={constructor:x,__cash:!0,length:0,splice:h.splice};y.get=function(a){return void 0===a?q.call(this):this[0>a?a+this.length:a]}; | ||
y.eq=function(a){return x(this.get(a))};y.first=function(){return this.eq(0)};y.last=function(){return this.eq(-1)};y.map=function(a){return x(ba.call(this,function(b,c){return a.call(b,c,b)}))};y.slice=function(){return x(q.apply(this,arguments))};var ha=/(?:^\w|[A-Z]|\b\w)/g,ia=/[\s-_]+/g;function z(a){return a.replace(ha,function(a,c){return a[c?"toUpperCase":"toLowerCase"]()}).replace(ia,"")}x.camelCase=z;function A(a,b){for(var c=0,d=a.length;c<d&&!1!==b.call(a[c],a[c],c,a);c++);}x.each=A; | ||
y.each=function(a){A(this,function(b,c){return a.call(b,c,b)});return this};y.removeProp=function(a){return this.each(function(b,c){delete c[a]})};"undefined"!==typeof exports?module.exports=x:g.cash=g.$=x;x.extend=y.extend=function(a){void 0===a&&(a=this);for(var b=arguments,c=b.length,d=2>c?0:1;d<c;d++)for(var f in b[d])a[f]=b[d][f];return a};var B=1;x.guid=B; | ||
function C(a,b){var c=a&&(a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.msMatchesSelector||a.oMatchesSelector);return!!c&&c.call(a,b)}x.matches=C;function w(a){return"function"===typeof a}x.isFunction=w;function u(a){return"string"===typeof a}x.isString=u;function D(a){return!isNaN(parseFloat(a))&&isFinite(a)}x.isNumeric=D;var E=Array.isArray;x.isArray=E; | ||
y.prop=function(a,b){if(a){if(u(a))return 2>arguments.length?this[0]&&this[0][a]:this.each(function(c,f){f[a]=b});for(var c in a)this.prop(c,a[c]);return this}};function F(a){return u(a)?function(b,c){return C(c,a)}:a.__cash?function(b,c){return a.is(c)}:function(a,c,d){return c===d}}y.filter=function(a){if(!a)return x();var b=w(a)?a:F(a);return x(l.call(this,function(c,d){return b.call(c,d,c,a)}))};var ja=/\S+/g;function G(a){return u(a)?a.match(ja)||[]:[]} | ||
y.hasClass=function(a){var b=G(a),c=!1;b.length&&this.each(function(a,f){c=f.classList.contains(b[0]);return!c});return c};y.removeAttr=function(a){var b=G(a);return b.length?this.each(function(a,d){A(b,function(a){d.removeAttribute(a)})}):this};y.attr=function(a,b){if(a){if(u(a)){if(2>arguments.length){if(!this[0])return;var c=this[0].getAttribute(a);return null===c?void 0:c}return null===b?this.removeAttr(a):this.each(function(c,f){f.setAttribute(a,b)})}for(c in a)this.attr(c,a[c]);return this}}; | ||
y.toggleClass=function(a,b){var c=G(a),d=void 0!==b;return c.length?this.each(function(a,k){A(c,function(a){d?b?k.classList.add(a):k.classList.remove(a):k.classList.toggle(a)})}):this};y.addClass=function(a){return this.toggleClass(a,!0)};y.removeClass=function(a){return arguments.length?this.toggleClass(a,!1):this.attr("class","")};function I(a){return a.filter(function(a,c,d){return d.indexOf(a)===c})}x.unique=I;y.add=function(a,b){return x(I(this.get().concat(x(a,b).get())))}; | ||
function J(a,b,c){if(1===a.nodeType)return a=g.getComputedStyle(a,null),b?c?a.getPropertyValue(b):a[b]:a}function K(a,b){return parseInt(J(a,b),10)||0}var L=/^--/,M={},ka=e.createElement("div").style,la=["webkit","moz","ms","o"];function N(a,b){void 0===b&&(b=L.test(a));if(b)return a;if(!M[a]){b=z(a);var c=""+b.charAt(0).toUpperCase()+b.slice(1);b=(b+" "+la.join(c+" ")+c).split(" ");A(b,function(b){if(b in ka)return M[a]=b,!1})}return M[a]}x.prefixedProp=N; | ||
var ma={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function O(a,b,c){void 0===c&&(c=L.test(a));return c||ma[a]||!D(b)?b:b+"px"}y.css=function(a,b){if(u(a)){var c=L.test(a);a=N(a,c);if(2>arguments.length)return this[0]&&J(this[0],a,c);if(!a)return this;b=O(a,b,c);return this.each(function(d,k){1===k.nodeType&&(c?k.style.setProperty(a,b):k.style[a]=b)})}for(var d in a)this.css(d,a[d]);return this}; | ||
var na=/^data-(.*)/;x.hasData=function(a){return"__cashData"in a};function P(a){return a.__cashData=a.__cashData||{}}function Q(a,b){var c=P(a);if(b){if(!(b in c)&&(a=a.dataset?a.dataset[b]||a.dataset[z(b)]:x(a).attr("data-"+b),void 0!==a)){try{a=JSON.parse(a)}catch(d){}c[b]=a}return c[b]}return c} | ||
y.data=function(a,b){var c=this;if(!a){if(!this[0])return;A(this[0].attributes,function(a){(a=a.name.match(na))&&c.data(a[1])});return Q(this[0])}if(u(a))return void 0===b?this[0]&&Q(this[0],a):this.each(function(c,d){P(d)[a]=b});for(var d in a)this.data(d,a[d]);return this};y.removeData=function(a){return this.each(function(b,c){void 0===a?delete c.__cashData:delete P(c)[a]})}; | ||
function R(a,b){return K(a,"border"+(b?"Left":"Top")+"Width")+K(a,"padding"+(b?"Left":"Top"))+K(a,"padding"+(b?"Right":"Bottom"))+K(a,"border"+(b?"Right":"Bottom")+"Width")}A(["Width","Height"],function(a){y["inner"+a]=function(){if(this[0])return this[0]===g?g["inner"+a]:this[0]["client"+a]}}); | ||
A(["width","height"],function(a,b){y[a]=function(c){if(!this[0])return void 0===c?void 0:this;if(!arguments.length)return this[0]===g?this[0][z("outer-"+a)]:this[0].getBoundingClientRect()[a]-R(this[0],!b);c=parseInt(c,10);return this.each(function(d,f){1===f.nodeType&&(d=J(f,"boxSizing"),f.style[a]=O(a,c+("border-box"===d?R(f,!b):0)))})}}); | ||
A(["Width","Height"],function(a,b){y["outer"+a]=function(c){if(this[0])return this[0]===g?g["outer"+a]:this[0]["offset"+a]+(c?K(this[0],"margin"+(b?"Top":"Left"))+K(this[0],"margin"+(b?"Bottom":"Right")):0)}});function S(a,b){for(var c=0,d=b.length;c<d;c++)if(0>a.indexOf(b[c]))return!1;return!0}function oa(a,b,c){A(a[c],function(a){b.removeEventListener(c,a[1])});delete a[c]} | ||
function pa(a,b,c,d){d.guid=d.guid||B++;var f=a.__cashEvents=a.__cashEvents||{};f[b]=f[b]||[];f[b].push([c,d]);a.addEventListener(b,d)}function T(a){a=a.split(".");return[a[0],a.slice(1).sort()]}function U(a,b,c,d){var f=a.__cashEvents=a.__cashEvents||{};if(b){var k=f[b];k&&(d&&(d.guid=d.guid||B++),f[b]=k.filter(function(f){var k=f[0];f=f[1];if(d&&f.guid!==d.guid||!S(k,c))return!0;a.removeEventListener(b,f)}))}else if(c&&c.length)for(b in f)U(a,b,c,d);else for(b in f)oa(f,a,b)} | ||
y.off=function(a,b){var c=this;void 0===a?this.each(function(a,b){return U(b)}):A(G(a),function(a){a=T(a);var d=a[0],k=a[1];c.each(function(a,c){return U(c,d,k,b)})});return this}; | ||
y.on=function(a,b,c,d){var f=this;if(!u(a)){for(var k in a)this.on(k,b,a[k]);return this}w(b)&&(c=b,b=!1);A(G(a),function(a){a=T(a);var k=a[0],H=a[1];f.each(function(a,f){a=function qa(a){if(!a.namespace||S(H,a.namespace.split("."))){var p=f;if(b)for(p=a.target;!C(p,b);){if(p===f)return;p=p.parentNode;if(!p)return}a.namespace=a.namespace||"";p=c.call(p,a,a.data);d&&U(f,k,H,qa);!1===p&&(a.preventDefault(),a.stopPropagation())}};a.guid=c.guid=c.guid||B++;pa(f,k,H,a)})});return this}; | ||
y.one=function(a,b,c){return this.on(a,b,c,!0)};y.ready=function(a){function b(){return a(x)}"loading"!==e.readyState?setTimeout(b):e.addEventListener("DOMContentLoaded",b);return this};y.trigger=function(a,b){var c=a;if(u(a)){var d=T(a);a=d[0];d=d[1];c=e.createEvent("HTMLEvents");c.initEvent(a,!0,!0);c.namespace=d.join(".")}c.data=b;return this.each(function(a,b){b.dispatchEvent(c)})}; | ||
function ra(a){var b=[];A(a.options,function(a){!a.selected||a.disabled||a.parentNode.disabled||b.push(a.value)});return b}var sa=/select-one/i,V=/select-multiple/i;function W(a){var b=a.type;return sa.test(b)?0>a.selectedIndex?null:a.options[a.selectedIndex].value:V.test(b)?ra(a):a.value}var ta=/%20/g,ua=/file|reset|submit|button|image/i,va=/radio|checkbox/i; | ||
y.serialize=function(){var a="";this.each(function(b,c){A(c.elements||[c],function(b){if(!b.disabled&&b.name&&"FIELDSET"!==b.tagName&&!ua.test(b.type)&&(!va.test(b.type)||b.checked)){var c=W(b);void 0!==c&&(c=E(c)?c:[c],A(c,function(c){var d=a;c="&"+encodeURIComponent(b.name)+"="+encodeURIComponent(c).replace(ta,"+");a=d+c}))}})});return a.substr(1)}; | ||
y.val=function(a){return void 0===a?this[0]&&W(this[0]):this.each(function(b,c){b=V.test(c.type);var d=null===a?b?[]:"":a;b&&E(d)?A(c.options,function(a){a.selected=0<=d.indexOf(a.value)}):c.value=d})};y.clone=function(){return this.map(function(a,b){return b.cloneNode(!0)})};y.detach=function(){return this.each(function(a,b){b.parentNode&&b.parentNode.removeChild(b)})};var wa=/^\s*<(\w+)[^>]*>/,xa=/^\s*<(\w+)\s*\/?>(?:<\/\1>)?\s*$/,X; | ||
function v(a){if(!X){var b=e.createElement("table"),c=e.createElement("tr");X={"*":e.createElement("div"),tr:e.createElement("tbody"),td:c,th:c,thead:b,tbody:b,tfoot:b}}if(!u(a))return[];if(xa.test(a))return[e.createElement(RegExp.$1)];b=wa.test(a)&&RegExp.$1;b=X[b]||X["*"];b.innerHTML=a;return x(b.childNodes).detach().get()}x.parseHTML=v;y.empty=function(){var a=this[0];if(a)for(;a.firstChild;)a.removeChild(a.firstChild);return this}; | ||
function Y(a,b,c){if(void 0!==b){var d=u(b);!d&&b.length?A(b,function(b){return Y(a,b,c)}):A(a,d?function(a){a.insertAdjacentHTML(c?"afterbegin":"beforeend",b)}:function(a,d){d=d?b.cloneNode(!0):b;c?a.insertBefore(d,a.childNodes[0]):a.appendChild(d)})}}y.append=function(){var a=this;A(arguments,function(b){Y(a,b)});return this};y.appendTo=function(a){Y(x(a),this);return this}; | ||
y.html=function(a){if(void 0===a)return this[0]&&this[0].innerHTML;var b=a.nodeType?a[0].outerHTML:a;return this.each(function(a,d){d.innerHTML=b})};y.insertAfter=function(a){var b=this;x(a).each(function(a,d){var c=d.parentNode;b.each(function(b,f){c.insertBefore(a?f.cloneNode(!0):f,d.nextSibling)})});return this};y.after=function(){var a=this;A(n.apply(arguments),function(b){n.apply(x(b).slice()).insertAfter(a)});return this}; | ||
y.insertBefore=function(a){var b=this;x(a).each(function(a,d){var c=d.parentNode;b.each(function(b,f){c.insertBefore(a?f.cloneNode(!0):f,d)})});return this};y.before=function(){var a=this;A(arguments,function(b){x(b).insertBefore(a)});return this};y.prepend=function(){var a=this;A(arguments,function(b){Y(a,b,!0)});return this};y.prependTo=function(a){Y(x(a),n.apply(this.slice()),!0);return this};y.remove=function(){return this.detach().off()}; | ||
y.replaceWith=function(a){var b=this;return this.each(function(c,d){var f=d.parentNode;if(f){c=c?x(a).clone():x(a);if(!c[0])return b.remove(),!1;f.replaceChild(c[0],d);x(c[0]).after(c.slice(1))}})};y.replaceAll=function(a){x(a).replaceWith(this);return this};y.text=function(a){return void 0===a?this[0]?this[0].textContent:"":this.each(function(b,c){c.textContent=a})};var Z=e.documentElement; | ||
y.offset=function(){var a=this[0];if(a)return a=a.getBoundingClientRect(),{top:a.top+g.pageYOffset-Z.clientTop,left:a.left+g.pageXOffset-Z.clientLeft}};y.offsetParent=function(){return x(this[0]&&this[0].offsetParent)};y.position=function(){var a=this[0];if(a)return{left:a.offsetLeft,top:a.offsetTop}};y.children=function(a){var b=[];this.each(function(a,d){m.apply(b,d.children)});b=x(I(b));return a?b.filter(function(b,d){return C(d,a)}):b}; | ||
y.contents=function(){var a=[];this.each(function(b,c){m.apply(a,"IFRAME"===c.tagName?[c.contentDocument]:c.childNodes)});return x(a.length&&I(a))};y.find=function(a){for(var b=[],c=0,d=this.length;c<d;c++){var f=r(a,this[c]);f.length&&m.apply(b,f)}return x(b.length&&I(b))};y.has=function(a){var b=u(a)?function(b,d){return!!r(a,d).length}:function(b,d){return d.contains(a)};return this.filter(b)}; | ||
y.is=function(a){if(!a||!this[0])return!1;var b=F(a),c=!1;this.each(function(d,f){c=b(d,f,a);return!c});return c};y.next=function(){return x(this[0]&&this[0].nextElementSibling)};y.not=function(a){if(!a||!this[0])return this;var b=F(a);return this.filter(function(c,d){return!b(c,d,a)})};y.parent=function(){var a=[];this.each(function(b,c){c&&c.parentNode&&a.push(c.parentNode)});return x(I(a))};y.index=function(a){var b=a?x(a)[0]:this[0];a=a?this:x(b).parent().children();return aa.call(a,b)}; | ||
y.closest=function(a){return a&&this[0]?this.is(a)?this.filter(a):this.parent().closest(a):x()};y.parents=function(a){var b=[],c;this.each(function(d,f){for(c=f;c&&c.parentNode&&c!==e.body.parentNode;)c=c.parentNode,(!a||a&&C(c,a))&&b.push(c)});return x(I(b))};y.prev=function(){return x(this[0]&&this[0].previousElementSibling)};y.siblings=function(){var a=this[0];return this.parent().children().filter(function(b,c){return c!==a})}; | ||
'use strict';var e=document,f=window,k=e.createElement("div"),l=Array.prototype,m=l.filter,n=l.indexOf,p=l.map,q=l.push,r=l.reverse,t=l.slice,u=l.some,aa=l.splice,ba=/^#[\w-]*$/,ca=/^\.[\w-]*$/,da=/<.+>/,ea=/^\w+$/;function v(a,b){void 0===b&&(b=e);return ca.test(a)?b.getElementsByClassName(a.slice(1)):ea.test(a)?b.getElementsByTagName(a):b.querySelectorAll(a)} | ||
var w=function(){function a(a,c){void 0===c&&(c=e);if(a){if(a instanceof w)return a;var b=a;if(x(a)){if(b=c instanceof w?c[0]:c,b=ba.test(a)?b.getElementById(a.slice(1)):da.test(a)?y(a):v(a,b),!b)return}else if(A(a))return this.ready(a);if(b.nodeType||b===f)b=[b];this.length=b.length;a=0;for(c=this.length;a<c;a++)this[a]=b[a]}}a.prototype.init=function(b,c){return new a(b,c)};return a}(),B=w.prototype.init;B.fn=B.prototype=w.prototype;w.prototype.length=0;w.prototype.splice=aa; | ||
w.prototype.get=function(a){return void 0===a?t.call(this):this[0>a?a+this.length:a]};w.prototype.eq=function(a){return B(this.get(a))};w.prototype.first=function(){return this.eq(0)};w.prototype.last=function(){return this.eq(-1)};w.prototype.map=function(a){return B(p.call(this,function(b,c){return a.call(b,c,b)}))};w.prototype.slice=function(){return B(t.apply(this,arguments))};var fa=/-([a-z])/g;function ha(a,b){return b.toUpperCase()}function C(a){return a.replace(fa,ha)}B.camelCase=C; | ||
function D(a,b){for(var c=0,d=a.length;c<d&&!1!==b.call(a[c],c,a[c]);c++);}B.each=D;w.prototype.each=function(a){D(this,a);return this};w.prototype.removeProp=function(a){return this.each(function(b,c){delete c[a]})};function E(a){for(var b=1;b<arguments.length;b++);b=arguments;for(var c=b.length,d=2>c?0:1;d<c;d++)for(var g in b[d])a[g]=b[d][g];return a}w.prototype.extend=function(a){return E(B.fn,a)};B.extend=E;var F=1;B.guid=F;function G(a,b){return!!a&&!!a.matches&&a.matches(b)}B.matches=G; | ||
function H(a,b){return m.call(p.call(a,function(a){return a[b]}),function(a){return null!=a})}function A(a){return"function"===typeof a}function x(a){return"string"===typeof a}function I(a){return!isNaN(parseFloat(a))&&isFinite(a)}var J=Array.isArray;B.isFunction=A;B.isString=x;B.isNumeric=I;B.isArray=J;w.prototype.prop=function(a,b){if(a){if(x(a))return 2>arguments.length?this[0]&&this[0][a]:this.each(function(c,g){g[a]=b});for(var c in a)this.prop(c,a[c]);return this}}; | ||
function K(a){return x(a)?function(b,c){return G(c,a)}:A(a)?a:a instanceof w?function(b,c){return a.is(c)}:function(b,c){return c===a}}w.prototype.filter=function(a){if(!a)return B();var b=K(a);return B(m.call(this,function(a,d){return b.call(a,d,a)}))};var ia=/\S+/g;function L(a){return x(a)?a.match(ia)||[]:[]}w.prototype.hasClass=function(a){return u.call(this,function(b){return b.classList.contains(a)})}; | ||
w.prototype.removeAttr=function(a){var b=L(a);return b.length?this.each(function(a,d){D(b,function(a,b){d.removeAttribute(b)})}):this};w.prototype.attr=function(a,b){if(a){if(x(a)){if(2>arguments.length){if(!this[0])return;var c=this[0].getAttribute(a);return null===c?void 0:c}return null===b?this.removeAttr(a):this.each(function(c,g){g.setAttribute(a,b)})}for(c in a)this.attr(c,a[c]);return this}}; | ||
w.prototype.toggleClass=function(a,b){var c=L(a),d=void 0!==b;return c.length?this.each(function(a,h){D(c,function(a,c){d?b?h.classList.add(c):h.classList.remove(c):h.classList.toggle(c)})}):this};w.prototype.addClass=function(a){return this.toggleClass(a,!0)};w.prototype.removeClass=function(a){return arguments.length?this.toggleClass(a,!1):this.attr("class","")};function M(a){return 1<a.length?m.call(a,function(a,c,d){return n.call(d,a)===c}):a}B.unique=M; | ||
w.prototype.add=function(a,b){return B(M(this.get().concat(B(a,b).get())))};function N(a,b,c){if(1===a.nodeType&&b)return a=f.getComputedStyle(a,null),b?c?a.getPropertyValue(b)||void 0:a[b]:a}function P(a,b){return parseInt(N(a,b),10)||0}var Q=/^--/,R={},ja=k.style,ka=["webkit","moz","ms","o"]; | ||
function S(a,b){void 0===b&&(b=Q.test(a));if(b)return a;if(!R[a]){b=C(a);var c=""+b.charAt(0).toUpperCase()+b.slice(1);b=(b+" "+ka.join(c+" ")+c).split(" ");D(b,function(b,c){if(c in ja)return R[a]=c,!1})}return R[a]}B.prefixedProp=S;var la={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function T(a,b,c){void 0===c&&(c=Q.test(a));return c||la[a]||!I(b)?b:b+"px"} | ||
w.prototype.css=function(a,b){if(x(a)){var c=Q.test(a);a=S(a,c);if(2>arguments.length)return this[0]&&N(this[0],a,c);if(!a)return this;b=T(a,b,c);return this.each(function(d,h){1===h.nodeType&&(c?h.style.setProperty(a,b):h.style[a]=b)})}for(var d in a)this.css(d,a[d]);return this};var ma=/^data-(.*)/;B.hasData=function(a){return"__cashData"in a};function U(a){return a.__cashData=a.__cashData||{}} | ||
function V(a,b){var c=U(a);if(b){if(!(b in c)&&(a=a.dataset?a.dataset[b]||a.dataset[C(b)]:B(a).attr("data-"+b),void 0!==a)){try{a=JSON.parse(a)}catch(d){}c[b]=a}return c[b]}return c}w.prototype.data=function(a,b){var c=this;if(!a){if(!this[0])return;D(this[0].attributes,function(a,b){(a=b.name.match(ma))&&c.data(a[1])});return V(this[0])}if(x(a))return void 0===b?this[0]&&V(this[0],a):this.each(function(c,d){U(d)[a]=b});for(var d in a)this.data(d,a[d]);return this}; | ||
w.prototype.removeData=function(a){return this.each(function(b,c){void 0===a?delete c.__cashData:delete U(c)[a]})};function na(a,b){return P(a,"border"+(b?"Left":"Top")+"Width")+P(a,"padding"+(b?"Left":"Top"))+P(a,"padding"+(b?"Right":"Bottom"))+P(a,"border"+(b?"Right":"Bottom")+"Width")}D(["Width","Height"],function(a,b){w.prototype["inner"+b]=function(){if(this[0])return this[0]===f?f["inner"+b]:this[0]["client"+b]}}); | ||
D(["width","height"],function(a,b){w.prototype[b]=function(c){if(!this[0])return void 0===c?void 0:this;if(!arguments.length)return this[0]===f?this[0][C("outer-"+b)]:this[0].getBoundingClientRect()[b]-na(this[0],!a);var d=parseInt(c,10);return this.each(function(c,h){1===h.nodeType&&(c=N(h,"boxSizing"),h.style[b]=T(b,d+("border-box"===c?na(h,!a):0)))})}}); | ||
D(["Width","Height"],function(a,b){w.prototype["outer"+b]=function(c){if(this[0])return this[0]===f?f["outer"+b]:this[0]["offset"+b]+(c?P(this[0],"margin"+(a?"Top":"Left"))+P(this[0],"margin"+(a?"Bottom":"Right")):0)}});function oa(a,b){return!b||!u.call(b,function(b){return 0>a.indexOf(b)})}function pa(a,b,c,d){d.guid=d.guid||F++;var g=a.__cashEvents=a.__cashEvents||{};g[b]=g[b]||[];g[b].push([c,d]);a.addEventListener(b,d)}function W(a){a=a.split(".");return[a[0],a.slice(1).sort()]} | ||
function X(a,b,c,d){var g=a.__cashEvents=a.__cashEvents||{};if(b)g[b]&&(g[b]=g[b].filter(function(g){var h=g[0];g=g[1];if(d&&g.guid!==d.guid||!oa(h,c))return!0;a.removeEventListener(b,g)}));else{for(b in g)X(a,b,c,d);delete a.__cashEvents}}w.prototype.off=function(a,b){var c=this;void 0===a?this.each(function(a,b){return X(b)}):D(L(a),function(a,g){a=W(g);var d=a[0],z=a[1];c.each(function(a,c){return X(c,d,z,b)})});return this}; | ||
w.prototype.on=function(a,b,c,d){var g=this;if(!x(a)){for(var h in a)this.on(h,b,a[h]);return this}A(b)&&(c=b,b="");D(L(a),function(a,h){a=W(h);var z=a[0],O=a[1];g.each(function(a,g){a=function sa(a){if(!a.namespace||oa(O,a.namespace.split("."))){var h=g;if(b)for(h=a.target;!G(h,b);){if(h===g)return;h=h.parentNode;if(!h)return}a.namespace=a.namespace||"";h=c.call(h,a,a.data);d&&X(g,z,O,sa);!1===h&&(a.preventDefault(),a.stopPropagation())}};a.guid=c.guid=c.guid||F++;pa(g,z,O,a)})});return this}; | ||
w.prototype.one=function(a,b,c){return this.on(a,b,c,!0)};w.prototype.ready=function(a){function b(){return a(B)}"loading"!==e.readyState?setTimeout(b):e.addEventListener("DOMContentLoaded",b);return this};w.prototype.trigger=function(a,b){var c=a;if(x(a)){var d=W(a);a=d[0];d=d[1];c=e.createEvent("HTMLEvents");c.initEvent(a,!0,!0);c.namespace=d.join(".")}c.data=b;return this.each(function(a,b){b.dispatchEvent(c)})}; | ||
function qa(a){return a.multiple?H(m.call(a.options,function(a){return a.selected&&!a.disabled&&!a.parentNode.disabled}),"value"):a.value||""}var ra=/%20/g,ta=/file|reset|submit|button|image/i,ua=/radio|checkbox/i; | ||
w.prototype.serialize=function(){var a="";this.each(function(b,c){D(c.elements||[c],function(b,c){c.disabled||!c.name||"FIELDSET"===c.tagName||ta.test(c.type)||ua.test(c.type)&&!c.checked||(b=qa(c),void 0!==b&&(b=J(b)?b:[b],D(b,function(b,d){b=a;d="&"+encodeURIComponent(c.name)+"="+encodeURIComponent(d).replace(ra,"+");a=b+d})))})});return a.substr(1)}; | ||
w.prototype.val=function(a){return void 0===a?this[0]&&qa(this[0]):this.each(function(b,c){b=c.multiple;var d=null===a?b?[]:"":a;b&&J(d)?D(c.options,function(a,b){b.selected=0<=d.indexOf(b.value)}):c.value=d})};w.prototype.clone=function(){return this.map(function(a,b){return b.cloneNode(!0)})};w.prototype.detach=function(){return this.each(function(a,b){b.parentNode&&b.parentNode.removeChild(b)})};var va=/^\s*<(\w+)[^>]*>/,wa=/^\s*<(\w+)\s*\/?>(?:<\/\1>)?\s*$/,Y; | ||
function y(a){if(!Y){var b=e.createElement("table"),c=e.createElement("tr");Y={"*":k,tr:e.createElement("tbody"),td:c,th:c,thead:b,tbody:b,tfoot:b}}if(!x(a))return[];if(wa.test(a))return[e.createElement(RegExp.$1)];b=va.test(a)&&RegExp.$1;b=Y[b]||Y["*"];b.innerHTML=a;return B(b.childNodes).detach().get()}B.parseHTML=y;w.prototype.empty=function(){var a=this[0];if(a)for(;a.firstChild;)a.removeChild(a.firstChild);return this}; | ||
function Z(a,b,c){D(a,function(a,g){D(b,function(b,d){b=a?d.cloneNode(!0):d;c?g.insertBefore(b,g.childNodes[0]):g.appendChild(b)})})}w.prototype.append=function(){var a=this;D(arguments,function(b,c){Z(a,B(c))});return this};w.prototype.appendTo=function(a){Z(B(a),this);return this};w.prototype.html=function(a){return void 0===a?this[0]&&this[0].innerHTML:this.each(function(b,c){c.innerHTML=a})}; | ||
w.prototype.insertAfter=function(a){var b=this;B(a).each(function(a,d){var c=d.parentNode;c&&b.each(function(b,g){c.insertBefore(a?g.cloneNode(!0):g,d.nextSibling)})});return this};w.prototype.after=function(){var a=this;D(r.apply(arguments),function(b,c){r.apply(B(c).slice()).insertAfter(a)});return this};w.prototype.insertBefore=function(a){var b=this;B(a).each(function(a,d){var c=d.parentNode;c&&b.each(function(b,g){c.insertBefore(a?g.cloneNode(!0):g,d)})});return this}; | ||
w.prototype.before=function(){var a=this;D(arguments,function(b,c){B(c).insertBefore(a)});return this};w.prototype.prepend=function(){var a=this;D(arguments,function(b,c){Z(a,B(c),!0)});return this};w.prototype.prependTo=function(a){Z(B(a),r.apply(this.slice()),!0);return this};w.prototype.remove=function(){return this.detach().off()};w.prototype.replaceWith=function(a){return this.before(a).remove()};w.prototype.replaceAll=function(a){B(a).replaceWith(this);return this}; | ||
w.prototype.text=function(a){return void 0===a?this[0]?this[0].textContent:"":this.each(function(b,c){c.textContent=a})};var xa=e.documentElement;w.prototype.offset=function(){var a=this[0];if(a)return a=a.getBoundingClientRect(),{top:a.top+f.pageYOffset-xa.clientTop,left:a.left+f.pageXOffset-xa.clientLeft}};w.prototype.offsetParent=function(){return B(this[0]&&this[0].offsetParent)};w.prototype.position=function(){var a=this[0];if(a)return{left:a.offsetLeft,top:a.offsetTop}}; | ||
w.prototype.children=function(a){var b=[];this.each(function(a,d){q.apply(b,d.children)});b=B(M(b));return a?b.filter(a):b};w.prototype.contents=function(){var a=[];this.each(function(b,c){q.apply(a,"IFRAME"===c.tagName?[c.contentDocument]:c.childNodes)});return B(M(a))};w.prototype.find=function(a){for(var b=[],c=0,d=this.length;c<d;c++){var g=v(a,this[c]);g.length&&q.apply(b,g)}return B(M(b))}; | ||
w.prototype.has=function(a){var b=x(a)?function(b,d){return!!v(a,d).length}:function(b,d){return d.contains(a)};return this.filter(b)};w.prototype.is=function(a){if(!a||!this[0])return!1;var b=K(a),c=!1;this.each(function(a,g){c=b.call(g,a,g);return!c});return c};w.prototype.next=function(){return B(M(H(this,"nextElementSibling")))};w.prototype.not=function(a){if(!a||!this[0])return this;var b=K(a);return this.filter(function(a,d){return!b.call(d,a,d)})}; | ||
w.prototype.parent=function(){return B(M(H(this,"parentNode")))};w.prototype.index=function(a){var b=a?B(a)[0]:this[0];a=a?this:B(b).parent().children();return n.call(a,b)};w.prototype.closest=function(a){return a&&this[0]?this.is(a)?this.filter(a):this.parent().closest(a):B()};w.prototype.parents=function(a){var b=[],c;this.each(function(d,g){for(c=g;c&&c.parentNode&&c!==e.body.parentNode;)c=c.parentNode,(!a||a&&G(c,a))&&b.push(c)});return B(M(b))};w.prototype.prev=function(){return B(M(H(this,"previousElementSibling")))}; | ||
w.prototype.siblings=function(){var a=this[0];return this.parent().children().filter(function(b,c){return c!==a})};"undefined"!==typeof exports?module.exports=B:f.cash=f.$=B; | ||
})(); |
@@ -101,2 +101,3 @@ | ||
'karma-chrome-launcher', | ||
'karma-firefox-launcher', | ||
'karma-sauce-launcher', | ||
@@ -107,5 +108,17 @@ 'karma-spec-reporter' | ||
'dist/cash.js', | ||
'test/index.js' | ||
'test/helpers.js', | ||
'test/modules/attributes.js', | ||
'test/modules/collection.js', | ||
'test/modules/core.js', | ||
'test/modules/css.js', | ||
'test/modules/data.js', | ||
'test/modules/dimensions.js', | ||
'test/modules/events.js', | ||
'test/modules/forms.js', | ||
'test/modules/manipulation.js', | ||
'test/modules/offset.js', | ||
'test/modules/traversal.js', | ||
'test/modules/utilities.js' | ||
], | ||
browsers: isSauceLabs ? Object.keys ( SauceLabsLaunchers ) : ['Chrome'], | ||
browsers: isSauceLabs ? Object.keys ( SauceLabsLaunchers ) : ['Chrome', 'Firefox'], | ||
customLaunchers: SauceLabsLaunchers, | ||
@@ -112,0 +125,0 @@ reporters: [ |
{ | ||
"browsers": ["ie >= 10"], | ||
"components": { | ||
"core/export_esm": false | ||
}, | ||
"paths": { | ||
@@ -11,2 +14,6 @@ "tokens": { | ||
"minified": "[dist]/[bundle].min.js" | ||
}, | ||
"typescript": { | ||
"declaration": "[dist]/[bundle].d.ts", | ||
"partial": "[dist]/[bundle].ts" | ||
} | ||
@@ -28,3 +35,4 @@ } | ||
"components": { | ||
"core/export": false | ||
"core/export": false, | ||
"core/export_esm": true | ||
}, | ||
@@ -43,3 +51,3 @@ "paths": { | ||
"templates": { | ||
"unminified": "/* MIT https://github.com/kenwheeler/cash */\n[content]\nexport default cash;\n" | ||
"unminified": "/* MIT https://github.com/kenwheeler/cash */\n[content]\n" | ||
} | ||
@@ -46,0 +54,0 @@ } |
{ | ||
"name": "cash-dom", | ||
"description": "An absurdly small jQuery alternative for modern browsers.", | ||
"version": "2.3.9", | ||
"version": "3.0.0-beta.0", | ||
"license": "MIT", | ||
@@ -9,2 +9,3 @@ "main": "./dist/cash.js", | ||
"jsnext:main": "./dist/cash.esm.js", | ||
"types": "dist/cash.d.ts", | ||
"scripts": { | ||
@@ -41,6 +42,9 @@ "clean": "pacco clean", | ||
"devDependencies": { | ||
"@types/node": "^10.12.0", | ||
"browser-sync": "^2.26.3", | ||
"bundlesize": "^0.17.0", | ||
"jquery": "^3.3.1", | ||
"karma": "^3.0.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-firefox-launcher": "^1.1.0", | ||
"karma-qunit": "^2.1.0", | ||
@@ -50,5 +54,5 @@ "karma-sauce-launcher": "^1.2.0", | ||
"opn-cli": "^3.1.0", | ||
"pacco": "^1.3.7", | ||
"pacco": "^2.0.6", | ||
"qunit": "^2.7.1" | ||
} | ||
} |
@@ -10,18 +10,27 @@ | ||
## Size Comparison | ||
## Comparison | ||
| | Cash | jQuery 3.3.1 | | ||
| ------------------ | ----------- | ------------ | | ||
| Uncompressed | **28.7 KB** | 271 KB | | ||
| Minified | **11 KB** | 87 KB | | ||
| Minified & Gzipped | **4.5 KB** | 30.3 KB | | ||
| Size | Cash | Zepto 1.2.0 | jQuery 3.3.1 | | ||
| ------------------ | ----------- | ----------- | ------------ | | ||
| Uncompressed | **28.7 KB** | 58.7 KB | 271 KB | | ||
| Minified | **12.7 KB** | 26 KB | 87 KB | | ||
| Minified & Gzipped | **4.5 KB** | 9.8 KB | 30.3 KB | | ||
An **85%** gain in size reduction. If you need a smaller bundle, we support [partial builds](https://github.com/kenwheeler/cash/blob/master/docs/partial_builds.md) too. | ||
An **85%** gain in size reduction compared to jQuery. If you need a smaller bundle, we support [partial builds](https://github.com/kenwheeler/cash/blob/master/docs/partial_builds.md) too. | ||
| Features | Cash | Zepto 1.2.0 | jQuery 3.3.1 | | ||
| ------------------------ | ---------------------------- | ------------------------------ | ------------------------ | | ||
| Supports Modern Browsers | ✔ | ️✔ | ✔ | | ||
| Actively Maintained | ✔ | ❌ | ✔ | | ||
| Namespaced Events | ✔ | ️❌ | ✔ | | ||
| Modern Codebase | ✔ (TypeScript) | ️❌ | ❌ | | ||
| TypeScript Types | ✔ (generated from code) | ⚠️ (via DefinitelyTyped) | ⚠️ (via DefinitelyTyped) | | ||
| Partial Builds | ✔ (can exclude single files) | ⚠️ (can exclude whole modules) | ❌ | | ||
## Usage | ||
Get cash from [CloudFlare](https://cdnjs.cloudflare.com/ajax/libs/cash/2.3.7/cash.min.js) or [jsDelivr](https://cdn.jsdelivr.net/npm/cash-dom@2.3.7/dist/cash.min.js) and use it like this: | ||
Get cash from [CloudFlare](https://cdnjs.cloudflare.com/ajax/libs/cash/3.0.0-beta.0/cash.min.js) or [jsDelivr](https://cdn.jsdelivr.net/npm/cash-dom@3.0.0-beta.0/dist/cash.min.js) and use it like this: | ||
```html | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/cash/2.3.7/cash.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/cash/3.0.0-beta.0/cash.min.js"></script> | ||
<script> | ||
@@ -28,0 +37,0 @@ $(function () { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
646778
153
7034
875
13
1
1