UNPKG

@danielkalen/simplybind

Version:

Magically simple, framework-less one-way/two-way data binding for frontend/backend in ~5kb.

25 lines (13 loc) 793 B
isBinding: (subject)-> subject instanceof Binding isIterable: (subject)-> checkIf.isObject(subject) and checkIf.isNumber(subject.length) isDom: (subject)-> subject.nodeName and subject.nodeType is 1 isDomInput: (subject)-> nodeName = subject.nodeName.toUpperCase() return nodeName is 'INPUT' or nodeName is 'TEXTAREA' or nodeName is 'SELECT' isDomRadio: (subject)-> subject.type is 'radio' isDomCheckbox: (subject)-> subject.type is 'checkbox' isElCollection: (subject)-> (subject instanceof NodeList) or (subject instanceof HTMLCollection) or (checkIf.isDefined(jQuery) and subject instanceof jQuery) domElsAreSame: (iterable)-> type = iterable[0].type itemsWithSameType = [].filter.call iterable, (item)-> item.type is type return itemsWithSameType.length is iterable.length