diff --git a/dist/moon.js b/dist/moon.js
index 49a7410e..8256dd9f 100644
--- a/dist/moon.js
+++ b/dist/moon.js
@@ -34,7 +34,7 @@
* @param {Object} computed
*/
var initComputed = function (instance, computed) {
- for (var prop in computed) {
+ var setComputedProperty = function (prop) {
var properties = {
get: function () {
return computed[prop].get.call(instance);
@@ -46,6 +46,9 @@
};
}
Object.defineProperty(instance.$data, prop, properties);
+ };
+ for (var propName in computed) {
+ setComputedProperty(propName);
}
};
diff --git a/dist/moon.min.js b/dist/moon.min.js
index 6c10e138..8b73e85e 100644
--- a/dist/moon.min.js
+++ b/dist/moon.min.js
@@ -5,4 +5,4 @@
* Free to use under the MIT license.
* https://kingpixil.github.io/license
*/
-!function(e,t){"object"==typeof module&&module.exports?module.exports=t():e.Moon=t()}(this,function(){"use strict";function e(e){this.instance=e}function t(t){this.$opts=t||{},this.$id=s++,this.$name=this.$opts.name||"root",this.$data=this.$opts.data||{},this.$render=this.$opts.render||L,this.$hooks=this.$opts.hooks||{},this.$methods=this.$opts.methods||{},this.$events={},this.$dom={},this.$observer=new e(this),this.$destroyed=!1,this.$initialRender=!0,this.$queued=!1,this.$opts.computed&&a(this,this.$opts.computed),this.init()}var n={},r={},o={},i={stop:"event.stopPropagation();",prevent:"event.preventDefault();",ctrl:"if(!event.ctrlKey) {return;};",shift:"if(!event.shiftKey) {return;};",alt:"if(!event.altKey) {return;};",enter:"if(event.keyCode !== 13) {return;};"},s=0,a=function(e,t){for(var n in t){var r={get:function(){return t[n].get.call(e)}};t[n].set&&(r.set=function(r){return t[n].set.call(e,r)}),Object.defineProperty(e.$data,n,r)}};e.prototype.notify=function(){p(this.instance)};var c=function(e){t.config.silent||console.log(e)},u=function(e){console.error("[Moon] ERR: "+e)},p=function(e){e.$queued||e.$destroyed||(e.$queued=!0,setTimeout(function(){e.build(),G(e,"updated"),e.$queued=!1},0))},l=function(e){for(var t={},n=e.attributes,r=n.length;r--;)t[n[r].name]=n[r].value;return e.__moon__props__=t,t},f=function(){return{shouldRender:!0,eventListeners:{}}},h=function(e){var t=/\n/g,n=/"/g,r=/\\/g;return e.replace(r,"\\\\").replace(n,'\\"').replace(t,"\\n")},v=function(e,t,n,r){var o;n.replace(/\[(\w+)\]/g,function(e,t){n=n.replace(e,"."+t)});var i=n.split(".");for(o=0;o
{{reversed}}
'); + var computedApp = new Moon({ + el: "#computed", + data: { + msg: "Message" + }, + computed: { + reversed: { + get: function() { + return this.get('msg').split("").reverse().join(""); + } + } + } + }); + it('should compute at initial render', function() { + expect(computedAppEl.childNodes[1].textContent).to.equal("egasseM"); + }); + it('should update when the message updates', function() { + computedApp.set('msg', 'New'); + Moon.nextTick(function() { + expect(computedAppEl.childNode[1].textContent).to.equal('weN'); + }); + }); +}); + describe("Directive", function() { describe('Custom Directive', function() { createTestElement("customDirective", '');