Skip to content

Instantly share code, notes, and snippets.

View poliphilochu's full-sized avatar

Poliphilo Chu poliphilochu

View GitHub Profile
@poliphilochu
poliphilochu / two-way-binding.js
Created May 17, 2021 08:33 — forked from straker/two-way-binding.js
Simple and small two-way data binding between DOM and data
/**
* @param {object} scope - Object that all bound data will be attached to.
*/
function twoWayBind(scope) {
// a list of all bindings used in the DOM
// @example
// { 'person.name': [<input type="text" data-bind="person.name"/>] }
var bindings = {};
// each bindings old value to be compared for changes