// bindings.js BoxInfo.prototype = { get content() { if (!this.box) return null; return this.box.value; }, set content(w) { if (!this.box) return; this.box.value = w; }, } function BoxInfo() { this.box = null; this.setBox = function(newBox) { // store the new box value, with KVO notifcations JSKVC.willChange(document, 'boxInfo'); this.box = newBox; JSKVC.didChange(document, 'boxInfo'); } } function installBoxInfo() { // create an BoxInfo object for the document, using KVO notifications JSKVC.willChange(document, 'boxInfo'); document.boxInfo = new BoxInfo(); JSKVC.didChange(document, 'boxInfo'); var boxElement = document.getElementById( 'box' ); document.boxInfo.setBox(boxElement); //boxElement.setAttribute('style', 'outline: -3px solid white;'); boxElement.onblur = function() { JSKVC.willChange(document, 'boxInfo'); JSKVC.didChange(document, 'boxInfo'); }; }