JSFiddle - React, Tailwind, and code Playground
by ifandelse
HTML
<script src="https://raw.github.com/documentcloud/underscore/master/underscore.js"></script>
JavaScript
var ProxyProvider = function() {
ProxyProvider.prototype.wrap = function() {
throw "This browser does not support getters and setters on JavaScript objects";
};
if(Object.defineProperty) {
this.wrap = function(context, subject, memberName, namespace) {
Object.defineProperty(context, memberName, {
set : function (x) {
var old = subject[memberName];
if(typeof x === 'object') {
subject[memberName] = new Proxify(namespace, x);
}
else {
subject[memberName] = x;
}
//postal.publish(namespace + "._changed", { oldValue: old, newValue: x });
},
get : function () {
//postal.publish(namespace + "._read");
return subject[memberName];
},
enumerable: true
});
}
}
else if(Object.prototype.__defineSetter__ && Object.prototype.__defineGetter__) {
this.wrap = function(context, subject, memberName, namespace) {
//setter
context.__defineSetter__(memberName, function(x) {
var old = subject[memberName];
if(typeof x === 'object') {
subject[memberName] = new Proxify(namespace, x);
}
else {
subject[memberName] = x;
}
//postal.publish(namespace + "._changed", { oldValue: old, newValue: x });
});
//getter
context.__defineGetter__(memberName, function() {
//postal.publish(namespace + "._read");
return subject[memberName];
});
}
}
};
var provider = new ProxyProvider();
var ArrayProxy = function(subject, namespace) {
return subject;
};
var ObjectProxy = function(subject, namespace)...