UNPKG

@danielkalen/simplybind

Version:

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

31 lines (24 loc) 856 B
cache = get: (object, isFunction, selector, isMultiChoice)-> if isFunction return boundInstances[object._sb_ID] else # simplyimport:if BUNDLE_TARGET = 'browser' if isMultiChoice and object[0]._sb_map sampleItem = boundInstances[ object[0]._sb_map[selector] ] return sampleItem.groupBinding if sampleItem.groupBinding # simplyimport:end if object._sb_map and object._sb_map[selector] return boundInstances[ object._sb_map[selector] ] set: (B, isFunction)-> # B ==== Binding Object if isFunction defineProperty B.object, '_sb_ID', {'configurable':true, 'value':B.ID} else selector = B.selector if B.object._sb_map B.object._sb_map[selector] = B.ID else propsMap = {} propsMap[selector] = B.ID defineProperty B.object, '_sb_map', {'configurable':true, 'value':propsMap} return