Comparing version 5.0.0 to 6.0.0
@@ -0,1 +1,51 @@ | ||
### Version 6.0.0 | ||
##### Removed Features | ||
- $.camelCase|matches|isString|prefixedProp: no longer exposing these methods, aligning with jQuery | ||
##### New Features | ||
- $.fn.nextUntil|prevUntil|parentsUntil: implemented these methods | ||
- $.fn.detach|remove: added support for an optional "selector" argument | ||
- $.fn.on|one: added support for an optional “data” argument | ||
- Set-up test coverage (currently at ~99%) reporting to coveralls.io | ||
- Migration guide: major update | ||
##### Bug Fixes | ||
- $.extend: aligned more with jQuery when called with zero or one argument | ||
- $.fn.before|after|append|prepend|insertBefore|insertAfter|appendTo|prependTo: ensuring cloned scripts don't get executed | ||
- $.fn.contents: ensuring template elements are supported | ||
- $.fn.css: ensuring “grid-*“ properties don’t get the “px” suffix appended to their values when they are not supposed to | ||
- $.fn.data: doing nothing when trying to set values to undefined | ||
- $.fn.data: ensuring strings containing leading/trailing whitespace aren’t parsed as JSON | ||
- $.fn.get|eq: ensuring string indexes are supported | ||
- $.fn.map: ensuring callbacks that return an array of elements are supported too | ||
- $.fn.offset|offsetParent|position: rewritten to much more closely match jQuery’s implementation | ||
- $.fn.on|one|off: ensuring namespaces-only events are ignored | ||
- $.fn.on|one|off: ensuring they don’t throw when receiving a falsy callback | ||
- $.fn.on|one: ensuring these methods are chainable even when receiving falsy callbacks | ||
- $.fn.prop|removeProp: mapping special HTML attributes into their equivalent DOM properties (e.g. “for” -> “htmlFor”) | ||
- $.fn.ready: ensuring exceptions are always caught, so they can't crash the app | ||
- $.fn.serialize: normalizing newlines | ||
- $.fn.trigger: testing that non-nil falsy values are passed correctly | ||
- $.fn.unwrap: ensuring immediate children of the body don’t get unwrapped | ||
- $.fn.val: ensuring checkboxes and radios can be set properly | ||
- $.fn.val: ensuring non-string values are supported | ||
- $.fn.val|html: more reliably detecting when being called with no arguments | ||
- $.fn.width|height|innerWidth|innerHeight|outerWidth|outerHeight: ensuring document objects are supported too | ||
- $.fn.width|height|innerWidth|innerHeight|outerWidth|outerHeight: ensuring they return the right value for the Window object | ||
- $.fn.wrapAll: ensuring elements aren’t cloned unnecessarely | ||
- $.parseHTML: ensuring whitespace around a single HTML tag is preserved | ||
- Ensuring empty selectors don’t throw an error | ||
- Collections containing non-element objects: | ||
- $.fn.addClass|removeClass|toggleClass: ensuring it doesn’t throw with collections containing non-elements | ||
- $.fn.attr: ensuring a collection containing non-element objects doesn’t cause an error to be thrown | ||
- $.fn.before|after|append|prepend|insertBefore|insertAfter|appendTo|prependTo: ensuring non-element nodes are accounted for properly | ||
- $.fn.hasClass: ensuring a collection containing non-element objects doesn’t cause an error to be thrown | ||
- $.fn.hide|show|toggle: ensuring a collection containing non-element objects doesn’t cause an error to be thrown | ||
- $.fn.html: ensuring collections containing non-element objects are supported | ||
- $.fn.not: ensuring non-element nodes are excluded | ||
- $.fn.on|off: ensuring non-element objects in the collection are ignored | ||
- $.fn.removeAttr: ensuring a collection containing non-element objects doesn’t cause an error to be thrown | ||
- $.fn.text: improved support of collections containing non-elements objects | ||
### Version 5.0.0 | ||
@@ -2,0 +52,0 @@ - Dropped support for IE10 |
@@ -5,2 +5,3 @@ interface Event { | ||
___cd?: boolean; | ||
___td?: boolean; | ||
} | ||
@@ -40,5 +41,2 @@ interface Cash { | ||
} | ||
interface CashStatic { | ||
camelCase(str: string): string; | ||
} | ||
declare type EachCallback<T> = (this: T, index: number, ele: T) => any; | ||
@@ -55,2 +53,4 @@ interface CashStatic { | ||
interface CashStatic { | ||
extend(): any; | ||
extend(target: any): typeof cash; | ||
extend(target: any, ...objs: any[]): any; | ||
@@ -65,8 +65,4 @@ } | ||
interface CashStatic { | ||
matches(ele: any, selector: string): boolean; | ||
} | ||
interface CashStatic { | ||
isWindow(x: any): x is Window; | ||
isFunction(x: any): x is Function; | ||
isString(x: any): x is string; | ||
isNumeric(x: any): boolean; | ||
@@ -123,5 +119,2 @@ isArray(x: any): x is Array<any>; | ||
} | ||
interface CashStatic { | ||
prefixedProp(prop: string, isVariable?: boolean): string; | ||
} | ||
interface Cash { | ||
@@ -168,9 +161,19 @@ css(prop: string): string | undefined; | ||
on(events: Record<string, EventCallback>): this; | ||
on(events: string, callback: EventCallback, _one?: boolean): this; | ||
on(events: string, selector: string | EventCallback, callback: EventCallback, _one?: boolean): this; | ||
on(events: Record<string, EventCallback>, selector: string): this; | ||
on(events: Record<string, EventCallback>, data: any): this; | ||
on(events: Record<string, EventCallback>, selector: string | null | undefined, data: any): this; | ||
on(events: string, callback: EventCallback): this; | ||
on(events: string, selector: string, callback: EventCallback): this; | ||
on(events: string, data: any, callback: EventCallback): this; | ||
on(events: string, selector: string | null | undefined, data: any, callback: EventCallback, _one?: boolean): this; | ||
} | ||
interface Cash { | ||
one(events: Record<string, EventCallback>): this; | ||
one(events: Record<string, EventCallback>, selector: string): this; | ||
one(events: Record<string, EventCallback>, data: any): this; | ||
one(events: Record<string, EventCallback>, selector: string | null | undefined, data: any): this; | ||
one(events: string, callback: EventCallback): this; | ||
one(events: string, selector: string | EventCallback, callback: EventCallback): this; | ||
one(events: string, selector: string, callback: EventCallback): this; | ||
one(events: string, data: any, callback: EventCallback): this; | ||
one(events: string, selector: string | null | undefined, data: any, callback: EventCallback): this; | ||
} | ||
@@ -194,3 +197,3 @@ interface Cash { | ||
interface Cash { | ||
detach(): this; | ||
detach(comparator?: Comparator): this; | ||
} | ||
@@ -208,3 +211,3 @@ interface CashStatic { | ||
interface Cash { | ||
remove(): this; | ||
remove(comparator?: Comparator): this; | ||
} | ||
@@ -288,3 +291,3 @@ interface Cash { | ||
interface Cash { | ||
next(comparator?: Comparator, _all?: boolean): Cash; | ||
next(comparator?: Comparator, _all?: boolean, _until?: Comparator): Cash; | ||
} | ||
@@ -295,2 +298,5 @@ interface Cash { | ||
interface Cash { | ||
nextUntil(until?: Comparator, comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
not(comparator?: Comparator): Cash; | ||
@@ -308,11 +314,17 @@ } | ||
interface Cash { | ||
parents(comparator?: Comparator): Cash; | ||
parents(comparator?: Comparator, _until?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
prev(comparator?: Comparator, _all?: boolean): Cash; | ||
parentsUntil(until?: Comparator, comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
prev(comparator?: Comparator, _all?: boolean, _until?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
prevAll(comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
prevUntil(until?: Comparator, comparator?: Comparator): Cash; | ||
} | ||
interface Cash { | ||
siblings(comparator?: Comparator): Cash; | ||
@@ -319,0 +331,0 @@ } |
/* MIT https://github.com/kenwheeler/cash */ | ||
const doc = document, win = window, docEle = doc.documentElement, createElement = doc.createElement.bind(doc), div = createElement('div'), table = createElement('table'), tbody = createElement('tbody'), tr = createElement('tr'), { isArray, prototype: ArrayProtoType } = Array, { filter, indexOf, map, push, slice, some, splice } = ArrayProtoType; | ||
const propMap = { | ||
/* GENERAL */ | ||
class: 'className', | ||
contenteditable: 'contentEditable', | ||
/* LABEL */ | ||
for: 'htmlFor', | ||
/* INPUT */ | ||
readonly: 'readOnly', | ||
maxlength: 'maxLength', | ||
tabindex: 'tabIndex', | ||
/* TABLE */ | ||
colspan: 'colSpan', | ||
rowspan: 'rowSpan', | ||
/* IMAGE */ | ||
usemap: 'useMap' | ||
}; | ||
function attempt(fn, arg) { | ||
try { | ||
return fn(arg); | ||
} | ||
catch (_a) { | ||
return arg; | ||
} | ||
} | ||
const doc = document, win = window, docEle = doc.documentElement, createElement = doc.createElement.bind(doc), div = createElement('div'), table = createElement('table'), tbody = createElement('tbody'), tr = createElement('tr'), { isArray, prototype: ArrayPrototype } = Array, { concat, filter, indexOf, map, push, slice, some, splice } = ArrayPrototype; | ||
const idRe = /^#[\w-]*$/, classRe = /^\.[\w-]*$/, htmlRe = /<.+>/, tagRe = /^\w+$/; | ||
// @require ./variables.ts | ||
function find(selector, context = doc) { | ||
return !isDocument(context) && !isElement(context) | ||
function find(selector, context) { | ||
return !selector || (!isDocument(context) && !isElement(context)) | ||
? [] | ||
@@ -17,3 +41,3 @@ : classRe.test(selector) | ||
class Cash { | ||
constructor(selector, context = doc) { | ||
constructor(selector, context) { | ||
if (!selector) | ||
@@ -25,3 +49,3 @@ return; | ||
if (isString(selector)) { | ||
const ctx = isCash(context) ? context[0] : context; | ||
const ctx = (isCash(context) ? context[0] : context) || doc; | ||
eles = idRe.test(selector) | ||
@@ -54,6 +78,6 @@ ? ctx.getElementById(selector.slice(1)) | ||
if (typeof Symbol === 'function') { // Ensuring a cash collection is iterable | ||
fn[Symbol['iterator']] = ArrayProtoType[Symbol['iterator']]; | ||
fn[Symbol['iterator']] = ArrayPrototype[Symbol['iterator']]; | ||
} | ||
fn.map = function (callback) { | ||
return cash(map.call(this, (ele, i) => callback.call(ele, i, ele))); | ||
return cash(concat.apply([], map.call(this, (ele, i) => callback.call(ele, i, ele)))); | ||
}; | ||
@@ -63,2 +87,3 @@ fn.slice = function (start, end) { | ||
}; | ||
// @require ./cash.ts | ||
const dashAlphaRe = /-([a-z])/g; | ||
@@ -68,5 +93,4 @@ function camelCase(str) { | ||
} | ||
cash.camelCase = camelCase; | ||
function each(arr, callback, reverse) { | ||
if (reverse) { | ||
function each(arr, callback, _reverse) { | ||
if (_reverse) { | ||
let i = arr.length; | ||
@@ -91,7 +115,11 @@ while (i--) { | ||
fn.removeProp = function (prop) { | ||
return this.each((i, ele) => { delete ele[prop]; }); | ||
return this.each((i, ele) => { delete ele[propMap[prop] || prop]; }); | ||
}; | ||
cash.extend = function (target, ...objs) { | ||
function extend(target, ...objs) { | ||
const length = arguments.length; | ||
for (let i = (length < 2 ? 0 : 1); i < length; i++) { | ||
if (!length) | ||
return {}; | ||
if (length === 1) | ||
return extend(cash, target); | ||
for (let i = 1; i < length; i++) { | ||
for (const key in arguments[i]) { | ||
@@ -102,12 +130,13 @@ target[key] = arguments[i][key]; | ||
return target; | ||
}; | ||
} | ||
cash.extend = extend; | ||
fn.extend = function (plugins) { | ||
return cash.extend(fn, plugins); | ||
return extend(fn, plugins); | ||
}; | ||
cash.guid = 1; | ||
// @require ./cash.ts | ||
function matches(ele, selector) { | ||
const matches = ele && (ele['matches'] || ele['webkitMatchesSelector'] || ele['msMatchesSelector']); | ||
return !!matches && matches.call(ele, selector); | ||
return !!matches && !!selector && matches.call(ele, selector); | ||
} | ||
cash.matches = matches; | ||
function isCash(x) { | ||
@@ -142,3 +171,2 @@ return x instanceof Cash; | ||
cash.isFunction = isFunction; | ||
cash.isString = isString; | ||
cash.isNumeric = isNumeric; | ||
@@ -150,2 +178,3 @@ cash.isArray = isArray; | ||
if (isString(prop)) { | ||
prop = propMap[prop] || prop; | ||
if (arguments.length < 2) | ||
@@ -163,2 +192,3 @@ return this[0] && this[0][prop]; | ||
return slice.call(this); | ||
index = Number(index); | ||
return this[index < 0 ? index + this.length : index]; | ||
@@ -202,3 +232,3 @@ }; | ||
fn.hasClass = function (cls) { | ||
return !!cls && some.call(this, (ele) => ele.classList.contains(cls)); | ||
return !!cls && some.call(this, (ele) => isElement(ele) && ele.classList.contains(cls)); | ||
}; | ||
@@ -208,2 +238,4 @@ fn.removeAttr = function (attr) { | ||
return this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
each(attrs, (i, a) => { | ||
@@ -219,3 +251,3 @@ ele.removeAttribute(a); | ||
if (arguments.length < 2) { | ||
if (!this[0]) | ||
if (!this[0] || !isElement(this[0])) | ||
return; | ||
@@ -229,3 +261,7 @@ const value = this[0].getAttribute(attr); | ||
return this.removeAttr(attr); | ||
return this.each((i, ele) => { ele.setAttribute(attr, value); }); | ||
return this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
ele.setAttribute(attr, value); | ||
}); | ||
} | ||
@@ -241,2 +277,4 @@ for (const key in attr) { | ||
return this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
each(classes, (i, c) => { | ||
@@ -260,4 +298,4 @@ if (isForce) { | ||
}; | ||
function pluck(arr, prop, deep) { | ||
const plucked = [], isCallback = isFunction(prop); | ||
function pluck(arr, prop, deep, until) { | ||
const plucked = [], isCallback = isFunction(prop), compare = until && getCompareFunction(until); | ||
for (let i = 0, l = arr.length; i < l; i++) { | ||
@@ -272,2 +310,4 @@ if (isCallback) { | ||
while (val != null) { | ||
if (until && compare(-1, val)) | ||
break; | ||
plucked.push(val); | ||
@@ -290,6 +330,6 @@ val = deep ? val[prop] : null; | ||
function computeStyle(ele, prop, isVariable) { | ||
if (!isElement(ele) || !prop) | ||
if (!isElement(ele)) | ||
return; | ||
const style = win.getComputedStyle(ele, null); | ||
return prop ? (isVariable ? style.getPropertyValue(prop) || undefined : style[prop]) : style; | ||
return isVariable ? style.getPropertyValue(prop) || undefined : style[prop]; | ||
} | ||
@@ -305,2 +345,7 @@ // @require ./compute_style.ts | ||
} | ||
// @require core/camel_case.ts | ||
// @require core/cash.ts | ||
// @require core/each.ts | ||
// @require core/variables.ts | ||
// @require ./is_css_variable.ts | ||
const prefixedProps = {}, { style } = div, vendorsPrefixes = ['webkit', 'moz', 'ms']; | ||
@@ -322,3 +367,2 @@ function getPrefixedProp(prop, isVariable = isCSSVariable(prop)) { | ||
; | ||
cash.prefixedProp = getPrefixedProp; | ||
// @require core/type_checking.ts | ||
@@ -332,2 +376,9 @@ // @require ./is_css_variable.ts | ||
fontWeight: true, | ||
gridArea: true, | ||
gridColumn: true, | ||
gridColumnEnd: true, | ||
gridColumnStart: true, | ||
gridRow: true, | ||
gridRowEnd: true, | ||
gridRowStart: true, | ||
lineHeight: true, | ||
@@ -371,17 +422,15 @@ opacity: true, | ||
// @optional ./css.ts | ||
// @require core/attempt.ts | ||
// @require core/camel_case.ts | ||
const JSONStringRe = /^\s+|\s+$/; | ||
function getData(ele, key) { | ||
const value = ele.dataset[key] || ele.dataset[camelCase(key)]; | ||
try { | ||
return JSON.parse(value); | ||
} | ||
catch (_a) { } | ||
return value; | ||
if (JSONStringRe.test(value)) | ||
return value; | ||
return attempt(JSON.parse, value); | ||
} | ||
// @require core/attempt.ts | ||
// @require core/camel_case.ts | ||
function setData(ele, key, value) { | ||
try { | ||
value = JSON.stringify(value); | ||
} | ||
catch (_a) { } | ||
value = attempt(JSON.stringify, value); | ||
ele.dataset[camelCase(key)] = value; | ||
@@ -402,2 +451,4 @@ } | ||
return this[0] && getData(this[0], name); | ||
if (isUndefined(value)) | ||
return this; | ||
return this.each((i, ele) => { setData(ele, name, value); }); | ||
@@ -412,2 +463,6 @@ } | ||
// @optional ./data.ts | ||
function getDocumentDimension(doc, dimension) { | ||
const docEle = doc.documentElement; | ||
return Math.max(doc.body[`scroll${dimension}`], docEle[`scroll${dimension}`], doc.body[`offset${dimension}`], docEle[`offset${dimension}`], docEle[`client${dimension}`]); | ||
} | ||
// @require css/helpers/compute_style_int.ts | ||
@@ -424,3 +479,5 @@ function getExtraSpace(ele, xAxis) { | ||
if (isWindow(this[0])) | ||
return win[name]; | ||
return outer ? this[0][`inner${prop}`] : this[0].document.documentElement[`client${prop}`]; | ||
if (isDocument(this[0])) | ||
return getDocumentDimension(this[0], prop); | ||
return this[0][`${outer ? 'offset' : 'client'}${prop}`] + (includeMargins && outer ? computeStyleInt(this[0], `margin${i ? 'Top' : 'Left'}`) + computeStyleInt(this[0], `margin${i ? 'Bottom' : 'Right'}`) : 0); | ||
@@ -430,4 +487,5 @@ }; | ||
}); | ||
each(['width', 'height'], (index, prop) => { | ||
fn[prop] = function (value) { | ||
each(['Width', 'Height'], (index, prop) => { | ||
const propLC = prop.toLowerCase(); | ||
fn[propLC] = function (value) { | ||
if (!this[0]) | ||
@@ -437,4 +495,6 @@ return isUndefined(value) ? undefined : this; | ||
if (isWindow(this[0])) | ||
return this[0][camelCase(`outer-${prop}`)]; | ||
return this[0].getBoundingClientRect()[prop] - getExtraSpace(this[0], !index); | ||
return this[0].document.documentElement[`client${prop}`]; | ||
if (isDocument(this[0])) | ||
return getDocumentDimension(this[0], prop); | ||
return this[0].getBoundingClientRect()[propLC] - getExtraSpace(this[0], !index); | ||
} | ||
@@ -446,3 +506,3 @@ const valueNumber = parseInt(value, 10); | ||
const boxSizing = computeStyle(ele, 'boxSizing'); | ||
ele.style[prop] = getSuffixedValue(prop, valueNumber + (boxSizing === 'border-box' ? getExtraSpace(ele, !index) : 0)); | ||
ele.style[propLC] = getSuffixedValue(propLC, valueNumber + (boxSizing === 'border-box' ? getExtraSpace(ele, !index) : 0)); | ||
}); | ||
@@ -471,2 +531,4 @@ }; | ||
return this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
const show = isUndefined(force) ? isHidden(ele) : force; | ||
@@ -509,3 +571,2 @@ if (show) { | ||
function addEvent(ele, name, namespaces, selector, callback) { | ||
callback.guid = callback.guid || cash.guid++; | ||
const eventCache = getEventsCache(ele); | ||
@@ -541,3 +602,7 @@ eventCache[name] = (eventCache[name] || []); | ||
if (isUndefined(eventFullName)) { | ||
this.each((i, ele) => { removeEvent(ele); }); | ||
this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
removeEvent(ele); | ||
}); | ||
} | ||
@@ -556,3 +621,7 @@ else if (!isString(eventFullName)) { | ||
const [name, namespaces] = parseEventName(getEventNameBubbling(eventFullName)); | ||
this.each((i, ele) => { removeEvent(ele, name, namespaces, selector, callback); }); | ||
this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
removeEvent(ele, name, namespaces, selector, callback); | ||
}); | ||
}); | ||
@@ -562,16 +631,36 @@ } | ||
}; | ||
function on(eventFullName, selector, callback, _one) { | ||
function on(eventFullName, selector, data, callback, _one) { | ||
if (!isString(eventFullName)) { | ||
for (const key in eventFullName) { | ||
this.on(key, selector, eventFullName[key]); | ||
this.on(key, selector, data, eventFullName[key], _one); | ||
} | ||
return this; | ||
} | ||
if (isFunction(selector)) { | ||
callback = selector; | ||
selector = ''; | ||
if (!isString(selector)) { | ||
if (isUndefined(selector) || isNull(selector)) { | ||
selector = ''; | ||
} | ||
else if (isUndefined(data)) { | ||
data = selector; | ||
selector = ''; | ||
} | ||
else { | ||
callback = data; | ||
data = selector; | ||
selector = ''; | ||
} | ||
} | ||
if (!isFunction(callback)) { | ||
callback = data; | ||
data = undefined; | ||
} | ||
if (!callback) | ||
return this; | ||
each(getSplitValues(eventFullName), (i, eventFullName) => { | ||
const [name, namespaces] = parseEventName(getEventNameBubbling(eventFullName)); | ||
if (!name) | ||
return; | ||
this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
const finalCallback = function (event) { | ||
@@ -601,3 +690,4 @@ if (event.namespace && !hasNamespaces(namespaces, event.namespace.split(eventsNamespacesSeparator))) | ||
} | ||
const returnValue = callback.call(thisArg, event, event.data); | ||
event.data = data; | ||
const returnValue = callback.call(thisArg, event, event.___td); | ||
if (_one) { | ||
@@ -618,4 +708,4 @@ removeEvent(ele, name, namespaces, selector, finalCallback); | ||
fn.on = on; | ||
function one(eventFullName, selector, callback) { | ||
return this.on(eventFullName, selector, callback, true); | ||
function one(eventFullName, selector, data, callback) { | ||
return this.on(eventFullName, selector, data, callback, true); | ||
} | ||
@@ -625,7 +715,8 @@ ; | ||
fn.ready = function (callback) { | ||
const cb = () => attempt(callback, cash); | ||
if (doc.readyState !== 'loading') { | ||
callback(cash); | ||
cb(); | ||
} | ||
else { | ||
doc.addEventListener('DOMContentLoaded', () => { callback(cash); }); | ||
doc.addEventListener('DOMContentLoaded', cb); | ||
} | ||
@@ -636,3 +727,6 @@ return this; | ||
if (isString(event)) { | ||
const [name, namespaces] = parseEventName(event), type = eventsMouseRe.test(name) ? 'MouseEvents' : 'HTMLEvents'; | ||
const [name, namespaces] = parseEventName(event); | ||
if (!name) | ||
return this; | ||
const type = eventsMouseRe.test(name) ? 'MouseEvents' : 'HTMLEvents'; | ||
event = doc.createEvent(type); | ||
@@ -642,3 +736,3 @@ event.initEvent(name, true, true); | ||
} | ||
event.data = data; | ||
event.___td = data; | ||
const isEventFocus = (event.type in eventsFocus); | ||
@@ -666,5 +760,5 @@ return this.each((i, ele) => { | ||
} | ||
const queryEncodeSpaceRe = /%20/g; | ||
const queryEncodeSpaceRe = /%20/g, queryEncodeCRLFRe = /\r?\n/g; | ||
function queryEncode(prop, value) { | ||
return `&${encodeURIComponent(prop)}=${encodeURIComponent(value).replace(queryEncodeSpaceRe, '+')}`; | ||
return `&${encodeURIComponent(prop)}=${encodeURIComponent(value.replace(queryEncodeCRLFRe, '\r\n')).replace(queryEncodeSpaceRe, '+')}`; | ||
} | ||
@@ -690,13 +784,19 @@ const skippableRe = /file|reset|submit|button|image/i, checkableRe = /radio|checkbox/i; | ||
function val(value) { | ||
if (isUndefined(value)) | ||
if (!arguments.length) | ||
return this[0] && getValue(this[0]); | ||
return this.each((i, ele) => { | ||
if (ele.tagName === 'SELECT') { | ||
const eleValue = isArray(value) ? value : (isNull(value) ? [] : [value]); | ||
each(ele.options, (i, option) => { | ||
option.selected = eleValue.indexOf(option.value) >= 0; | ||
}); | ||
const isSelect = ele.multiple && ele.options; | ||
if (isSelect || checkableRe.test(ele.type)) { | ||
const eleValue = isArray(value) ? map.call(value, String) : (isNull(value) ? [] : [String(value)]); | ||
if (isSelect) { | ||
each(ele.options, (i, option) => { | ||
option.selected = eleValue.indexOf(option.value) >= 0; | ||
}, true); | ||
} | ||
else { | ||
ele.checked = eleValue.indexOf(ele.value) >= 0; | ||
} | ||
} | ||
else { | ||
ele.value = isNull(value) ? '' : value; | ||
ele.value = isUndefined(value) || isNull(value) ? '' : value; | ||
} | ||
@@ -709,4 +809,4 @@ }); | ||
}; | ||
fn.detach = function () { | ||
return this.each((i, ele) => { | ||
fn.detach = function (comparator) { | ||
filtered(this, comparator).each((i, ele) => { | ||
if (ele.parentNode) { | ||
@@ -716,4 +816,5 @@ ele.parentNode.removeChild(ele); | ||
}); | ||
return this; | ||
}; | ||
const fragmentRe = /^\s*<(\w+)[^>]*>/, singleTagRe = /^\s*<(\w+)\s*\/?>(?:<\/\1>)?\s*$/; | ||
const fragmentRe = /^\s*<(\w+)[^>]*>/, singleTagRe = /^<(\w+)\s*\/?>(?:<\/\1>)?$/; | ||
const containers = { | ||
@@ -728,2 +829,4 @@ '*': div, | ||
}; | ||
//TODO: Create elements inside a document fragment, in order to prevent inline event handlers from firing | ||
//TODO: Ensure the created elements have the fragment as their parent instead of null, this also ensures we can deal with detatched nodes more reliably | ||
function parseHTML(html) { | ||
@@ -747,9 +850,16 @@ if (!isString(html)) | ||
function html(html) { | ||
if (!arguments.length) | ||
return this[0] && this[0].innerHTML; | ||
if (isUndefined(html)) | ||
return this[0] && this[0].innerHTML; | ||
return this.each((i, ele) => { ele.innerHTML = html; }); | ||
return this; | ||
return this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
ele.innerHTML = html; | ||
}); | ||
} | ||
fn.html = html; | ||
fn.remove = function () { | ||
return this.detach().off(); | ||
fn.remove = function (comparator) { | ||
filtered(this, comparator).detach().off(); | ||
return this; | ||
}; | ||
@@ -759,3 +869,7 @@ function text(text) { | ||
return this[0] ? this[0].textContent : ''; | ||
return this.each((i, ele) => { ele.textContent = text; }); | ||
return this.each((i, ele) => { | ||
if (!isElement(ele)) | ||
return; | ||
ele.textContent = text; | ||
}); | ||
} | ||
@@ -766,2 +880,4 @@ ; | ||
this.parent().each((i, ele) => { | ||
if (ele.tagName === 'BODY') | ||
return; | ||
const $ele = cash(ele); | ||
@@ -778,8 +894,14 @@ $ele.replaceWith($ele.children()); | ||
return { | ||
top: rect.top + win.pageYOffset - docEle.clientTop, | ||
left: rect.left + win.pageXOffset - docEle.clientLeft | ||
top: rect.top + win.pageYOffset, | ||
left: rect.left + win.pageXOffset | ||
}; | ||
}; | ||
fn.offsetParent = function () { | ||
return cash(this[0] && this[0].offsetParent); | ||
return this.map((i, ele) => { | ||
let offsetParent = ele.offsetParent; | ||
while (offsetParent && computeStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.offsetParent; | ||
} | ||
return offsetParent || docEle; | ||
}); | ||
}; | ||
@@ -790,5 +912,18 @@ fn.position = function () { | ||
return; | ||
const isFixed = (computeStyle(ele, 'position') === 'fixed'), offset = isFixed ? ele.getBoundingClientRect() : this.offset(); | ||
if (!isFixed) { | ||
const doc = ele.ownerDocument; | ||
let offsetParent = ele.offsetParent || doc.documentElement; | ||
while ((offsetParent === doc.body || offsetParent === doc.documentElement) && computeStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.parentNode; | ||
} | ||
if (offsetParent !== ele && isElement(offsetParent)) { | ||
const parentOffset = cash(offsetParent).offset(); | ||
offset.top -= parentOffset.top + computeStyleInt(offsetParent, 'borderTopWidth'); | ||
offset.left -= parentOffset.left + computeStyleInt(offsetParent, 'borderLeftWidth'); | ||
} | ||
} | ||
return { | ||
left: ele.offsetLeft, | ||
top: ele.offsetTop | ||
top: offset.top - computeStyleInt(ele, 'marginTop'), | ||
left: offset.left - computeStyleInt(ele, 'marginLeft') | ||
}; | ||
@@ -800,3 +935,3 @@ }; | ||
fn.contents = function () { | ||
return cash(unique(pluck(this, ele => ele.tagName === 'IFRAME' ? [ele.contentDocument] : ele.childNodes))); | ||
return cash(unique(pluck(this, ele => ele.tagName === 'IFRAME' ? [ele.contentDocument] : (ele.tagName === 'TEMPLATE' ? ele.content.childNodes : ele.childNodes)))); | ||
}; | ||
@@ -826,10 +961,12 @@ fn.find = function (selector) { | ||
// @require ./eval_scripts.ts | ||
function insertElement(anchor, target, left, inside) { | ||
function insertElement(anchor, target, left, inside, evaluate) { | ||
if (inside) { // prepend/append | ||
anchor.insertBefore(target, left ? anchor.firstElementChild : null); | ||
anchor.insertBefore(target, left ? anchor.firstChild : null); | ||
} | ||
else { // before/after | ||
anchor.parentNode.insertBefore(target, left ? anchor : anchor.nextElementSibling); | ||
anchor.parentNode.insertBefore(target, left ? anchor : anchor.nextSibling); | ||
} | ||
evalScripts(target, anchor.ownerDocument); | ||
if (evaluate) { | ||
evalScripts(target, anchor.ownerDocument); | ||
} | ||
} | ||
@@ -841,4 +978,4 @@ // @require ./insert_element.ts | ||
each(cash(anchors), (ai, anchor) => { | ||
const anchorFinal = inverse ? target : anchor, targetFinal = inverse ? anchor : target; | ||
insertElement(anchorFinal, !ai ? targetFinal : targetFinal.cloneNode(true), left, inside); | ||
const anchorFinal = inverse ? target : anchor, targetFinal = inverse ? anchor : target, indexFinal = inverse ? ti : ai; | ||
insertElement(anchorFinal, !indexFinal ? targetFinal : targetFinal.cloneNode(true), left, inside, !indexFinal); | ||
}, reverseLoop3); | ||
@@ -909,4 +1046,4 @@ }, reverseLoop2); | ||
}; | ||
fn.next = function (comparator, _all) { | ||
return filtered(cash(unique(pluck(this, 'nextElementSibling', _all))), comparator); | ||
fn.next = function (comparator, _all, _until) { | ||
return filtered(cash(unique(pluck(this, 'nextElementSibling', _all, _until))), comparator); | ||
}; | ||
@@ -916,5 +1053,8 @@ fn.nextAll = function (comparator) { | ||
}; | ||
fn.nextUntil = function (until, comparator) { | ||
return this.next(comparator, true, until); | ||
}; | ||
fn.not = function (comparator) { | ||
const compare = getCompareFunction(comparator); | ||
return this.filter((i, ele) => !compare.call(ele, i, ele)); | ||
return this.filter((i, ele) => (!isString(comparator) || isElement(ele)) && !compare.call(ele, i, ele)); | ||
}; | ||
@@ -937,11 +1077,17 @@ fn.parent = function (comparator) { | ||
}; | ||
fn.parents = function (comparator) { | ||
return filtered(cash(unique(pluck(this, 'parentElement', true))), comparator); | ||
fn.parents = function (comparator, _until) { | ||
return filtered(cash(unique(pluck(this, 'parentElement', true, _until))), comparator); | ||
}; | ||
fn.prev = function (comparator, _all) { | ||
return filtered(cash(unique(pluck(this, 'previousElementSibling', _all))), comparator); | ||
fn.parentsUntil = function (until, comparator) { | ||
return this.parents(comparator, until); | ||
}; | ||
fn.prev = function (comparator, _all, _until) { | ||
return filtered(cash(unique(pluck(this, 'previousElementSibling', _all, _until))), comparator); | ||
}; | ||
fn.prevAll = function (comparator) { | ||
return this.prev(comparator, true); | ||
}; | ||
fn.prevUntil = function (until, comparator) { | ||
return this.prev(comparator, true, until); | ||
}; | ||
fn.siblings = function (comparator) { | ||
@@ -957,6 +1103,11 @@ return filtered(cash(unique(pluck(this, ele => cash(ele).parent().children().not(ele)))), comparator); | ||
// @optional ./next.ts | ||
// @optional ./next_all.ts | ||
// @optional ./next_until.ts | ||
// @optional ./not.ts | ||
// @optional ./parent.ts | ||
// @optional ./parents.ts | ||
// @optional ./parents_until.ts | ||
// @optional ./prev.ts | ||
// @optional ./prev_all.ts | ||
// @optional ./prev_until.ts | ||
// @optional ./siblings.ts | ||
@@ -963,0 +1114,0 @@ // @optional attributes/index.ts |
360
dist/cash.js
@@ -5,2 +5,31 @@ /* MIT https://github.com/kenwheeler/cash */ | ||
var propMap = { | ||
/* GENERAL */ | ||
"class": 'className', | ||
contenteditable: 'contentEditable', | ||
/* LABEL */ | ||
"for": 'htmlFor', | ||
/* INPUT */ | ||
readonly: 'readOnly', | ||
maxlength: 'maxLength', | ||
tabindex: 'tabIndex', | ||
/* TABLE */ | ||
colspan: 'colSpan', | ||
rowspan: 'rowSpan', | ||
/* IMAGE */ | ||
usemap: 'useMap' | ||
}; | ||
function attempt(fn, arg) { | ||
try { | ||
return fn(arg); | ||
} catch (_a) { | ||
return arg; | ||
} | ||
} | ||
var doc = document, | ||
@@ -15,10 +44,11 @@ win = window, | ||
isArray = Array.isArray, | ||
ArrayProtoType = Array.prototype, | ||
filter = ArrayProtoType.filter, | ||
indexOf = ArrayProtoType.indexOf, | ||
map = ArrayProtoType.map, | ||
push = ArrayProtoType.push, | ||
slice = ArrayProtoType.slice, | ||
some = ArrayProtoType.some, | ||
splice = ArrayProtoType.splice; | ||
ArrayPrototype = Array.prototype, | ||
concat = ArrayPrototype.concat, | ||
filter = ArrayPrototype.filter, | ||
indexOf = ArrayPrototype.indexOf, | ||
map = ArrayPrototype.map, | ||
push = ArrayPrototype.push, | ||
slice = ArrayPrototype.slice, | ||
some = ArrayPrototype.some, | ||
splice = ArrayPrototype.splice; | ||
var idRe = /^#[\w-]*$/, | ||
@@ -30,7 +60,3 @@ classRe = /^\.[\w-]*$/, | ||
function find(selector, context) { | ||
if (context === void 0) { | ||
context = doc; | ||
} | ||
return !isDocument(context) && !isElement(context) ? [] : classRe.test(selector) ? context.getElementsByClassName(selector.slice(1)) : tagRe.test(selector) ? context.getElementsByTagName(selector) : context.querySelectorAll(selector); | ||
return !selector || !isDocument(context) && !isElement(context) ? [] : classRe.test(selector) ? context.getElementsByClassName(selector.slice(1)) : tagRe.test(selector) ? context.getElementsByTagName(selector) : context.querySelectorAll(selector); | ||
} // @require ./find.ts | ||
@@ -44,6 +70,2 @@ // @require ./variables.ts | ||
function Cash(selector, context) { | ||
if (context === void 0) { | ||
context = doc; | ||
} | ||
if (!selector) return; | ||
@@ -54,3 +76,3 @@ if (isCash(selector)) return selector; | ||
if (isString(selector)) { | ||
var ctx = isCash(context) ? context[0] : context; | ||
var ctx = (isCash(context) ? context[0] : context) || doc; | ||
eles = idRe.test(selector) ? ctx.getElementById(selector.slice(1)) : htmlRe.test(selector) ? parseHTML(selector) : find(selector, ctx); | ||
@@ -86,9 +108,9 @@ if (!eles) return; | ||
// Ensuring a cash collection is iterable | ||
fn[Symbol['iterator']] = ArrayProtoType[Symbol['iterator']]; | ||
fn[Symbol['iterator']] = ArrayPrototype[Symbol['iterator']]; | ||
} | ||
fn.map = function (callback) { | ||
return cash(map.call(this, function (ele, i) { | ||
return cash(concat.apply([], map.call(this, function (ele, i) { | ||
return callback.call(ele, i, ele); | ||
})); | ||
}))); | ||
}; | ||
@@ -98,4 +120,5 @@ | ||
return cash(slice.call(this, start, end)); | ||
}; | ||
}; // @require ./cash.ts | ||
var dashAlphaRe = /-([a-z])/g; | ||
@@ -109,6 +132,4 @@ | ||
cash.camelCase = camelCase; | ||
function each(arr, callback, reverse) { | ||
if (reverse) { | ||
function each(arr, callback, _reverse) { | ||
if (_reverse) { | ||
var i = arr.length; | ||
@@ -136,7 +157,7 @@ | ||
return this.each(function (i, ele) { | ||
delete ele[prop]; | ||
delete ele[propMap[prop] || prop]; | ||
}); | ||
}; | ||
cash.extend = function (target) { | ||
function extend(target) { | ||
var objs = []; | ||
@@ -149,4 +170,6 @@ | ||
var length = arguments.length; | ||
if (!length) return {}; | ||
if (length === 1) return extend(cash, target); | ||
for (var i = length < 2 ? 0 : 1; i < length; i++) { | ||
for (var i = 1; i < length; i++) { | ||
for (var key in arguments[i]) { | ||
@@ -158,17 +181,17 @@ target[key] = arguments[i][key]; | ||
return target; | ||
}; | ||
} | ||
cash.extend = extend; | ||
fn.extend = function (plugins) { | ||
return cash.extend(fn, plugins); | ||
return extend(fn, plugins); | ||
}; | ||
cash.guid = 1; | ||
cash.guid = 1; // @require ./cash.ts | ||
function matches(ele, selector) { | ||
var matches = ele && (ele['matches'] || ele['webkitMatchesSelector'] || ele['msMatchesSelector']); | ||
return !!matches && matches.call(ele, selector); | ||
return !!matches && !!selector && matches.call(ele, selector); | ||
} | ||
cash.matches = matches; | ||
function isCash(x) { | ||
@@ -212,3 +235,2 @@ return x instanceof Cash; | ||
cash.isFunction = isFunction; | ||
cash.isString = isString; | ||
cash.isNumeric = isNumeric; | ||
@@ -221,2 +243,3 @@ cash.isArray = isArray; | ||
if (isString(prop)) { | ||
prop = propMap[prop] || prop; | ||
if (arguments.length < 2) return this[0] && this[0][prop]; | ||
@@ -237,2 +260,3 @@ return this.each(function (i, ele) { | ||
if (isUndefined(index)) return slice.call(this); | ||
index = Number(index); | ||
return this[index < 0 ? index + this.length : index]; | ||
@@ -288,3 +312,3 @@ }; | ||
return !!cls && some.call(this, function (ele) { | ||
return ele.classList.contains(cls); | ||
return isElement(ele) && ele.classList.contains(cls); | ||
}); | ||
@@ -296,2 +320,3 @@ }; | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
each(attrs, function (i, a) { | ||
@@ -308,3 +333,3 @@ ele.removeAttribute(a); | ||
if (arguments.length < 2) { | ||
if (!this[0]) return; | ||
if (!this[0] || !isElement(this[0])) return; | ||
var value_1 = this[0].getAttribute(attr); | ||
@@ -317,2 +342,3 @@ return isNull(value_1) ? undefined : value_1; | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
ele.setAttribute(attr, value); | ||
@@ -335,2 +361,3 @@ }); | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
each(classes, function (i, c) { | ||
@@ -355,5 +382,6 @@ if (isForce) { | ||
function pluck(arr, prop, deep) { | ||
function pluck(arr, prop, deep, until) { | ||
var plucked = [], | ||
isCallback = isFunction(prop); | ||
isCallback = isFunction(prop), | ||
compare = until && getCompareFunction(until); | ||
@@ -368,2 +396,3 @@ for (var i = 0, l = arr.length; i < l; i++) { | ||
while (val_2 != null) { | ||
if (until && compare(-1, val_2)) break; | ||
plucked.push(val_2); | ||
@@ -393,5 +422,5 @@ val_2 = deep ? val_2[prop] : null; | ||
function computeStyle(ele, prop, isVariable) { | ||
if (!isElement(ele) || !prop) return; | ||
if (!isElement(ele)) return; | ||
var style = win.getComputedStyle(ele, null); | ||
return prop ? isVariable ? style.getPropertyValue(prop) || undefined : style[prop] : style; | ||
return isVariable ? style.getPropertyValue(prop) || undefined : style[prop]; | ||
} // @require ./compute_style.ts | ||
@@ -408,4 +437,9 @@ | ||
return cssVariableRe.test(prop); | ||
} | ||
} // @require core/camel_case.ts | ||
// @require core/cash.ts | ||
// @require core/each.ts | ||
// @require core/variables.ts | ||
// @require ./is_css_variable.ts | ||
var prefixedProps = {}, | ||
@@ -437,4 +471,3 @@ style = div.style, | ||
; | ||
cash.prefixedProp = getPrefixedProp; // @require core/type_checking.ts | ||
; // @require core/type_checking.ts | ||
// @require ./is_css_variable.ts | ||
@@ -448,2 +481,9 @@ | ||
fontWeight: true, | ||
gridArea: true, | ||
gridColumn: true, | ||
gridColumnEnd: true, | ||
gridColumnStart: true, | ||
gridRow: true, | ||
gridRowEnd: true, | ||
gridRowStart: true, | ||
lineHeight: true, | ||
@@ -492,20 +532,17 @@ opacity: true, | ||
fn.css = css; // @optional ./css.ts | ||
// @require core/attempt.ts | ||
// @require core/camel_case.ts | ||
var JSONStringRe = /^\s+|\s+$/; | ||
function getData(ele, key) { | ||
var value = ele.dataset[key] || ele.dataset[camelCase(key)]; | ||
if (JSONStringRe.test(value)) return value; | ||
return attempt(JSON.parse, value); | ||
} // @require core/attempt.ts | ||
// @require core/camel_case.ts | ||
try { | ||
return JSON.parse(value); | ||
} catch (_a) {} | ||
return value; | ||
} // @require core/camel_case.ts | ||
function setData(ele, key, value) { | ||
try { | ||
value = JSON.stringify(value); | ||
} catch (_a) {} | ||
value = attempt(JSON.stringify, value); | ||
ele.dataset[camelCase(key)] = value; | ||
@@ -528,2 +565,3 @@ } | ||
if (arguments.length < 2) return this[0] && getData(this[0], name); | ||
if (isUndefined(value)) return this; | ||
return this.each(function (i, ele) { | ||
@@ -542,4 +580,9 @@ setData(ele, name, value); | ||
fn.data = data; // @optional ./data.ts | ||
// @require css/helpers/compute_style_int.ts | ||
function getDocumentDimension(doc, dimension) { | ||
var docEle = doc.documentElement; | ||
return Math.max(doc.body["scroll" + dimension], docEle["scroll" + dimension], doc.body["offset" + dimension], docEle["offset" + dimension], docEle["client" + dimension]); | ||
} // @require css/helpers/compute_style_int.ts | ||
function getExtraSpace(ele, xAxis) { | ||
@@ -555,3 +598,4 @@ 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"); | ||
if (!this[0]) return; | ||
if (isWindow(this[0])) return win[name]; | ||
if (isWindow(this[0])) return outer ? this[0]["inner" + prop] : this[0].document.documentElement["client" + prop]; | ||
if (isDocument(this[0])) return getDocumentDimension(this[0], prop); | ||
return this[0]["" + (outer ? 'offset' : 'client') + prop] + (includeMargins && outer ? computeStyleInt(this[0], "margin" + (i ? 'Top' : 'Left')) + computeStyleInt(this[0], "margin" + (i ? 'Bottom' : 'Right')) : 0); | ||
@@ -561,9 +605,12 @@ }; | ||
}); | ||
each(['width', 'height'], function (index, prop) { | ||
fn[prop] = function (value) { | ||
each(['Width', 'Height'], function (index, prop) { | ||
var propLC = prop.toLowerCase(); | ||
fn[propLC] = function (value) { | ||
if (!this[0]) return isUndefined(value) ? undefined : this; | ||
if (!arguments.length) { | ||
if (isWindow(this[0])) return this[0][camelCase("outer-" + prop)]; | ||
return this[0].getBoundingClientRect()[prop] - getExtraSpace(this[0], !index); | ||
if (isWindow(this[0])) return this[0].document.documentElement["client" + prop]; | ||
if (isDocument(this[0])) return getDocumentDimension(this[0], prop); | ||
return this[0].getBoundingClientRect()[propLC] - getExtraSpace(this[0], !index); | ||
} | ||
@@ -575,3 +622,3 @@ | ||
var boxSizing = computeStyle(ele, 'boxSizing'); | ||
ele.style[prop] = getSuffixedValue(prop, valueNumber + (boxSizing === 'border-box' ? getExtraSpace(ele, !index) : 0)); | ||
ele.style[propLC] = getSuffixedValue(propLC, valueNumber + (boxSizing === 'border-box' ? getExtraSpace(ele, !index) : 0)); | ||
}); | ||
@@ -603,2 +650,3 @@ }; | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
var show = isUndefined(force) ? isHidden(ele) : force; | ||
@@ -660,3 +708,2 @@ | ||
function addEvent(ele, name, namespaces, selector, callback) { | ||
callback.guid = callback.guid || cash.guid++; | ||
var eventCache = getEventsCache(ele); | ||
@@ -700,2 +747,3 @@ eventCache[name] = eventCache[name] || []; | ||
this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
removeEvent(ele); | ||
@@ -719,2 +767,3 @@ }); | ||
_this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
removeEvent(ele, name, namespaces, selector, callback); | ||
@@ -728,3 +777,3 @@ }); | ||
function on(eventFullName, selector, callback, _one) { | ||
function on(eventFullName, selector, data, callback, _one) { | ||
var _this = this; | ||
@@ -734,3 +783,3 @@ | ||
for (var key in eventFullName) { | ||
this.on(key, selector, eventFullName[key]); | ||
this.on(key, selector, data, eventFullName[key], _one); | ||
} | ||
@@ -741,7 +790,21 @@ | ||
if (isFunction(selector)) { | ||
callback = selector; | ||
selector = ''; | ||
if (!isString(selector)) { | ||
if (isUndefined(selector) || isNull(selector)) { | ||
selector = ''; | ||
} else if (isUndefined(data)) { | ||
data = selector; | ||
selector = ''; | ||
} else { | ||
callback = data; | ||
data = selector; | ||
selector = ''; | ||
} | ||
} | ||
if (!isFunction(callback)) { | ||
callback = data; | ||
data = undefined; | ||
} | ||
if (!callback) return this; | ||
each(getSplitValues(eventFullName), function (i, eventFullName) { | ||
@@ -752,3 +815,7 @@ var _a = parseEventName(getEventNameBubbling(eventFullName)), | ||
if (!name) return; | ||
_this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
var finalCallback = function finalCallback(event) { | ||
@@ -780,3 +847,4 @@ if (event.namespace && !hasNamespaces(namespaces, event.namespace.split(eventsNamespacesSeparator))) return; | ||
var returnValue = callback.call(thisArg, event, event.data); | ||
event.data = data; | ||
var returnValue = callback.call(thisArg, event, event.___td); | ||
@@ -802,4 +870,4 @@ if (_one) { | ||
function one(eventFullName, selector, callback) { | ||
return this.on(eventFullName, selector, callback, true); | ||
function one(eventFullName, selector, data, callback) { | ||
return this.on(eventFullName, selector, data, callback, true); | ||
} | ||
@@ -811,8 +879,10 @@ | ||
fn.ready = function (callback) { | ||
var cb = function cb() { | ||
return attempt(callback, cash); | ||
}; | ||
if (doc.readyState !== 'loading') { | ||
callback(cash); | ||
cb(); | ||
} else { | ||
doc.addEventListener('DOMContentLoaded', function () { | ||
callback(cash); | ||
}); | ||
doc.addEventListener('DOMContentLoaded', cb); | ||
} | ||
@@ -827,5 +897,6 @@ | ||
name_1 = _a[0], | ||
namespaces = _a[1], | ||
type = eventsMouseRe.test(name_1) ? 'MouseEvents' : 'HTMLEvents'; | ||
namespaces = _a[1]; | ||
if (!name_1) return this; | ||
var type = eventsMouseRe.test(name_1) ? 'MouseEvents' : 'HTMLEvents'; | ||
event = doc.createEvent(type); | ||
@@ -836,3 +907,3 @@ event.initEvent(name_1, true, true); | ||
event.data = data; | ||
event.___td = data; | ||
var isEventFocus = event.type in eventsFocus; | ||
@@ -862,6 +933,7 @@ return this.each(function (i, ele) { | ||
var queryEncodeSpaceRe = /%20/g; | ||
var queryEncodeSpaceRe = /%20/g, | ||
queryEncodeCRLFRe = /\r?\n/g; | ||
function queryEncode(prop, value) { | ||
return "&" + encodeURIComponent(prop) + "=" + encodeURIComponent(value).replace(queryEncodeSpaceRe, '+'); | ||
return "&" + encodeURIComponent(prop) + "=" + encodeURIComponent(value.replace(queryEncodeCRLFRe, '\r\n')).replace(queryEncodeSpaceRe, '+'); | ||
} | ||
@@ -891,11 +963,18 @@ | ||
function val(value) { | ||
if (isUndefined(value)) return this[0] && getValue(this[0]); | ||
if (!arguments.length) return this[0] && getValue(this[0]); | ||
return this.each(function (i, ele) { | ||
if (ele.tagName === 'SELECT') { | ||
var eleValue_1 = isArray(value) ? value : isNull(value) ? [] : [value]; | ||
each(ele.options, function (i, option) { | ||
option.selected = eleValue_1.indexOf(option.value) >= 0; | ||
}); | ||
var isSelect = ele.multiple && ele.options; | ||
if (isSelect || checkableRe.test(ele.type)) { | ||
var eleValue_1 = isArray(value) ? map.call(value, String) : isNull(value) ? [] : [String(value)]; | ||
if (isSelect) { | ||
each(ele.options, function (i, option) { | ||
option.selected = eleValue_1.indexOf(option.value) >= 0; | ||
}, true); | ||
} else { | ||
ele.checked = eleValue_1.indexOf(ele.value) >= 0; | ||
} | ||
} else { | ||
ele.value = isNull(value) ? '' : value; | ||
ele.value = isUndefined(value) || isNull(value) ? '' : value; | ||
} | ||
@@ -913,4 +992,4 @@ }); | ||
fn.detach = function () { | ||
return this.each(function (i, ele) { | ||
fn.detach = function (comparator) { | ||
filtered(this, comparator).each(function (i, ele) { | ||
if (ele.parentNode) { | ||
@@ -920,6 +999,7 @@ ele.parentNode.removeChild(ele); | ||
}); | ||
return this; | ||
}; | ||
var fragmentRe = /^\s*<(\w+)[^>]*>/, | ||
singleTagRe = /^\s*<(\w+)\s*\/?>(?:<\/\1>)?\s*$/; | ||
singleTagRe = /^<(\w+)\s*\/?>(?:<\/\1>)?$/; | ||
var containers = { | ||
@@ -933,3 +1013,4 @@ '*': div, | ||
tfoot: table | ||
}; | ||
}; //TODO: Create elements inside a document fragment, in order to prevent inline event handlers from firing | ||
//TODO: Ensure the created elements have the fragment as their parent instead of null, this also ensures we can deal with detatched nodes more reliably | ||
@@ -956,4 +1037,6 @@ function parseHTML(html) { | ||
function html(html) { | ||
if (isUndefined(html)) return this[0] && this[0].innerHTML; | ||
if (!arguments.length) return this[0] && this[0].innerHTML; | ||
if (isUndefined(html)) return this; | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
ele.innerHTML = html; | ||
@@ -965,4 +1048,5 @@ }); | ||
fn.remove = function () { | ||
return this.detach().off(); | ||
fn.remove = function (comparator) { | ||
filtered(this, comparator).detach().off(); | ||
return this; | ||
}; | ||
@@ -973,2 +1057,3 @@ | ||
return this.each(function (i, ele) { | ||
if (!isElement(ele)) return; | ||
ele.textContent = text; | ||
@@ -983,2 +1068,3 @@ }); | ||
this.parent().each(function (i, ele) { | ||
if (ele.tagName === 'BODY') return; | ||
var $ele = cash(ele); | ||
@@ -995,4 +1081,4 @@ $ele.replaceWith($ele.children()); | ||
return { | ||
top: rect.top + win.pageYOffset - docEle.clientTop, | ||
left: rect.left + win.pageXOffset - docEle.clientLeft | ||
top: rect.top + win.pageYOffset, | ||
left: rect.left + win.pageXOffset | ||
}; | ||
@@ -1002,3 +1088,11 @@ }; | ||
fn.offsetParent = function () { | ||
return cash(this[0] && this[0].offsetParent); | ||
return this.map(function (i, ele) { | ||
var offsetParent = ele.offsetParent; | ||
while (offsetParent && computeStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.offsetParent; | ||
} | ||
return offsetParent || docEle; | ||
}); | ||
}; | ||
@@ -1009,5 +1103,23 @@ | ||
if (!ele) return; | ||
var isFixed = computeStyle(ele, 'position') === 'fixed', | ||
offset = isFixed ? ele.getBoundingClientRect() : this.offset(); | ||
if (!isFixed) { | ||
var doc_1 = ele.ownerDocument; | ||
var offsetParent = ele.offsetParent || doc_1.documentElement; | ||
while ((offsetParent === doc_1.body || offsetParent === doc_1.documentElement) && computeStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = offsetParent.parentNode; | ||
} | ||
if (offsetParent !== ele && isElement(offsetParent)) { | ||
var parentOffset = cash(offsetParent).offset(); | ||
offset.top -= parentOffset.top + computeStyleInt(offsetParent, 'borderTopWidth'); | ||
offset.left -= parentOffset.left + computeStyleInt(offsetParent, 'borderLeftWidth'); | ||
} | ||
} | ||
return { | ||
left: ele.offsetLeft, | ||
top: ele.offsetTop | ||
top: offset.top - computeStyleInt(ele, 'marginTop'), | ||
left: offset.left - computeStyleInt(ele, 'marginLeft') | ||
}; | ||
@@ -1024,3 +1136,3 @@ }; | ||
return cash(unique(pluck(this, function (ele) { | ||
return ele.tagName === 'IFRAME' ? [ele.contentDocument] : ele.childNodes; | ||
return ele.tagName === 'IFRAME' ? [ele.contentDocument] : ele.tagName === 'TEMPLATE' ? ele.content.childNodes : ele.childNodes; | ||
}))); | ||
@@ -1059,12 +1171,14 @@ }; | ||
function insertElement(anchor, target, left, inside) { | ||
function insertElement(anchor, target, left, inside, evaluate) { | ||
if (inside) { | ||
// prepend/append | ||
anchor.insertBefore(target, left ? anchor.firstElementChild : null); | ||
anchor.insertBefore(target, left ? anchor.firstChild : null); | ||
} else { | ||
// before/after | ||
anchor.parentNode.insertBefore(target, left ? anchor : anchor.nextElementSibling); | ||
anchor.parentNode.insertBefore(target, left ? anchor : anchor.nextSibling); | ||
} | ||
evalScripts(target, anchor.ownerDocument); | ||
if (evaluate) { | ||
evalScripts(target, anchor.ownerDocument); | ||
} | ||
} // @require ./insert_element.ts | ||
@@ -1078,4 +1192,5 @@ | ||
var anchorFinal = inverse ? target : anchor, | ||
targetFinal = inverse ? anchor : target; | ||
insertElement(anchorFinal, !ai ? targetFinal : targetFinal.cloneNode(true), left, inside); | ||
targetFinal = inverse ? anchor : target, | ||
indexFinal = inverse ? ti : ai; | ||
insertElement(anchorFinal, !indexFinal ? targetFinal : targetFinal.cloneNode(true), left, inside, !indexFinal); | ||
}, reverseLoop3); | ||
@@ -1171,4 +1286,4 @@ }, reverseLoop2); | ||
fn.next = function (comparator, _all) { | ||
return filtered(cash(unique(pluck(this, 'nextElementSibling', _all))), comparator); | ||
fn.next = function (comparator, _all, _until) { | ||
return filtered(cash(unique(pluck(this, 'nextElementSibling', _all, _until))), comparator); | ||
}; | ||
@@ -1180,6 +1295,10 @@ | ||
fn.nextUntil = function (until, comparator) { | ||
return this.next(comparator, true, until); | ||
}; | ||
fn.not = function (comparator) { | ||
var compare = getCompareFunction(comparator); | ||
return this.filter(function (i, ele) { | ||
return !compare.call(ele, i, ele); | ||
return (!isString(comparator) || isElement(ele)) && !compare.call(ele, i, ele); | ||
}); | ||
@@ -1206,10 +1325,14 @@ }; | ||
fn.parents = function (comparator) { | ||
return filtered(cash(unique(pluck(this, 'parentElement', true))), comparator); | ||
fn.parents = function (comparator, _until) { | ||
return filtered(cash(unique(pluck(this, 'parentElement', true, _until))), comparator); | ||
}; | ||
fn.prev = function (comparator, _all) { | ||
return filtered(cash(unique(pluck(this, 'previousElementSibling', _all))), comparator); | ||
fn.parentsUntil = function (until, comparator) { | ||
return this.parents(comparator, until); | ||
}; | ||
fn.prev = function (comparator, _all, _until) { | ||
return filtered(cash(unique(pluck(this, 'previousElementSibling', _all, _until))), comparator); | ||
}; | ||
fn.prevAll = function (comparator) { | ||
@@ -1219,2 +1342,6 @@ return this.prev(comparator, true); | ||
fn.prevUntil = function (until, comparator) { | ||
return this.prev(comparator, true, until); | ||
}; | ||
fn.siblings = function (comparator) { | ||
@@ -1231,6 +1358,11 @@ return filtered(cash(unique(pluck(this, function (ele) { | ||
// @optional ./next.ts | ||
// @optional ./next_all.ts | ||
// @optional ./next_until.ts | ||
// @optional ./not.ts | ||
// @optional ./parent.ts | ||
// @optional ./parents.ts | ||
// @optional ./parents_until.ts | ||
// @optional ./prev.ts | ||
// @optional ./prev_all.ts | ||
// @optional ./prev_until.ts | ||
// @optional ./siblings.ts | ||
@@ -1237,0 +1369,0 @@ // @optional attributes/index.ts |
/* MIT https://github.com/kenwheeler/cash */ | ||
(function(){ | ||
'use strict';var e=document,g=window,k=e.documentElement,m=e.createElement.bind(e),p=m("div"),q=m("table"),aa=m("tbody"),r=m("tr"),t=Array.isArray,v=Array.prototype,w=v.filter,x=v.indexOf,ba=v.map,ca=v.push,y=v.slice,z=v.some,da=v.splice,ea=/^#[\w-]*$/,fa=/^\.[\w-]*$/,ha=/<.+>/,ia=/^\w+$/;function A(a,b){void 0===b&&(b=e);return b&&9===b.nodeType||b&&1===b.nodeType?fa.test(a)?b.getElementsByClassName(a.slice(1)):ia.test(a)?b.getElementsByTagName(a):b.querySelectorAll(a):[]} | ||
var B=function(){function a(a,c){void 0===c&&(c=e);if(a){if(a instanceof B)return a;var b=a;if(C(a)){if(b=c instanceof B?c[0]:c,b=ea.test(a)?b.getElementById(a.slice(1)):ha.test(a)?D(a):A(a,b),!b)return}else if(E(a))return this.ready(a);if(b.nodeType||b===g)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}(),F=B.prototype,G=F.init;G.fn=G.prototype=F;F.length=0;F.splice=da; | ||
"function"===typeof Symbol&&(F[Symbol.iterator]=v[Symbol.iterator]);F.map=function(a){return G(ba.call(this,function(b,c){return a.call(b,c,b)}))};F.slice=function(a,b){return G(y.call(this,a,b))};var ja=/-([a-z])/g;function H(a){return a.replace(ja,function(a,c){return c.toUpperCase()})}G.camelCase=H;function I(a,b,c){if(c)for(c=a.length;c--&&!1!==b.call(a[c],c,a[c]););else{c=0;for(var d=a.length;c<d&&!1!==b.call(a[c],c,a[c]);c++);}return a}G.each=I;F.each=function(a){return I(this,a)}; | ||
F.removeProp=function(a){return this.each(function(b,c){delete c[a]})};G.extend=function(a){for(var b=1;b<arguments.length;b++);b=arguments.length;for(var c=2>b?0:1;c<b;c++)for(var d in arguments[c])a[d]=arguments[c][d];return a};F.extend=function(a){return G.extend(F,a)};G.guid=1;function J(a,b){var c=a&&(a.matches||a.webkitMatchesSelector||a.msMatchesSelector);return!!c&&c.call(a,b)}G.matches=J;function K(a){return!!a&&a===a.window}function E(a){return"function"===typeof a} | ||
function C(a){return"string"===typeof a}function L(a){return!isNaN(parseFloat(a))&&isFinite(a)}G.isWindow=K;G.isFunction=E;G.isString=C;G.isNumeric=L;G.isArray=t;F.prop=function(a,b){if(a){if(C(a))return 2>arguments.length?this[0]&&this[0][a]:this.each(function(c,h){h[a]=b});for(var c in a)this.prop(c,a[c]);return this}};F.get=function(a){return void 0===a?y.call(this):this[0>a?a+this.length:a]};F.eq=function(a){return G(this.get(a))};F.first=function(){return this.eq(0)};F.last=function(){return this.eq(-1)}; | ||
function M(a){return C(a)?function(b,c){return J(c,a)}:E(a)?a:a instanceof B?function(b,c){return a.is(c)}:a?function(b,c){return c===a}:function(){return!1}}F.filter=function(a){var b=M(a);return G(w.call(this,function(a,d){return b.call(a,d,a)}))};function N(a,b){return b?a.filter(b):a}var ka=/\S+/g;function O(a){return C(a)?a.match(ka)||[]:[]}F.hasClass=function(a){return!!a&&z.call(this,function(b){return b.classList.contains(a)})}; | ||
F.removeAttr=function(a){var b=O(a);return this.each(function(a,d){I(b,function(a,b){d.removeAttribute(b)})})};F.attr=function(a,b){if(a){if(C(a)){if(2>arguments.length){if(!this[0])return;var c=this[0].getAttribute(a);return null===c?void 0:c}return void 0===b?this:null===b?this.removeAttr(a):this.each(function(c,h){h.setAttribute(a,b)})}for(c in a)this.attr(c,a[c]);return this}}; | ||
F.toggleClass=function(a,b){var c=O(a),d=void 0!==b;return this.each(function(a,f){I(c,function(a,c){d?b?f.classList.add(c):f.classList.remove(c):f.classList.toggle(c)})})};F.addClass=function(a){return this.toggleClass(a,!0)};F.removeClass=function(a){return arguments.length?this.toggleClass(a,!1):this.attr("class","")};function P(a,b,c){for(var d=[],h=E(b),f=0,n=a.length;f<n;f++)if(h){var l=b(a[f]);l.length&&ca.apply(d,l)}else for(l=a[f][b];null!=l;)d.push(l),l=c?l[b]:null;return d} | ||
function Q(a){return 1<a.length?w.call(a,function(a,c,d){return x.call(d,a)===c}):a}G.unique=Q;F.add=function(a,b){return G(Q(this.get().concat(G(a,b).get())))};function R(a,b,c){if(a&&1===a.nodeType&&b)return a=g.getComputedStyle(a,null),b?c?a.getPropertyValue(b)||void 0:a[b]:a}function S(a,b){return parseInt(R(a,b),10)||0}var T=/^--/,U={},la=p.style,ma=["webkit","moz","ms"]; | ||
function na(a,b){void 0===b&&(b=T.test(a));if(b)return a;if(!U[a]){b=H(a);var c=""+b[0].toUpperCase()+b.slice(1);b=(b+" "+ma.join(c+" ")+c).split(" ");I(b,function(b,c){if(c in la)return U[a]=c,!1})}return U[a]}G.prefixedProp=na;var oa={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function pa(a,b,c){void 0===c&&(c=T.test(a));return c||oa[a]||!L(b)?b:b+"px"} | ||
F.css=function(a,b){if(C(a)){var c=T.test(a);a=na(a,c);if(2>arguments.length)return this[0]&&R(this[0],a,c);if(!a)return this;b=pa(a,b,c);return this.each(function(d,f){f&&1===f.nodeType&&(c?f.style.setProperty(a,b):f.style[a]=b)})}for(var d in a)this.css(d,a[d]);return this};function qa(a,b){a=a.dataset[b]||a.dataset[H(b)];try{return JSON.parse(a)}catch(c){}return a} | ||
F.data=function(a,b){if(!a){if(!this[0])return;var c={},d;for(d in this[0].dataset)c[d]=qa(this[0],d);return c}if(C(a))return 2>arguments.length?this[0]&&qa(this[0],a):this.each(function(c,d){c=b;try{c=JSON.stringify(c)}catch(n){}d.dataset[H(a)]=c});for(d in a)this.data(d,a[d]);return this};function ra(a,b){return S(a,"border"+(b?"Left":"Top")+"Width")+S(a,"padding"+(b?"Left":"Top"))+S(a,"padding"+(b?"Right":"Bottom"))+S(a,"border"+(b?"Right":"Bottom")+"Width")} | ||
I([!0,!1],function(a,b){I(["Width","Height"],function(a,d){var c=(b?"outer":"inner")+d;F[c]=function(f){if(this[0])return K(this[0])?g[c]:this[0][(b?"offset":"client")+d]+(f&&b?S(this[0],"margin"+(a?"Top":"Left"))+S(this[0],"margin"+(a?"Bottom":"Right")):0)}})}); | ||
I(["width","height"],function(a,b){F[b]=function(c){if(!this[0])return void 0===c?void 0:this;if(!arguments.length)return K(this[0])?this[0][H("outer-"+b)]:this[0].getBoundingClientRect()[b]-ra(this[0],!a);var d=parseInt(c,10);return this.each(function(c,f){f&&1===f.nodeType&&(c=R(f,"boxSizing"),f.style[b]=pa(b,d+("border-box"===c?ra(f,!a):0)))})}});var V={}; | ||
F.toggle=function(a){return this.each(function(b,c){if(void 0===a?"none"===R(c,"display"):a){if(c.style.display=c.___cd||"","none"===R(c,"display")){b=c.style;c=c.tagName;if(V[c])c=V[c];else{var d=m(c);e.body.insertBefore(d,null);var h=R(d,"display");e.body.removeChild(d);c=V[c]="none"!==h?h:"block"}b.display=c}}else c.___cd=R(c,"display"),c.style.display="none"})};F.hide=function(){return this.toggle(!1)};F.show=function(){return this.toggle(!0)}; | ||
function sa(a,b){return!b||!z.call(b,function(b){return 0>a.indexOf(b)})}var W={focus:"focusin",blur:"focusout"},ta={mouseenter:"mouseover",mouseleave:"mouseout"},ua=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function va(a,b,c,d,h){h.guid=h.guid||G.guid++;var f=a.___ce=a.___ce||{};f[b]=f[b]||[];f[b].push([c,d,h]);a.addEventListener(b,h)}function X(a){a=a.split(".");return[a[0],a.slice(1).sort()]} | ||
function Y(a,b,c,d,h){var f=a.___ce=a.___ce||{};if(b)f[b]&&(f[b]=f[b].filter(function(f){var n=f[0],ya=f[1];f=f[2];if(h&&f.guid!==h.guid||!sa(n,c)||d&&d!==ya)return!0;a.removeEventListener(b,f)}));else for(b in f)Y(a,b,c,d,h)}F.off=function(a,b,c){var d=this;if(void 0===a)this.each(function(a,b){Y(b)});else if(C(a))E(b)&&(c=b,b=""),I(O(a),function(a,h){a=X(ta[h]||W[h]||h);var f=a[0],n=a[1];d.each(function(a,d){Y(d,f,n,b,c)})});else for(var h in a)this.off(h,a[h]);return this}; | ||
F.on=function(a,b,c,d){var h=this;if(!C(a)){for(var f in a)this.on(f,b,a[f]);return this}E(b)&&(c=b,b="");I(O(a),function(a,f){a=X(ta[f]||W[f]||f);var n=a[0],l=a[1];h.each(function(a,f){a=function za(a){if(!a.namespace||sa(l,a.namespace.split("."))){var h=f;if(b){for(var u=a.target;!J(u,b);){if(u===f)return;u=u.parentNode;if(!u)return}h=u;a.___cd=!0}a.___cd&&Object.defineProperty(a,"currentTarget",{configurable:!0,get:function(){return h}});u=c.call(h,a,a.data);d&&Y(f,n,l,b,za);!1===u&&(a.preventDefault(), | ||
a.stopPropagation())}};a.guid=c.guid=c.guid||G.guid++;va(f,n,l,b,a)})});return this};F.one=function(a,b,c){return this.on(a,b,c,!0)};F.ready=function(a){"loading"!==e.readyState?a(G):e.addEventListener("DOMContentLoaded",function(){a(G)});return this}; | ||
F.trigger=function(a,b){if(C(a)){var c=X(a),d=c[0];c=c[1];var h=ua.test(d)?"MouseEvents":"HTMLEvents";a=e.createEvent(h);a.initEvent(d,!0,!0);a.namespace=c.join(".")}a.data=b;var f=a.type in W;return this.each(function(b,c){if(f&&E(c[a.type]))c[a.type]();else c.dispatchEvent(a)})};function wa(a){return a.multiple&&a.options?P(w.call(a.options,function(a){return a.selected&&!a.disabled&&!a.parentNode.disabled}),"value"):a.value||""}var xa=/%20/g,Aa=/file|reset|submit|button|image/i,Ba=/radio|checkbox/i; | ||
F.serialize=function(){var a="";this.each(function(b,c){I(c.elements||[c],function(b,c){c.disabled||!c.name||"FIELDSET"===c.tagName||Aa.test(c.type)||Ba.test(c.type)&&!c.checked||(b=wa(c),void 0!==b&&(b=t(b)?b:[b],I(b,function(b,d){b=a;d="&"+encodeURIComponent(c.name)+"="+encodeURIComponent(d).replace(xa,"+");a=b+d})))})});return a.slice(1)}; | ||
F.val=function(a){return void 0===a?this[0]&&wa(this[0]):this.each(function(b,c){if("SELECT"===c.tagName){var d=t(a)?a:null===a?[]:[a];I(c.options,function(a,b){b.selected=0<=d.indexOf(b.value)})}else c.value=null===a?"":a})};F.clone=function(){return this.map(function(a,b){return b.cloneNode(!0)})};F.detach=function(){return this.each(function(a,b){b.parentNode&&b.parentNode.removeChild(b)})}; | ||
var Ca=/^\s*<(\w+)[^>]*>/,Da=/^\s*<(\w+)\s*\/?>(?:<\/\1>)?\s*$/,Ea={"*":p,tr:aa,td:r,th:r,thead:q,tbody:q,tfoot:q};function D(a){if(!C(a))return[];if(Da.test(a))return[m(RegExp.$1)];var b=Ca.test(a)&&RegExp.$1;b=Ea[b]||Ea["*"];b.innerHTML=a;return G(b.childNodes).detach().get()}G.parseHTML=D;F.empty=function(){return this.each(function(a,b){for(;b.firstChild;)b.removeChild(b.firstChild)})};F.html=function(a){return void 0===a?this[0]&&this[0].innerHTML:this.each(function(b,c){c.innerHTML=a})}; | ||
F.remove=function(){return this.detach().off()};F.text=function(a){return void 0===a?this[0]?this[0].textContent:"":this.each(function(b,c){c.textContent=a})};F.unwrap=function(){this.parent().each(function(a,b){a=G(b);a.replaceWith(a.children())});return this};F.offset=function(){var a=this[0];if(a)return a=a.getBoundingClientRect(),{top:a.top+g.pageYOffset-k.clientTop,left:a.left+g.pageXOffset-k.clientLeft}};F.offsetParent=function(){return G(this[0]&&this[0].offsetParent)}; | ||
F.position=function(){var a=this[0];if(a)return{left:a.offsetLeft,top:a.offsetTop}};F.children=function(a){return N(G(Q(P(this,function(a){return a.children}))),a)};F.contents=function(){return G(Q(P(this,function(a){return"IFRAME"===a.tagName?[a.contentDocument]:a.childNodes})))};F.find=function(a){return G(Q(P(this,function(b){return A(a,b)})))};var Fa=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,Ga=/^$|^module$|\/(java|ecma)script/i,Ha=["type","src","nonce","noModule"]; | ||
function Ia(a,b){a=G(a);a.filter("script").add(a.find("script")).each(function(a,d){if(Ga.test(d.type)&&k.contains(d)){var c=m("script");c.text=d.textContent.replace(Fa,"");I(Ha,function(a,b){d[b]&&(c[b]=d[b])});b.head.insertBefore(c,null);b.head.removeChild(c)}})} | ||
function Z(a,b,c,d,h,f,n,l){I(a,function(a,f){I(G(f),function(a,f){I(G(b),function(a,b){var l=c?b:f;b=c?f:b;a=a?l.cloneNode(!0):l;h?b.insertBefore(a,d?b.firstElementChild:null):b.parentNode.insertBefore(a,d?b:b.nextElementSibling);Ia(a,b.ownerDocument)},l)},n)},f);return b}F.after=function(){return Z(arguments,this,!1,!1,!1,!0,!0)};F.append=function(){return Z(arguments,this,!1,!1,!0)};F.appendTo=function(a){return Z(arguments,this,!0,!1,!0)};F.before=function(){return Z(arguments,this,!1,!0)}; | ||
'use strict';var e={"class":"className",contenteditable:"contentEditable","for":"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};function g(a,b){try{return a(b)}catch(c){return b}} | ||
var m=document,n=window,p=m.documentElement,r=m.createElement.bind(m),aa=r("div"),t=r("table"),ba=r("tbody"),ca=r("tr"),u=Array.isArray,v=Array.prototype,da=v.concat,w=v.filter,ea=v.indexOf,fa=v.map,ha=v.push,ia=v.slice,x=v.some,ja=v.splice,ka=/^#[\w-]*$/,la=/^\.[\w-]*$/,ma=/<.+>/,na=/^\w+$/;function y(a,b){return a&&(A(b)||B(b))?la.test(a)?b.getElementsByClassName(a.slice(1)):na.test(a)?b.getElementsByTagName(a):b.querySelectorAll(a):[]} | ||
var C=function(){function a(a,c){if(a){if(a instanceof C)return a;var b=a;if(D(a)){if(b=(c instanceof C?c[0]:c)||m,b=ka.test(a)?b.getElementById(a.slice(1)):ma.test(a)?oa(a):y(a,b),!b)return}else if(E(a))return this.ready(a);if(b.nodeType||b===n)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}(),F=C.prototype,G=F.init;G.fn=G.prototype=F;F.length=0;F.splice=ja;"function"===typeof Symbol&&(F[Symbol.iterator]=v[Symbol.iterator]); | ||
F.map=function(a){return G(da.apply([],fa.call(this,function(b,c){return a.call(b,c,b)})))};F.slice=function(a,b){return G(ia.call(this,a,b))};var pa=/-([a-z])/g;function H(a){return a.replace(pa,function(a,c){return c.toUpperCase()})}function I(a,b,c){if(c)for(c=a.length;c--&&!1!==b.call(a[c],c,a[c]););else{c=0;for(var d=a.length;c<d&&!1!==b.call(a[c],c,a[c]);c++);}return a}G.each=I;F.each=function(a){return I(this,a)};F.removeProp=function(a){return this.each(function(b,c){delete c[e[a]||a]})}; | ||
function J(a){for(var b=1;b<arguments.length;b++);b=arguments.length;if(!b)return{};if(1===b)return J(G,a);for(var c=1;c<b;c++)for(var d in arguments[c])a[d]=arguments[c][d];return a}G.extend=J;F.extend=function(a){return J(F,a)};G.guid=1;function qa(a,b){var c=a&&(a.matches||a.webkitMatchesSelector||a.msMatchesSelector);return!!c&&!!b&&c.call(a,b)}function K(a){return!!a&&a===a.window}function A(a){return!!a&&9===a.nodeType}function B(a){return!!a&&1===a.nodeType} | ||
function E(a){return"function"===typeof a}function D(a){return"string"===typeof a}function ra(a){return!isNaN(parseFloat(a))&&isFinite(a)}G.isWindow=K;G.isFunction=E;G.isNumeric=ra;G.isArray=u;F.prop=function(a,b){if(a){if(D(a))return a=e[a]||a,2>arguments.length?this[0]&&this[0][a]:this.each(function(c,h){h[a]=b});for(var c in a)this.prop(c,a[c]);return this}};F.get=function(a){if(void 0===a)return ia.call(this);a=Number(a);return this[0>a?a+this.length:a]};F.eq=function(a){return G(this.get(a))}; | ||
F.first=function(){return this.eq(0)};F.last=function(){return this.eq(-1)};function L(a){return D(a)?function(b,c){return qa(c,a)}:E(a)?a:a instanceof C?function(b,c){return a.is(c)}:a?function(b,c){return c===a}:function(){return!1}}F.filter=function(a){var b=L(a);return G(w.call(this,function(a,d){return b.call(a,d,a)}))};function M(a,b){return b?a.filter(b):a}var sa=/\S+/g;function N(a){return D(a)?a.match(sa)||[]:[]}F.hasClass=function(a){return!!a&&x.call(this,function(b){return B(b)&&b.classList.contains(a)})}; | ||
F.removeAttr=function(a){var b=N(a);return this.each(function(a,d){B(d)&&I(b,function(a,b){d.removeAttribute(b)})})};F.attr=function(a,b){if(a){if(D(a)){if(2>arguments.length){if(!this[0]||!B(this[0]))return;var c=this[0].getAttribute(a);return null===c?void 0:c}return void 0===b?this:null===b?this.removeAttr(a):this.each(function(c,h){B(h)&&h.setAttribute(a,b)})}for(c in a)this.attr(c,a[c]);return this}}; | ||
F.toggleClass=function(a,b){var c=N(a),d=void 0!==b;return this.each(function(a,f){B(f)&&I(c,function(a,c){d?b?f.classList.add(c):f.classList.remove(c):f.classList.toggle(c)})})};F.addClass=function(a){return this.toggleClass(a,!0)};F.removeClass=function(a){return arguments.length?this.toggleClass(a,!1):this.attr("class","")}; | ||
function O(a,b,c,d){for(var h=[],f=E(b),k=d&&L(d),q=0,S=a.length;q<S;q++)if(f){var l=b(a[q]);l.length&&ha.apply(h,l)}else for(l=a[q][b];!(null==l||d&&k(-1,l));)h.push(l),l=c?l[b]:null;return h}function P(a){return 1<a.length?w.call(a,function(a,c,d){return ea.call(d,a)===c}):a}G.unique=P;F.add=function(a,b){return G(P(this.get().concat(G(a,b).get())))};function Q(a,b,c){if(B(a))return a=n.getComputedStyle(a,null),c?a.getPropertyValue(b)||void 0:a[b]}function R(a,b){return parseInt(Q(a,b),10)||0} | ||
var T=/^--/,U={},ta=aa.style,ua=["webkit","moz","ms"];function va(a,b){void 0===b&&(b=T.test(a));if(b)return a;if(!U[a]){b=H(a);var c=""+b[0].toUpperCase()+b.slice(1);b=(b+" "+ua.join(c+" ")+c).split(" ");I(b,function(b,c){if(c in ta)return U[a]=c,!1})}return U[a]} | ||
var wa={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function xa(a,b,c){void 0===c&&(c=T.test(a));return c||wa[a]||!ra(b)?b:b+"px"} | ||
F.css=function(a,b){if(D(a)){var c=T.test(a);a=va(a,c);if(2>arguments.length)return this[0]&&Q(this[0],a,c);if(!a)return this;b=xa(a,b,c);return this.each(function(d,f){B(f)&&(c?f.style.setProperty(a,b):f.style[a]=b)})}for(var d in a)this.css(d,a[d]);return this};var ya=/^\s+|\s+$/;function za(a,b){a=a.dataset[b]||a.dataset[H(b)];return ya.test(a)?a:g(JSON.parse,a)} | ||
F.data=function(a,b){if(!a){if(!this[0])return;var c={},d;for(d in this[0].dataset)c[d]=za(this[0],d);return c}if(D(a))return 2>arguments.length?this[0]&&za(this[0],a):void 0===b?this:this.each(function(c,d){c=b;c=g(JSON.stringify,c);d.dataset[H(a)]=c});for(d in a)this.data(d,a[d]);return this};function Aa(a,b){var c=a.documentElement;return Math.max(a.body["scroll"+b],c["scroll"+b],a.body["offset"+b],c["offset"+b],c["client"+b])} | ||
function Ba(a,b){return R(a,"border"+(b?"Left":"Top")+"Width")+R(a,"padding"+(b?"Left":"Top"))+R(a,"padding"+(b?"Right":"Bottom"))+R(a,"border"+(b?"Right":"Bottom")+"Width")} | ||
I([!0,!1],function(a,b){I(["Width","Height"],function(a,d){F[(b?"outer":"inner")+d]=function(c){if(this[0])return K(this[0])?b?this[0]["inner"+d]:this[0].document.documentElement["client"+d]:A(this[0])?Aa(this[0],d):this[0][(b?"offset":"client")+d]+(c&&b?R(this[0],"margin"+(a?"Top":"Left"))+R(this[0],"margin"+(a?"Bottom":"Right")):0)}})}); | ||
I(["Width","Height"],function(a,b){var c=b.toLowerCase();F[c]=function(d){if(!this[0])return void 0===d?void 0:this;if(!arguments.length)return K(this[0])?this[0].document.documentElement["client"+b]:A(this[0])?Aa(this[0],b):this[0].getBoundingClientRect()[c]-Ba(this[0],!a);var h=parseInt(d,10);return this.each(function(b,d){B(d)&&(b=Q(d,"boxSizing"),d.style[c]=xa(c,h+("border-box"===b?Ba(d,!a):0)))})}});var V={}; | ||
F.toggle=function(a){return this.each(function(b,c){if(B(c))if(void 0===a?"none"===Q(c,"display"):a){if(c.style.display=c.___cd||"","none"===Q(c,"display")){b=c.style;c=c.tagName;if(V[c])c=V[c];else{var d=r(c);m.body.insertBefore(d,null);var h=Q(d,"display");m.body.removeChild(d);c=V[c]="none"!==h?h:"block"}b.display=c}}else c.___cd=Q(c,"display"),c.style.display="none"})};F.hide=function(){return this.toggle(!1)};F.show=function(){return this.toggle(!0)}; | ||
function Ca(a,b){return!b||!x.call(b,function(b){return 0>a.indexOf(b)})}var W={focus:"focusin",blur:"focusout"},Da={mouseenter:"mouseover",mouseleave:"mouseout"},Ea=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function Fa(a,b,c,d,h){var f=a.___ce=a.___ce||{};f[b]=f[b]||[];f[b].push([c,d,h]);a.addEventListener(b,h)}function X(a){a=a.split(".");return[a[0],a.slice(1).sort()]} | ||
function Y(a,b,c,d,h){var f=a.___ce=a.___ce||{};if(b)f[b]&&(f[b]=f[b].filter(function(f){var k=f[0],S=f[1];f=f[2];if(h&&f.guid!==h.guid||!Ca(k,c)||d&&d!==S)return!0;a.removeEventListener(b,f)}));else for(b in f)Y(a,b,c,d,h)}F.off=function(a,b,c){var d=this;if(void 0===a)this.each(function(a,b){B(b)&&Y(b)});else if(D(a))E(b)&&(c=b,b=""),I(N(a),function(a,h){a=X(Da[h]||W[h]||h);var f=a[0],k=a[1];d.each(function(a,d){B(d)&&Y(d,f,k,b,c)})});else for(var h in a)this.off(h,a[h]);return this}; | ||
F.on=function(a,b,c,d,h){var f=this;if(!D(a)){for(var k in a)this.on(k,b,c,a[k],h);return this}D(b)||(void 0!==b&&null!==b&&(void 0!==c&&(d=c),c=b),b="");E(d)||(d=c,c=void 0);if(!d)return this;I(N(a),function(a,k){a=X(Da[k]||W[k]||k);var l=a[0],q=a[1];l&&f.each(function(a,f){B(f)&&(a=function Ja(a){if(!a.namespace||Ca(q,a.namespace.split("."))){var k=f;if(b){for(var z=a.target;!qa(z,b);){if(z===f)return;z=z.parentNode;if(!z)return}k=z;a.___cd=!0}a.___cd&&Object.defineProperty(a,"currentTarget",{configurable:!0, | ||
get:function(){return k}});a.data=c;z=d.call(k,a,a.___td);h&&Y(f,l,q,b,Ja);!1===z&&(a.preventDefault(),a.stopPropagation())}},a.guid=d.guid=d.guid||G.guid++,Fa(f,l,q,b,a))})});return this};F.one=function(a,b,c,d){return this.on(a,b,c,d,!0)};F.ready=function(a){function b(){return g(a,G)}"loading"!==m.readyState?b():m.addEventListener("DOMContentLoaded",b);return this}; | ||
F.trigger=function(a,b){if(D(a)){var c=X(a),d=c[0];c=c[1];if(!d)return this;var h=Ea.test(d)?"MouseEvents":"HTMLEvents";a=m.createEvent(h);a.initEvent(d,!0,!0);a.namespace=c.join(".")}a.___td=b;var f=a.type in W;return this.each(function(b,c){if(f&&E(c[a.type]))c[a.type]();else c.dispatchEvent(a)})};function Ga(a){return a.multiple&&a.options?O(w.call(a.options,function(a){return a.selected&&!a.disabled&&!a.parentNode.disabled}),"value"):a.value||""} | ||
var Ha=/%20/g,Ia=/\r?\n/g,Ka=/file|reset|submit|button|image/i,La=/radio|checkbox/i;F.serialize=function(){var a="";this.each(function(b,c){I(c.elements||[c],function(b,c){c.disabled||!c.name||"FIELDSET"===c.tagName||Ka.test(c.type)||La.test(c.type)&&!c.checked||(b=Ga(c),void 0!==b&&(b=u(b)?b:[b],I(b,function(b,d){b=a;d="&"+encodeURIComponent(c.name)+"="+encodeURIComponent(d.replace(Ia,"\r\n")).replace(Ha,"+");a=b+d})))})});return a.slice(1)}; | ||
F.val=function(a){return arguments.length?this.each(function(b,c){if((b=c.multiple&&c.options)||La.test(c.type)){var d=u(a)?fa.call(a,String):null===a?[]:[String(a)];b?I(c.options,function(a,b){b.selected=0<=d.indexOf(b.value)},!0):c.checked=0<=d.indexOf(c.value)}else c.value=void 0===a||null===a?"":a}):this[0]&&Ga(this[0])};F.clone=function(){return this.map(function(a,b){return b.cloneNode(!0)})};F.detach=function(a){M(this,a).each(function(a,c){c.parentNode&&c.parentNode.removeChild(c)});return this}; | ||
var Ma=/^\s*<(\w+)[^>]*>/,Na=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,Oa={"*":aa,tr:ba,td:ca,th:ca,thead:t,tbody:t,tfoot:t};function oa(a){if(!D(a))return[];if(Na.test(a))return[r(RegExp.$1)];var b=Ma.test(a)&&RegExp.$1;b=Oa[b]||Oa["*"];b.innerHTML=a;return G(b.childNodes).detach().get()}G.parseHTML=oa;F.empty=function(){return this.each(function(a,b){for(;b.firstChild;)b.removeChild(b.firstChild)})}; | ||
F.html=function(a){return arguments.length?void 0===a?this:this.each(function(b,c){B(c)&&(c.innerHTML=a)}):this[0]&&this[0].innerHTML};F.remove=function(a){M(this,a).detach().off();return this};F.text=function(a){return void 0===a?this[0]?this[0].textContent:"":this.each(function(b,c){B(c)&&(c.textContent=a)})};F.unwrap=function(){this.parent().each(function(a,b){"BODY"!==b.tagName&&(a=G(b),a.replaceWith(a.children()))});return this}; | ||
F.offset=function(){var a=this[0];if(a)return a=a.getBoundingClientRect(),{top:a.top+n.pageYOffset,left:a.left+n.pageXOffset}};F.offsetParent=function(){return this.map(function(a,b){for(a=b.offsetParent;a&&"static"===Q(a,"position");)a=a.offsetParent;return a||p})}; | ||
F.position=function(){var a=this[0];if(a){var b="fixed"===Q(a,"position"),c=b?a.getBoundingClientRect():this.offset();if(!b){var d=a.ownerDocument;for(b=a.offsetParent||d.documentElement;(b===d.body||b===d.documentElement)&&"static"===Q(b,"position");)b=b.parentNode;b!==a&&B(b)&&(d=G(b).offset(),c.top-=d.top+R(b,"borderTopWidth"),c.left-=d.left+R(b,"borderLeftWidth"))}return{top:c.top-R(a,"marginTop"),left:c.left-R(a,"marginLeft")}}}; | ||
F.children=function(a){return M(G(P(O(this,function(a){return a.children}))),a)};F.contents=function(){return G(P(O(this,function(a){return"IFRAME"===a.tagName?[a.contentDocument]:"TEMPLATE"===a.tagName?a.content.childNodes:a.childNodes})))};F.find=function(a){return G(P(O(this,function(b){return y(a,b)})))};var Pa=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,Qa=/^$|^module$|\/(java|ecma)script/i,Ra=["type","src","nonce","noModule"]; | ||
function Sa(a,b){a=G(a);a.filter("script").add(a.find("script")).each(function(a,d){if(Qa.test(d.type)&&p.contains(d)){var c=r("script");c.text=d.textContent.replace(Pa,"");I(Ra,function(a,b){d[b]&&(c[b]=d[b])});b.head.insertBefore(c,null);b.head.removeChild(c)}})} | ||
function Z(a,b,c,d,h,f,k,q){I(a,function(a,f){I(G(f),function(a,f){I(G(b),function(b,k){var l=c?k:f;b=c?a:b;k=c?f:k;l=b?l.cloneNode(!0):l;b=!b;h?k.insertBefore(l,d?k.firstChild:null):k.parentNode.insertBefore(l,d?k:k.nextSibling);b&&Sa(l,k.ownerDocument)},q)},k)},f);return b}F.after=function(){return Z(arguments,this,!1,!1,!1,!0,!0)};F.append=function(){return Z(arguments,this,!1,!1,!0)};F.appendTo=function(a){return Z(arguments,this,!0,!1,!0)};F.before=function(){return Z(arguments,this,!1,!0)}; | ||
F.insertAfter=function(a){return Z(arguments,this,!0,!1,!1,!1,!1,!0)};F.insertBefore=function(a){return Z(arguments,this,!0,!0)};F.prepend=function(){return Z(arguments,this,!1,!0,!0,!0,!0)};F.prependTo=function(a){return Z(arguments,this,!0,!0,!0,!1,!1,!0)};F.replaceWith=function(a){return this.before(a).remove()};F.replaceAll=function(a){G(a).replaceWith(this);return this};F.wrapAll=function(a){a=G(a);for(var b=a[0];b.children.length;)b=b.firstElementChild;this.first().before(a);return this.appendTo(b)}; | ||
F.wrap=function(a){return this.each(function(b,c){var d=G(a)[0];G(c).wrapAll(b?d.cloneNode(!0):d)})};F.wrapInner=function(a){return this.each(function(b,c){b=G(c);c=b.contents();c.length?c.wrapAll(a):b.append(a)})};F.has=function(a){var b=C(a)?function(b,d){return A(a,d).length}:function(b,d){return d.contains(a)};return this.filter(b)};F.is=function(a){var b=M(a);return z.call(this,function(a,d){return b.call(a,d,a)})};F.next=function(a,b){return N(G(Q(P(this,"nextElementSibling",b))),a)}; | ||
F.nextAll=function(a){return this.next(a,!0)};F.not=function(a){var b=M(a);return this.filter(function(a,d){return!b.call(d,a,d)})};F.parent=function(a){return N(G(Q(P(this,"parentNode"))),a)};F.index=function(a){var b=a?G(a)[0]:this[0];a=a?this:G(b).parent().children();return x.call(a,b)};F.closest=function(a){var b=this.filter(a);if(b.length)return b;var c=this.parent();return c.length?c.closest(a):b};F.parents=function(a){return N(G(Q(P(this,"parentElement",!0))),a)}; | ||
F.prev=function(a,b){return N(G(Q(P(this,"previousElementSibling",b))),a)};F.prevAll=function(a){return this.prev(a,!0)};F.siblings=function(a){return N(G(Q(P(this,function(a){return G(a).parent().children().not(a)}))),a)};"undefined"!==typeof exports?module.exports=G:g.cash=g.$=G; | ||
F.wrap=function(a){return this.each(function(b,c){var d=G(a)[0];G(c).wrapAll(b?d.cloneNode(!0):d)})};F.wrapInner=function(a){return this.each(function(b,c){b=G(c);c=b.contents();c.length?c.wrapAll(a):b.append(a)})};F.has=function(a){var b=D(a)?function(b,d){return y(a,d).length}:function(b,d){return d.contains(a)};return this.filter(b)};F.is=function(a){var b=L(a);return x.call(this,function(a,d){return b.call(a,d,a)})};F.next=function(a,b,c){return M(G(P(O(this,"nextElementSibling",b,c))),a)}; | ||
F.nextAll=function(a){return this.next(a,!0)};F.nextUntil=function(a,b){return this.next(b,!0,a)};F.not=function(a){var b=L(a);return this.filter(function(c,d){return(!D(a)||B(d))&&!b.call(d,c,d)})};F.parent=function(a){return M(G(P(O(this,"parentNode"))),a)};F.index=function(a){var b=a?G(a)[0]:this[0];a=a?this:G(b).parent().children();return ea.call(a,b)};F.closest=function(a){var b=this.filter(a);if(b.length)return b;var c=this.parent();return c.length?c.closest(a):b}; | ||
F.parents=function(a,b){return M(G(P(O(this,"parentElement",!0,b))),a)};F.parentsUntil=function(a,b){return this.parents(b,a)};F.prev=function(a,b,c){return M(G(P(O(this,"previousElementSibling",b,c))),a)};F.prevAll=function(a){return this.prev(a,!0)};F.prevUntil=function(a,b){return this.prev(b,!0,a)};F.siblings=function(a){return M(G(P(O(this,function(a){return G(a).parent().children().not(a)}))),a)};"undefined"!==typeof exports?module.exports=G:n.cash=n.$=G; | ||
})(); |
528
dist/cash.ts
const propMap: Record<string, string> = { | ||
/* GENERAL */ | ||
class: 'className', | ||
contenteditable: 'contentEditable', | ||
/* LABEL */ | ||
for: 'htmlFor', | ||
/* INPUT */ | ||
readonly: 'readOnly', | ||
maxlength: 'maxLength', | ||
tabindex: 'tabIndex', | ||
/* TABLE */ | ||
colspan: 'colSpan', | ||
rowspan: 'rowSpan', | ||
/* IMAGE */ | ||
usemap: 'useMap' | ||
}; | ||
function attempt<T, U> ( fn: (( arg?: U ) => T), arg?: U ): T | U { | ||
try { | ||
return fn ( arg ); | ||
} catch { | ||
return arg; | ||
} | ||
} | ||
interface Event { | ||
namespace: string, | ||
data: any, | ||
___cd?: boolean // Delegate | ||
___cd?: boolean, // Delegate | ||
___td?: boolean // Trigger data | ||
} | ||
@@ -43,4 +77,4 @@ | ||
tr = createElement ( 'tr' ), | ||
{isArray, prototype: ArrayProtoType} = Array, | ||
{filter, indexOf, map, push, slice, some, splice} = ArrayProtoType; | ||
{isArray, prototype: ArrayPrototype} = Array, | ||
{concat, filter, indexOf, map, push, slice, some, splice} = ArrayPrototype; | ||
@@ -55,5 +89,5 @@ const idRe = /^#[\w-]*$/, | ||
function find ( selector: string, context: Ele = doc ): ArrayLike<Element> { | ||
function find ( selector: string, context: Ele ): ArrayLike<Element> { | ||
return !isDocument ( context ) && !isElement ( context ) | ||
return !selector || ( !isDocument ( context ) && !isElement ( context ) ) | ||
? [] | ||
@@ -74,3 +108,3 @@ : classRe.test ( selector ) | ||
constructor ( selector?: Selector, context: Context | Cash = doc ) { | ||
constructor ( selector?: Selector, context?: Context | Cash ) { | ||
@@ -85,3 +119,3 @@ if ( !selector ) return; | ||
const ctx = isCash ( context ) ? context[0] : context; | ||
const ctx = ( isCash ( context ) ? context[0] : context ) || doc; | ||
@@ -131,3 +165,3 @@ eles = idRe.test ( selector ) | ||
if ( typeof Symbol === 'function' ) { // Ensuring a cash collection is iterable | ||
fn[Symbol['iterator']] = ArrayProtoType[Symbol['iterator']]; | ||
fn[Symbol['iterator']] = ArrayPrototype[Symbol['iterator']]; | ||
} | ||
@@ -147,3 +181,3 @@ | ||
return cash ( map.call ( this, ( ele: EleLoose, i: number ) => callback.call ( ele, i, ele ) ) ); | ||
return cash ( concat.apply ( [], map.call ( this, ( ele: EleLoose, i: number ) => callback.call ( ele, i, ele ) ) ) ); | ||
@@ -169,6 +203,2 @@ }; | ||
interface CashStatic { | ||
camelCase ( str: string ): string; | ||
} | ||
const dashAlphaRe = /-([a-z])/g; | ||
@@ -182,5 +212,3 @@ | ||
cash.camelCase = camelCase; | ||
// @require ./cash.ts | ||
@@ -194,5 +222,5 @@ | ||
function each<T, U extends ArrayLike<T> = ArrayLike<T>> ( arr: U, callback: EachCallback<U[0]>, reverse?: boolean ): U { | ||
function each<T, U extends ArrayLike<T> = ArrayLike<T>> ( arr: U, callback: EachCallback<U[0]>, _reverse?: boolean ): U { | ||
if ( reverse ) { | ||
if ( _reverse ) { | ||
@@ -240,2 +268,3 @@ let i = arr.length; | ||
// @require collection/each.ts | ||
// @require ./helpers/variables.ts | ||
@@ -248,3 +277,3 @@ interface Cash { | ||
return this.each ( ( i, ele ) => { delete ele[prop] } ); | ||
return this.each ( ( i, ele ) => { delete ele[propMap[prop] || prop] } ); | ||
@@ -257,2 +286,4 @@ }; | ||
interface CashStatic { | ||
extend (): any; | ||
extend ( target: any ): typeof cash; | ||
extend ( target: any, ...objs: any[] ): any; | ||
@@ -265,8 +296,12 @@ } | ||
cash.extend = function ( target: any, ...objs: any[] ) { | ||
function extend ( target?: any, ...objs: any[] ) { | ||
const length = arguments.length; | ||
for ( let i = ( length < 2 ? 0 : 1 ); i < length; i++ ) { | ||
if ( !length ) return {}; | ||
if ( length === 1 ) return extend ( cash, target ); | ||
for ( let i = 1; i < length; i++ ) { | ||
for ( const key in arguments[i] ) { | ||
@@ -282,7 +317,9 @@ | ||
}; | ||
} | ||
cash.extend = extend; | ||
fn.extend = function ( plugins: Record<string, any> ) { | ||
return cash.extend ( fn, plugins ); | ||
return extend ( fn, plugins ); | ||
@@ -303,6 +340,2 @@ }; | ||
interface CashStatic { | ||
matches ( ele: any, selector: string ): boolean; | ||
} | ||
function matches ( ele: any, selector: string ): boolean { | ||
@@ -312,9 +345,7 @@ | ||
return !!matches && matches.call ( ele, selector ); | ||
return !!matches && !!selector && matches.call ( ele, selector ); | ||
} | ||
cash.matches = matches; | ||
// @require ./cash.ts | ||
@@ -326,3 +357,2 @@ // @require ./variables.ts | ||
isFunction ( x: any ): x is Function; | ||
isString ( x: any ): x is string; | ||
isNumeric ( x: any ): boolean; | ||
@@ -388,3 +418,2 @@ isArray ( x: any ): x is Array<any>; | ||
cash.isFunction = isFunction; | ||
cash.isString = isString; | ||
cash.isNumeric = isNumeric; | ||
@@ -397,2 +426,3 @@ cash.isArray = isArray; | ||
// @require collection/each.ts | ||
// @require ./helpers/variables.ts | ||
@@ -411,2 +441,4 @@ interface Cash { | ||
prop = propMap[prop] || prop; | ||
if ( arguments.length < 2 ) return this[0] && this[0][prop]; | ||
@@ -442,2 +474,4 @@ | ||
index = Number ( index ); | ||
return this[index < 0 ? index + this.length : index]; | ||
@@ -549,2 +583,3 @@ | ||
// @require core/get_split_values.ts | ||
// @require core/type_checking.ts | ||
// @require collection/each.ts | ||
@@ -558,3 +593,3 @@ | ||
return !!cls && some.call ( this, ( ele: EleLoose ) => ele.classList.contains ( cls ) ); | ||
return !!cls && some.call ( this, ( ele: EleLoose ) => isElement ( ele ) && ele.classList.contains ( cls ) ); | ||
@@ -578,2 +613,4 @@ }; | ||
if ( !isElement ( ele ) ) return; | ||
each ( attrs, ( i, a ) => { | ||
@@ -614,3 +651,3 @@ | ||
if ( !this[0] ) return; | ||
if ( !this[0] || !isElement ( this[0] ) ) return; | ||
@@ -627,4 +664,10 @@ const value = this[0].getAttribute ( attr ); | ||
return this.each ( ( i, ele ) => { ele.setAttribute ( attr, value ) } ); | ||
return this.each ( ( i, ele ) => { | ||
if ( !isElement ( ele ) ) return; | ||
ele.setAttribute ( attr, value ) | ||
}); | ||
} | ||
@@ -662,2 +705,4 @@ | ||
if ( !isElement ( ele ) ) return; | ||
each ( classes, ( i, c ) => { | ||
@@ -723,2 +768,3 @@ | ||
// @require ./get_compare_function.ts | ||
// @require ./type_checking.ts | ||
@@ -729,8 +775,7 @@ // @require ./variables.ts | ||
function pluck<T, U extends ArrayLike<T> = ArrayLike<T>> ( arr: U, prop: PluckCallback<U[0]> ): Array<Ele>; | ||
function pluck<T, U extends ArrayLike<T> = ArrayLike<T>> ( arr: U, prop: string, deep?: boolean ): Array<Ele>; | ||
function pluck<T, U extends ArrayLike<T> = ArrayLike<T>> ( arr: U, prop: string | PluckCallback<U[0]>, deep?: boolean ): Array<Ele> { | ||
function pluck<T, U extends ArrayLike<T> = ArrayLike<T>> ( arr: U, prop: string | PluckCallback<U[0]>, deep?: boolean, until?: Comparator ): Array<Ele> { | ||
const plucked: Array<Ele> = [], | ||
isCallback = isFunction ( prop ); | ||
isCallback = isFunction ( prop ), | ||
compare = until && getCompareFunction ( until ); | ||
@@ -751,2 +796,4 @@ for ( let i = 0, l = arr.length; i < l; i++ ) { | ||
if ( until && compare ( -1, val ) ) break; | ||
plucked.push ( val ); | ||
@@ -803,7 +850,7 @@ | ||
if ( !isElement ( ele ) || !prop ) return; | ||
if ( !isElement ( ele ) ) return; | ||
const style = win.getComputedStyle ( ele, null ); | ||
return prop ? ( isVariable ? style.getPropertyValue ( prop ) || undefined : style[prop] ) : style; | ||
return isVariable ? style.getPropertyValue ( prop ) || undefined : style[prop]; | ||
@@ -840,6 +887,2 @@ } | ||
interface CashStatic { | ||
prefixedProp ( prop: string, isVariable?: boolean ): string; | ||
} | ||
const prefixedProps: { [prop: string]: string } = {}, | ||
@@ -877,5 +920,3 @@ {style} = div, | ||
cash.prefixedProp = getPrefixedProp; | ||
// @require core/type_checking.ts | ||
@@ -890,2 +931,9 @@ // @require ./is_css_variable.ts | ||
fontWeight: true, | ||
gridArea: true, | ||
gridColumn: true, | ||
gridColumnEnd: true, | ||
gridColumnStart: true, | ||
gridRow: true, | ||
gridRowEnd: true, | ||
gridRowStart: true, | ||
lineHeight: true, | ||
@@ -971,4 +1019,7 @@ opacity: true, | ||
// @require core/attempt.ts | ||
// @require core/camel_case.ts | ||
const JSONStringRe = /^\s+|\s+$/; | ||
function getData ( ele: EleLoose, key: string ): any { | ||
@@ -978,13 +1029,10 @@ | ||
try { | ||
if ( JSONStringRe.test ( value ) ) return value; | ||
return JSON.parse ( value ); | ||
return attempt ( JSON.parse, value ); | ||
} catch {} | ||
return value; | ||
} | ||
// @require core/attempt.ts | ||
// @require core/camel_case.ts | ||
@@ -994,8 +1042,4 @@ | ||
try { | ||
value = attempt ( JSON.stringify, value ); | ||
value = JSON.stringify ( value ); | ||
} catch {} | ||
ele.dataset[camelCase ( key )] = value; | ||
@@ -1045,2 +1089,4 @@ | ||
if ( isUndefined ( value ) ) return this; | ||
return this.each ( ( i, ele ) => { setData ( ele, name, value ) } ); | ||
@@ -1066,2 +1112,17 @@ | ||
function getDocumentDimension ( doc: Document, dimension: 'Width' | 'Height' ): number { | ||
const docEle = doc.documentElement; | ||
return Math.max ( | ||
doc.body[`scroll${dimension}`], | ||
docEle[`scroll${dimension}`], | ||
doc.body[`offset${dimension}`], | ||
docEle[`offset${dimension}`], | ||
docEle[`client${dimension}`] | ||
); | ||
} | ||
// @require css/helpers/compute_style_int.ts | ||
@@ -1080,2 +1141,3 @@ | ||
// @require core/variables.ts | ||
// @require ./helpers/get_document_dimension.ts | ||
@@ -1099,4 +1161,6 @@ interface Cash { | ||
if ( isWindow ( this[0] ) ) return win[name]; | ||
if ( isWindow ( this[0] ) ) return outer ? this[0][`inner${prop}`] : this[0].document.documentElement[`client${prop}`]; | ||
if ( isDocument ( this[0] ) ) return getDocumentDimension ( this[0], prop ); | ||
return this[0][`${outer ? 'offset' : 'client'}${prop}`] + ( includeMargins && outer ? computeStyleInt ( this[0], `margin${ i ? 'Top' : 'Left' }` ) + computeStyleInt ( this[0], `margin${ i ? 'Bottom' : 'Right' }` ) : 0 ); | ||
@@ -1111,3 +1175,2 @@ | ||
// @require core/camel_case.ts | ||
// @require core/cash.ts | ||
@@ -1120,2 +1183,3 @@ // @require core/each.ts | ||
// @require ./helpers/get_extra_space.ts | ||
// @require ./helpers/get_document_dimension.ts | ||
@@ -1129,6 +1193,8 @@ interface Cash { | ||
each ( ['width', 'height'], ( index: number, prop: 'width' | 'height' ) => { | ||
each ( ['Width', 'Height'], ( index: number, prop: 'Width' | 'Height' ) => { | ||
fn[prop] = function ( this: Cash, value?: number | string ) { | ||
const propLC = prop.toLowerCase (); | ||
fn[propLC] = function ( this: Cash, value?: number | string ) { | ||
if ( !this[0] ) return isUndefined ( value ) ? undefined : this; | ||
@@ -1138,6 +1204,8 @@ | ||
if ( isWindow ( this[0] ) ) return this[0][ camelCase ( `outer-${prop}` )]; | ||
if ( isWindow ( this[0] ) ) return this[0].document.documentElement[`client${prop}`]; | ||
return this[0].getBoundingClientRect ()[prop] - getExtraSpace ( this[0], !index ); | ||
if ( isDocument ( this[0] ) ) return getDocumentDimension ( this[0], prop ); | ||
return this[0].getBoundingClientRect ()[propLC] - getExtraSpace ( this[0], !index ); | ||
} | ||
@@ -1153,3 +1221,3 @@ | ||
ele.style[prop] = getSuffixedValue ( prop, valueNumber + ( boxSizing === 'border-box' ? getExtraSpace ( ele, !index ) : 0 ) ); | ||
ele.style[propLC] = getSuffixedValue ( propLC, valueNumber + ( boxSizing === 'border-box' ? getExtraSpace ( ele, !index ) : 0 ) ); | ||
@@ -1214,2 +1282,4 @@ }); | ||
if ( !isElement ( ele ) ) return; | ||
const show = isUndefined ( force ) ? isHidden ( ele ) : force; | ||
@@ -1310,4 +1380,2 @@ | ||
callback.guid = callback.guid || cash.guid++; | ||
const eventCache = getEventsCache ( ele ); | ||
@@ -1385,4 +1453,10 @@ | ||
this.each ( ( i, ele ) => { removeEvent ( ele ) } ); | ||
this.each ( ( i, ele ) => { | ||
if ( !isElement ( ele ) ) return; | ||
removeEvent ( ele ); | ||
}); | ||
} else if ( !isString ( eventFullName ) ) { | ||
@@ -1409,4 +1483,10 @@ | ||
this.each ( ( i, ele ) => { removeEvent ( ele, name, namespaces, selector, callback ) } ); | ||
this.each ( ( i, ele ) => { | ||
if ( !isElement ( ele ) ) return; | ||
removeEvent ( ele, name, namespaces, selector, callback ); | ||
}); | ||
}); | ||
@@ -1436,10 +1516,20 @@ | ||
on ( events: Record<string, EventCallback> ): this; | ||
on ( events: string, callback: EventCallback, _one?: boolean ): this; | ||
on ( events: string, selector: string | EventCallback, callback: EventCallback, _one?: boolean ): this; | ||
on ( events: Record<string, EventCallback>, selector: string ): this; | ||
on ( events: Record<string, EventCallback>, data: any ): this; | ||
on ( events: Record<string, EventCallback>, selector: string | null | undefined, data: any ): this; | ||
on ( events: string, callback: EventCallback ): this; | ||
on ( events: string, selector: string, callback: EventCallback ): this; | ||
on ( events: string, data: any, callback: EventCallback ): this; | ||
on ( events: string, selector: string | null | undefined, data: any, callback: EventCallback, _one?: boolean ): this; | ||
} | ||
function on ( this: Cash, eventFullName: Record<string, EventCallback> ): Cash; | ||
function on ( this: Cash, eventFullName: string, callback: EventCallback, _one?: boolean ): Cash; | ||
function on ( this: Cash, eventFullName: string, selector: string | EventCallback, callback: EventCallback, _one?: boolean ): Cash; | ||
function on ( this: Cash, eventFullName: string | Record<string, EventCallback>, selector?: string | EventCallback, callback?: boolean | EventCallback, _one?: boolean ) { | ||
function on ( this: Cash, eventFullName: Record<string, EventCallback>, selector: string ): Cash; | ||
function on ( this: Cash, eventFullName: Record<string, EventCallback>, data: any ): Cash; | ||
function on ( this: Cash, eventFullName: Record<string, EventCallback>, selector: string | null | undefined, data: any ): Cash; | ||
function on ( this: Cash, eventFullName: string, callback: EventCallback ): Cash; | ||
function on ( this: Cash, eventFullName: string, selector: string, callback: EventCallback ): Cash; | ||
function on ( this: Cash, eventFullName: string, data: any, callback: EventCallback ): Cash; | ||
function on ( this: Cash, eventFullName: string, selector: string | null | undefined, data: any, callback: EventCallback, _one?: boolean ): Cash; | ||
function on ( this: Cash, eventFullName: Record<string, EventCallback> | string, selector?: any, data?: any, callback?: EventCallback, _one?: boolean ) { | ||
@@ -1450,3 +1540,3 @@ if ( !isString ( eventFullName ) ) { | ||
this.on ( key, selector, eventFullName[key] ); | ||
this.on ( key, selector, data, eventFullName[key], _one ); | ||
@@ -1459,9 +1549,32 @@ } | ||
if ( isFunction ( selector ) ) { | ||
if ( !isString ( selector ) ) { | ||
callback = selector; | ||
selector = ''; | ||
if ( isUndefined ( selector ) || isNull ( selector ) ) { | ||
selector = ''; | ||
} else if ( isUndefined ( data ) ) { | ||
data = selector; | ||
selector = ''; | ||
} else { | ||
callback = data; | ||
data = selector; | ||
selector = ''; | ||
} | ||
} | ||
if ( !isFunction ( callback ) ) { | ||
callback = data; | ||
data = undefined; | ||
} | ||
if ( !callback ) return this; | ||
each ( getSplitValues ( eventFullName ), ( i, eventFullName ) => { | ||
@@ -1471,4 +1584,8 @@ | ||
if ( !name ) return; | ||
this.each ( ( i, ele ) => { | ||
if ( !isElement ( ele ) ) return; | ||
const finalCallback = function ( event: Event ) { | ||
@@ -1511,4 +1628,6 @@ | ||
const returnValue = callback.call ( thisArg, event, event.data ); | ||
event.data = data; | ||
const returnValue = callback.call ( thisArg, event, event.___td ); | ||
if ( _one ) { | ||
@@ -1549,12 +1668,22 @@ | ||
one ( events: Record<string, EventCallback> ): this; | ||
one ( events: Record<string, EventCallback>, selector: string ): this; | ||
one ( events: Record<string, EventCallback>, data: any ): this; | ||
one ( events: Record<string, EventCallback>, selector: string | null | undefined, data: any ): this; | ||
one ( events: string, callback: EventCallback ): this; | ||
one ( events: string, selector: string | EventCallback, callback: EventCallback ): this; | ||
one ( events: string, selector: string, callback: EventCallback ): this; | ||
one ( events: string, data: any, callback: EventCallback ): this; | ||
one ( events: string, selector: string | null | undefined, data: any, callback: EventCallback ): this; | ||
} | ||
function one ( this: Cash, eventFullName: Record<string, EventCallback> ): Cash; | ||
function one ( this: Cash, eventFullName: Record<string, EventCallback>, selector: string ): Cash; | ||
function one ( this: Cash, eventFullName: Record<string, EventCallback>, data: any ): Cash; | ||
function one ( this: Cash, eventFullName: Record<string, EventCallback>, selector: string | null | undefined, data: any ): Cash; | ||
function one ( this: Cash, eventFullName: string, callback: EventCallback ): Cash; | ||
function one ( this: Cash, eventFullName: string, selector: string | EventCallback, callback: EventCallback ): Cash; | ||
function one ( this: Cash, eventFullName: string | Record<string, EventCallback>, selector?: string | EventCallback, callback?: EventCallback ) { | ||
function one ( this: Cash, eventFullName: string, selector: string, callback: EventCallback ): Cash; | ||
function one ( this: Cash, eventFullName: string, data: any, callback: EventCallback ): Cash; | ||
function one ( this: Cash, eventFullName: string, selector: string | null | undefined, data: any, callback: EventCallback ): Cash; | ||
function one ( this: Cash, eventFullName: Record<string, EventCallback> | string, selector?: any, data?: any, callback?: EventCallback ) { | ||
return this.on ( eventFullName, selector, callback, true ); | ||
return this.on ( eventFullName, selector, data, callback, true ); | ||
@@ -1573,11 +1702,13 @@ }; | ||
fn.ready = function ( this: Cash, callback: Function ) { | ||
fn.ready = function ( this: Cash, callback: ( $: typeof cash ) => any ) { | ||
const cb = () => attempt ( callback, cash ); | ||
if ( doc.readyState !== 'loading' ) { | ||
callback ( cash ); | ||
cb (); | ||
} else { | ||
doc.addEventListener ( 'DOMContentLoaded', () => { callback ( cash ) } ); | ||
doc.addEventListener ( 'DOMContentLoaded', cb ); | ||
@@ -1606,5 +1737,8 @@ } | ||
const [name, namespaces] = parseEventName ( event ), | ||
type = eventsMouseRe.test ( name ) ? 'MouseEvents' : 'HTMLEvents'; | ||
const [name, namespaces] = parseEventName ( event ); | ||
if ( !name ) return this; | ||
const type = eventsMouseRe.test ( name ) ? 'MouseEvents' : 'HTMLEvents'; | ||
event = doc.createEvent ( type ); | ||
@@ -1616,3 +1750,3 @@ event.initEvent ( name, true, true ); | ||
event.data = data; | ||
event.___td = data; | ||
@@ -1657,7 +1791,8 @@ const isEventFocus = ( event.type in eventsFocus ); | ||
const queryEncodeSpaceRe = /%20/g; | ||
const queryEncodeSpaceRe = /%20/g, | ||
queryEncodeCRLFRe = /\r?\n/g; | ||
function queryEncode ( prop: string, value: string ): string { | ||
return `&${encodeURIComponent ( prop )}=${encodeURIComponent ( value ).replace ( queryEncodeSpaceRe, '+' )}`; | ||
return `&${encodeURIComponent ( prop )}=${encodeURIComponent ( value.replace ( queryEncodeCRLFRe, '\r\n' ) ).replace ( queryEncodeSpaceRe, '+' )}`; | ||
@@ -1728,19 +1863,29 @@ } | ||
if ( isUndefined ( value ) ) return this[0] && getValue ( this[0] ); | ||
if ( !arguments.length ) return this[0] && getValue ( this[0] ); | ||
return this.each ( ( i, ele ) => { | ||
if ( ele.tagName === 'SELECT' ) { | ||
const isSelect = ele.multiple && ele.options; | ||
const eleValue = isArray ( value ) ? value : ( isNull ( value ) ? [] : [value] ); | ||
if ( isSelect || checkableRe.test ( ele.type ) ) { | ||
each ( ele.options, ( i, option ) => { | ||
const eleValue = isArray ( value ) ? map.call ( value, String ) : ( isNull ( value ) ? [] : [String ( value )] ); | ||
option.selected = eleValue.indexOf ( option.value ) >= 0; | ||
if ( isSelect ) { | ||
}); | ||
each ( ele.options, ( i, option ) => { | ||
option.selected = eleValue.indexOf ( option.value ) >= 0; | ||
}, true ); | ||
} else { | ||
ele.checked = eleValue.indexOf ( ele.value ) >= 0; | ||
} | ||
} else { | ||
ele.value = isNull ( value ) ? '' : value; | ||
ele.value = isUndefined ( value ) || isNull ( value ) ? '' : value; | ||
@@ -1775,11 +1920,12 @@ } | ||
// @require core/cash.ts | ||
// @require core/filtered.ts | ||
// @require collection/each.ts | ||
interface Cash { | ||
detach (): this; | ||
detach ( comparator?: Comparator ): this; | ||
} | ||
fn.detach = function ( this: Cash ) { | ||
fn.detach = function ( this: Cash, comparator?: Comparator ) { | ||
return this.each ( ( i, ele ) => { | ||
filtered ( this, comparator ).each ( ( i, ele ) => { | ||
@@ -1794,2 +1940,4 @@ if ( ele.parentNode ) { | ||
return this; | ||
}; | ||
@@ -1809,3 +1957,3 @@ | ||
const fragmentRe = /^\s*<(\w+)[^>]*>/, | ||
singleTagRe = /^\s*<(\w+)\s*\/?>(?:<\/\1>)?\s*$/; | ||
singleTagRe = /^<(\w+)\s*\/?>(?:<\/\1>)?$/; | ||
@@ -1822,2 +1970,5 @@ const containers = { | ||
//TODO: Create elements inside a document fragment, in order to prevent inline event handlers from firing | ||
//TODO: Ensure the created elements have the fragment as their parent instead of null, this also ensures we can deal with detatched nodes more reliably | ||
function parseHTML ( html: string ): EleLoose[] { | ||
@@ -1841,3 +1992,2 @@ | ||
// @optional ./camel_case.ts | ||
// @optional ./each.ts | ||
@@ -1849,8 +1999,7 @@ // @optional ./extend.ts | ||
// @optional ./guid.ts | ||
// @optional ./matches.ts | ||
// @optional ./parse_html.ts | ||
// @optional ./unique.ts | ||
// @optional ./variables.ts | ||
// @require ./cash.ts | ||
// @require ./type_checking.ts | ||
// @require ./variables.ts | ||
@@ -1893,6 +2042,14 @@ | ||
if ( isUndefined ( html ) ) return this[0] && this[0].innerHTML; | ||
if ( !arguments.length ) return this[0] && this[0].innerHTML; | ||
return this.each ( ( i, ele ) => { ele.innerHTML = html } ); | ||
if ( isUndefined ( html ) ) return this; | ||
return this.each ( ( i, ele ) => { | ||
if ( !isElement ( ele ) ) return; | ||
ele.innerHTML = html; | ||
}); | ||
} | ||
@@ -1904,2 +2061,3 @@ | ||
// @require core/cash.ts | ||
// @require core/filtered.ts | ||
// @require events/off.ts | ||
@@ -1909,9 +2067,11 @@ // @require ./detach.ts | ||
interface Cash { | ||
remove (): this; | ||
remove ( comparator?: Comparator ): this; | ||
} | ||
fn.remove = function ( this: Cash ) { | ||
fn.remove = function ( this: Cash, comparator?: Comparator ) { | ||
return this.detach ().off (); | ||
filtered ( this, comparator ).detach ().off (); | ||
return this; | ||
}; | ||
@@ -1935,4 +2095,10 @@ | ||
return this.each ( ( i, ele ) => { ele.textContent = text } ); | ||
return this.each ( ( i, ele ) => { | ||
if ( !isElement ( ele ) ) return; | ||
ele.textContent = text | ||
}); | ||
}; | ||
@@ -1953,2 +2119,4 @@ | ||
if ( ele.tagName === 'BODY' ) return; | ||
const $ele = cash ( ele ); | ||
@@ -1984,4 +2152,4 @@ | ||
return { | ||
top: rect.top + win.pageYOffset - docEle.clientTop, | ||
left: rect.left + win.pageXOffset - docEle.clientLeft | ||
top: rect.top + win.pageYOffset, | ||
left: rect.left + win.pageXOffset | ||
}; | ||
@@ -1993,2 +2161,4 @@ | ||
// @require core/cash.ts | ||
// @require collection/map.ts | ||
// @require css/helpers/compute_style.ts | ||
@@ -2001,4 +2171,16 @@ interface Cash { | ||
return cash ( this[0] && this[0].offsetParent ); | ||
return this.map ( ( i, ele ) => { | ||
let offsetParent = ele.offsetParent; | ||
while ( offsetParent && computeStyle ( offsetParent, 'position' ) === 'static' ) { | ||
offsetParent = offsetParent.offsetParent; | ||
} | ||
return offsetParent || docEle; | ||
}); | ||
}; | ||
@@ -2008,2 +2190,6 @@ | ||
// @require core/cash.ts | ||
// @require core/type_checking.ts | ||
// @require css/helpers/compute_style.ts | ||
// @require css/helpers/compute_style_int.ts | ||
// @require ./offset.ts | ||
@@ -2023,5 +2209,31 @@ interface Cash { | ||
const isFixed = ( computeStyle ( ele, 'position' ) === 'fixed' ), | ||
offset = isFixed ? ele.getBoundingClientRect () : this.offset (); | ||
if ( !isFixed ) { | ||
const doc = ele.ownerDocument; | ||
let offsetParent = ele.offsetParent || doc.documentElement; | ||
while ( ( offsetParent === doc.body || offsetParent === doc.documentElement ) && computeStyle ( offsetParent, 'position' ) === 'static' ) { | ||
offsetParent = offsetParent.parentNode; | ||
} | ||
if ( offsetParent !== ele && isElement ( offsetParent ) ) { | ||
const parentOffset = cash ( offsetParent ).offset (); | ||
offset.top -= parentOffset.top + computeStyleInt ( offsetParent, 'borderTopWidth' ); | ||
offset.left -= parentOffset.left + computeStyleInt ( offsetParent, 'borderLeftWidth' ); | ||
} | ||
} | ||
return { | ||
left: ele.offsetLeft, | ||
top: ele.offsetTop | ||
top: offset.top - computeStyleInt ( ele, 'marginTop' ), | ||
left: offset.left - computeStyleInt ( ele, 'marginLeft' ) | ||
}; | ||
@@ -2066,3 +2278,3 @@ | ||
return cash ( unique ( pluck ( this, ele => ele.tagName === 'IFRAME' ? [ele.contentDocument] : ele.childNodes ) ) ); | ||
return cash ( unique ( pluck ( this, ele => ele.tagName === 'IFRAME' ? [ele.contentDocument] : ( ele.tagName === 'TEMPLATE' ? ele.content.childNodes : ele.childNodes ) ) ) ); | ||
@@ -2127,16 +2339,20 @@ }; | ||
function insertElement ( anchor: EleLoose, target: EleLoose, left?: boolean, inside?: boolean ): void { | ||
function insertElement ( anchor: EleLoose, target: EleLoose, left?: boolean, inside?: boolean, evaluate?: boolean ): void { | ||
if ( inside ) { // prepend/append | ||
anchor.insertBefore ( target, left ? anchor.firstElementChild : null ); | ||
anchor.insertBefore ( target, left ? anchor.firstChild : null ); | ||
} else { // before/after | ||
anchor.parentNode.insertBefore ( target, left ? anchor : anchor.nextElementSibling ); | ||
anchor.parentNode.insertBefore ( target, left ? anchor : anchor.nextSibling ); | ||
} | ||
evalScripts ( target, anchor.ownerDocument ); | ||
if ( evaluate ) { | ||
evalScripts ( target, anchor.ownerDocument ); | ||
} | ||
} | ||
@@ -2156,5 +2372,6 @@ | ||
const anchorFinal = inverse ? target : anchor, | ||
targetFinal = inverse ? anchor : target; | ||
targetFinal = inverse ? anchor : target, | ||
indexFinal = inverse ? ti : ai; | ||
insertElement ( anchorFinal, !ai ? targetFinal : targetFinal.cloneNode ( true ), left, inside ); | ||
insertElement ( anchorFinal, !indexFinal ? targetFinal : targetFinal.cloneNode ( true ), left, inside, !indexFinal ); | ||
@@ -2447,8 +2664,8 @@ }, reverseLoop3 ); | ||
interface Cash { | ||
next ( comparator?: Comparator, _all?: boolean ): Cash; | ||
next ( comparator?: Comparator, _all?: boolean, _until?: Comparator ): Cash; | ||
} | ||
fn.next = function ( this: Cash, comparator?: Comparator, _all?: boolean ) { | ||
fn.next = function ( this: Cash, comparator?: Comparator, _all?: boolean, _until?: Comparator ) { | ||
return filtered ( cash ( unique ( pluck ( this, 'nextElementSibling', _all ) ) ), comparator ); | ||
return filtered ( cash ( unique ( pluck ( this, 'nextElementSibling', _all, _until ) ) ), comparator ); | ||
@@ -2471,4 +2688,18 @@ }; | ||
// @require ./next.ts | ||
interface Cash { | ||
nextUntil ( until?: Comparator, comparator?: Comparator): Cash; | ||
} | ||
fn.nextUntil = function ( this: Cash, until?: Comparator, comparator?: Comparator ) { | ||
return this.next ( comparator, true, until ); | ||
}; | ||
// @require core/cash.ts | ||
// @require core/get_compare_function.ts | ||
// @require core/type_checking.ts | ||
// @require collection/filter.ts | ||
@@ -2484,3 +2715,3 @@ | ||
return this.filter ( ( i: number, ele: EleLoose ) => !compare.call ( ele, i, ele ) ); | ||
return this.filter ( ( i: number, ele: EleLoose ) => ( !isString ( comparator ) || isElement ( ele ) ) && !compare.call ( ele, i, ele ) ); | ||
@@ -2532,3 +2763,3 @@ }; | ||
// @optional ./get.ts | ||
// @optional ./indexFn.ts | ||
// @optional ./index_fn.ts | ||
// @optional ./last.ts | ||
@@ -2571,8 +2802,8 @@ // @optional ./map.ts | ||
interface Cash { | ||
parents ( comparator?: Comparator ): Cash; | ||
parents ( comparator?: Comparator, _until?: Comparator ): Cash; | ||
} | ||
fn.parents = function ( this: Cash, comparator?: Comparator ) { | ||
fn.parents = function ( this: Cash, comparator?: Comparator, _until?: Comparator ) { | ||
return filtered ( cash ( unique ( pluck ( this, 'parentElement', true ) ) ), comparator ); | ||
return filtered ( cash ( unique ( pluck ( this, 'parentElement', true, _until ) ) ), comparator ); | ||
@@ -2582,2 +2813,15 @@ }; | ||
// @require ./parents.ts | ||
interface Cash { | ||
parentsUntil ( until?: Comparator, comparator?: Comparator): Cash; | ||
} | ||
fn.parentsUntil = function ( this: Cash, until?: Comparator, comparator?: Comparator ) { | ||
return this.parents ( comparator, until ); | ||
}; | ||
// @require core/cash.ts | ||
@@ -2589,8 +2833,8 @@ // @require core/filtered.ts | ||
interface Cash { | ||
prev ( comparator?: Comparator, _all?: boolean ): Cash; | ||
prev ( comparator?: Comparator, _all?: boolean, _until?: Comparator ): Cash; | ||
} | ||
fn.prev = function ( this: Cash, comparator?: Comparator, _all?: boolean ) { | ||
fn.prev = function ( this: Cash, comparator?: Comparator, _all?: boolean, _until?: Comparator ) { | ||
return filtered ( cash ( unique ( pluck ( this, 'previousElementSibling', _all ) ) ), comparator ); | ||
return filtered ( cash ( unique ( pluck ( this, 'previousElementSibling', _all, _until ) ) ), comparator ); | ||
@@ -2613,2 +2857,15 @@ }; | ||
// @require ./prev.ts | ||
interface Cash { | ||
prevUntil ( until?: Comparator, comparator?: Comparator ): Cash; | ||
} | ||
fn.prevUntil = function ( this: Cash, until?: Comparator, comparator?: Comparator ) { | ||
return this.prev ( comparator, true, until ); | ||
}; | ||
// @require core/cash.ts | ||
@@ -2642,6 +2899,11 @@ // @require core/filtered.ts | ||
// @optional ./next.ts | ||
// @optional ./next_all.ts | ||
// @optional ./next_until.ts | ||
// @optional ./not.ts | ||
// @optional ./parent.ts | ||
// @optional ./parents.ts | ||
// @optional ./parents_until.ts | ||
// @optional ./prev.ts | ||
// @optional ./prev_all.ts | ||
// @optional ./prev_until.ts | ||
// @optional ./siblings.ts | ||
@@ -2648,0 +2910,0 @@ |
{ | ||
"name": "cash-dom", | ||
"description": "An absurdly small jQuery alternative for modern browsers.", | ||
"version": "5.0.0", | ||
"version": "6.0.0", | ||
"license": "MIT", | ||
@@ -27,6 +27,11 @@ "browser": "./dist/cash.js", | ||
"test:karma": "karma start --single-run", | ||
"test:karma:coverage": "karma start --single-run --generate-coverage && open ./coverage/index.html", | ||
"test:karma:sauce": "karma start --single-run --sauce", | ||
"test:jquery": "( git -C ./test/jquery pull || git clone https://github.com/jquery/jquery.git ./test/jquery ) && npm run test:jquery:build && cd ./test/jquery && opn http://localhost:4444/test/index.html\\?module=css && php -S localhost:4444", | ||
"test:jquery:build": "cat ./node_modules/jquery/dist/jquery.js ./dist/cash.js ./test/jquery_patch.js > ./test/jquery/dist/jquery.min.js", | ||
"test:jquery:init": "( git -C ./test/jquery reset --hard HEAD && git -C ./test/jquery pull ) || git clone https://github.com/jquery/jquery.git ./test/jquery", | ||
"test:jquery": "npm run test:jquery:init && npm run test:jquery:build && cd ./test/jquery && npm i && opn http://localhost:4444/test/index.html\\?module=css && php -S localhost:4444", | ||
"test:jquery:build": "cat ./node_modules/jquery/dist/jquery.js ./dist/cash.js ./test/jquery_patch.js > ./test/jquery/dist/jquery.js && cp ./test/jquery/dist/jquery.js ./test/jquery/dist/jquery.min.js", | ||
"test:jquery:build:watch": "while sleep 1; do npm run test:jquery:build; done", | ||
"test:jquery:reverse": "npm run test:jquery:init && npm run test:jquery:reverse:build && npm run test:watch", | ||
"test:jquery:reverse:build": "cat ./node_modules/jquery/dist/jquery.js ./dist/cash.min.js ./test/jquery_reverse_patch.js > ./dist/cash.js", | ||
"test:jquery:reverse:build:watch": "while sleep 1; do npm run test:jquery:reverse:build; done", | ||
"graph": "pacco build-javascript --dependencies-graph --fresh", | ||
@@ -47,5 +52,7 @@ "prepublishOnly": "npm run clean && npm run build:deploy && npm run test:karma" | ||
"browser-sync": "^2.26.3", | ||
"coveralls": "^3.0.9", | ||
"jquery": "^3.3.1", | ||
"karma": "^3.0.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-coverage": "^2.0.1", | ||
"karma-firefox-launcher": "^1.1.0", | ||
@@ -52,0 +59,0 @@ "karma-qunit": "^2.1.0", |
145
README.md
@@ -12,11 +12,11 @@ | ||
| Size | Cash | Zepto 1.2.0 | jQuery 3.3.1 | | ||
| Size | Cash | Zepto 1.2.0 | jQuery 3.4.1 | | ||
| ------------------ | ----------- | ----------- | ------------ | | ||
| Uncompressed | **30 KB** | 58.7 KB | 271 KB | | ||
| Minified | **13.5 KB** | 26 KB | 87 KB | | ||
| Minified & Gzipped | **5 KB** | 9.8 KB | 30.3 KB | | ||
| Unminified | **34.6 KB** | 58.7 KB | 280 KB | | ||
| Minified | **15.2 KB** | 26 KB | 88.1 KB | | ||
| Minified & Gzipped | **5.6 KB** | 9.8 KB | 30.7 KB | | ||
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. | ||
An **82%** 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 | | ||
| Features | Cash | Zepto 1.2.0 | jQuery 3.4.1 | | ||
| ------------------------ | ---------------------------- | ------------------------------ | ------------------------ | | ||
@@ -34,6 +34,6 @@ | Supports Modern Browsers | ✔ | ️✔ | ✔ | | ||
Get Cash from [CloudFlare](https://cdnjs.cloudflare.com/ajax/libs/cash/5.0.0/cash.min.js) or [jsDelivr](https://cdn.jsdelivr.net/npm/cash-dom@5.0.0/dist/cash.min.js) and use it like this: | ||
Get Cash from [CloudFlare](https://cdnjs.cloudflare.com/ajax/libs/cash/6.0.0/cash.min.js) or [jsDelivr](https://cdn.jsdelivr.net/npm/cash-dom@6.0.0/dist/cash.min.js) and use it like this: | ||
```html | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/cash/5.0.0/cash.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/cash/6.0.0/cash.min.js"></script> | ||
<script> | ||
@@ -107,26 +107,25 @@ $(function () { | ||
| Events | Forms | Manipulation | Offset | Traversal | | ||
| ---------------------------- | -------------------------------- | -------------------------------------- | -------------------------------------- | ------------------------------ | | ||
| [fn.off ()](#fnoff-) | [fn.serialize ()](#fnserialize-) | [fn.after ()](#fnafter-) | [fn.offset ()](#fnoffset-) | [fn.children ()](#fnchildren-) | | ||
| [fn.on ()](#fnon-) | [fn.val ()](#fnval-) | [fn.append ()](#fnappend-) | [fn.offsetParent ()](#fnoffsetparent-) | [fn.closest ()](#fnclosest-) | | ||
| [fn.one ()](#fnone-) | | [fn.appendTo ()](#fnappendto-) | [fn.position ()](#fnposition-) | [fn.contents ()](#fncontents-) | | ||
| [fn.ready ()](#fnready-) | | [fn.before ()](#fnbefore-) | | [fn.find ()](#fnfind-) | | ||
| [fn.trigger ()](#fntrigger-) | | [fn.clone ()](#fnclone-) | | [fn.has ()](#fnhas-) | | ||
| | | [fn.detach ()](#fndetach-) | | [fn.is ()](#fnis-) | | ||
| | | [fn.empty ()](#fnempty-) | | [fn.next ()](#fnnext-) | | ||
| | | [fn.html ()](#fnhtml-) | | [fn.nextAll ()](#fnnextall-) | | ||
| | | [fn.insertAfter ()](#fninsertafter-) | | [fn.not ()](#fnnot-) | | ||
| | | [fn.insertBefore ()](#fninsertbefore-) | | [fn.parent ()](#fnparent-) | | ||
| | | [fn.prepend ()](#fnprepend-) | | [fn.parents ()](#fnparents-) | | ||
| | | [fn.prependTo ()](#fnprependto-) | | [fn.prev ()](#fnprev-) | | ||
| | | [fn.remove ()](#fnremove-) | | [fn.prevAll ()](#fnprevall-) | | ||
| | | [fn.replaceAll ()](#fnreplaceall-) | | [fn.siblings ()](#fnsiblings-) | | ||
| | | [fn.replaceWith ()](#fnreplacewith-) | | | | ||
| | | [fn.text ()](#fntext-) | | | | ||
| | | [fn.unwrap ()](#fnunwrap-) | | | | ||
| | | [fn.wrap ()](#fnwrap-) | | | | ||
| | | [fn.wrapAll ()](#fnwrapall-) | | | | ||
| | | [fn.wrapInner ()](#fnwrapinner-) | | | | ||
| Events | Forms | Manipulation | Offset | Traversal | | ||
| ---------------------------- | -------------------------------- | -------------------------------------- | -------------------------------------- | -------------------------------------- | | ||
| [fn.off ()](#fnoff-) | [fn.serialize ()](#fnserialize-) | [fn.after ()](#fnafter-) | [fn.offset ()](#fnoffset-) | [fn.children ()](#fnchildren-) | | ||
| [fn.on ()](#fnon-) | [fn.val ()](#fnval-) | [fn.append ()](#fnappend-) | [fn.offsetParent ()](#fnoffsetparent-) | [fn.closest ()](#fnclosest-) | | ||
| [fn.one ()](#fnone-) | | [fn.appendTo ()](#fnappendto-) | [fn.position ()](#fnposition-) | [fn.contents ()](#fncontents-) | | ||
| [fn.ready ()](#fnready-) | | [fn.before ()](#fnbefore-) | | [fn.find ()](#fnfind-) | | ||
| [fn.trigger ()](#fntrigger-) | | [fn.clone ()](#fnclone-) | | [fn.has ()](#fnhas-) | | ||
| | | [fn.detach ()](#fndetach-) | | [fn.is ()](#fnis-) | | ||
| | | [fn.empty ()](#fnempty-) | | [fn.next ()](#fnnext-) | | ||
| | | [fn.html ()](#fnhtml-) | | [fn.nextAll ()](#fnnextall-) | | ||
| | | [fn.insertAfter ()](#fninsertafter-) | | [fn.nextUntil ()](#fnnextuntil-) | | ||
| | | [fn.insertBefore ()](#fninsertbefore-) | | [fn.not ()](#fnnot-) | | ||
| | | [fn.prepend ()](#fnprepend-) | | [fn.parent ()](#fnparent-) | | ||
| | | [fn.prependTo ()](#fnprependto-) | | [fn.parents ()](#fnparents-) | | ||
| | | [fn.remove ()](#fnremove-) | | [fn.parentsUntil ()](#fnparentsuntil-) | | ||
| | | [fn.replaceAll ()](#fnreplaceall-) | | [fn.prev ()](#fnprev-) | | ||
| | | [fn.replaceWith ()](#fnreplacewith-) | | [fn.prevAll ()](#fnprevall-) | | ||
| | | [fn.text ()](#fntext-) | | [fn.prevUntil ()](#fnprevuntil-) | | ||
| | | [fn.unwrap ()](#fnunwrap-) | | [fn.siblings ()](#fnsiblings-) | | ||
| | | [fn.wrap ()](#fnwrap-) | | | | ||
| | | [fn.wrapAll ()](#fnwrapall-) | | | | ||
| | | [fn.wrapInner ()](#fnwrapinner-) | | | | ||
#### $.fn | ||
@@ -251,6 +250,7 @@ | ||
Removes collection elements from the DOM. | ||
Removes collection elements, optionally that match the selector, from the DOM. | ||
```js | ||
$(element).detach () // => collection | ||
$(element).detach ( selector ) // => collection | ||
``` | ||
@@ -483,2 +483,11 @@ | ||
#### fn.nextUntil () | ||
Returns all the next elements, until the provided selector matches. | ||
```js | ||
$(element).nextUntil ( selector ) // => collection | ||
$(element).nextUntil ( selector, filterSelector ) // => collection | ||
``` | ||
#### fn.not () | ||
@@ -587,2 +596,11 @@ | ||
#### fn.parentsUntil () | ||
Returns collection of elements who are parents of elements, until a provided selector matches. Optionally filtering by selector. | ||
```js | ||
$(element).parentsUntil ( selector ) // => collection | ||
$(element).parentsUntil ( selector, filterSelector ) // => collection | ||
``` | ||
#### fn.position () | ||
@@ -632,2 +650,11 @@ | ||
#### fn.prevUntil () | ||
Returns all the previous elements, until the provided selector matches. | ||
```js | ||
$(element).prevUntil ( selector ) // => collection | ||
$(element).prevUntil ( selector, filterSelector ) // => collection | ||
``` | ||
#### fn.prop () | ||
@@ -655,6 +682,7 @@ | ||
Removes collection elements from the DOM and removes all their event listeners. | ||
Removes collection elements, optionally that match the selector, from the DOM and removes all their event listeners. | ||
```js | ||
$(element).remove () // => collection | ||
$(element).remove ( selector ) // => collection | ||
``` | ||
@@ -836,3 +864,3 @@ | ||
```js | ||
$.isString ( str ) // => boolean | ||
$.isArray ( arr ) // => boolean | ||
``` | ||
@@ -842,12 +870,9 @@ | ||
| Type Checking | Utilities | | ||
| ------------------------------- | ----------------------------------- | | ||
| [$.isArray ()](#isarray-) | [$.guid](#guid) | | ||
| [$.isFunction ()](#isfunction-) | [$.camelCase ()](#camelcase-) | | ||
| [$.isNumeric ()](#isnumeric-) | [$.each ()](#each-) | | ||
| [$.isString ()](#isstring-) | [$.extend ()](#extend-) | | ||
| [$.isWindow ()](#iswindow-) | [$.matches ()](#matches-) | | ||
| | [$.parseHTML ()](#parsehtml-) | | ||
| | [$.prefixedProp ()](#prefixedprop-) | | ||
| | [$.unique ()](#unique-) | | ||
| Type Checking | Utilities | | ||
| ------------------------------- | ----------------------------- | | ||
| [$.isArray ()](#isarray-) | [$.guid](#guid) | | ||
| [$.isFunction ()](#isfunction-) | [$.each ()](#each-) | | ||
| [$.isNumeric ()](#isnumeric-) | [$.extend ()](#extend-) | | ||
| [$.isWindow ()](#iswindow-) | [$.parseHTML ()](#parsehtml-) | | ||
| | [$.unique ()](#unique-) | | ||
@@ -862,10 +887,2 @@ #### $.guid | ||
#### $.camelCase () | ||
Transforms a string to camelCase. | ||
```js | ||
$.camelCase ( 'border-width' ) // => 'borderWidth' | ||
``` | ||
#### $.each () | ||
@@ -912,10 +929,2 @@ | ||
#### $.isString () | ||
Check if the argument is a string. | ||
```js | ||
$.isString ( 'hello' ) // => true | ||
``` | ||
#### $.isWindow () | ||
@@ -929,10 +938,2 @@ | ||
#### $.matches () | ||
Checks a selector against an element, returning a boolean value for match. | ||
```js | ||
$.matches ( element, selector ) // => boolean | ||
``` | ||
#### $.parseHTML () | ||
@@ -946,10 +947,2 @@ | ||
#### $.prefixedProp () | ||
Return a prefixed CSS property, if necessary. | ||
```js | ||
$.prefixedProp ( 'transform' ) // => 'mozTransform' | ||
``` | ||
#### $.unique () | ||
@@ -956,0 +949,0 @@ |
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
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
224323
4267
14
963