diff --git a/dist/moon.js b/dist/moon.js index 19169be4..bc5e40d6 100644 --- a/dist/moon.js +++ b/dist/moon.js @@ -476,7 +476,19 @@ this.emit("created"); }; - var update = function() { + var update = function(key, value) { + var this$1 = this; + + if (key !== undefined) { + if (typeof key === "object") { + for (var childKey in key) { + this$1.data[childKey] = key[childKey]; + } + } else { + this.data[key] = value; + } + } + if (this.queued === false) { this.queued = true; @@ -494,19 +506,6 @@ this.emit("destroyed"); }; - var set = function(key, value) { - var this$1 = this; - - if (typeof key === "object") { - for (var childKey in key) { - this$1.set(childKey, key[childKey]); - } - } else { - this.data[key] = value; - this.update(); - } - }; - var on = function(type, handler) { var data = this.data; var handlers = data[type]; @@ -554,6 +553,7 @@ var this$1 = this; this.name = name; + this.queued = false; this.view = options.view.map(function (view) { return view.bind(this$1); }); this.m = m(); @@ -564,11 +564,9 @@ data[action] = actions[action].bind(this$1); } - this.queued = false; this.create = create; this.update = update; this.destroy = destroy; - this.set = set; this.on = on; this.off = off; this.emit = emit; diff --git a/dist/moon.min.js b/dist/moon.min.js index 4f9d349f..bb8212cf 100644 --- a/dist/moon.min.js +++ b/dist/moon.min.js @@ -4,4 +4,4 @@ * Released under the MIT License * https://kbrsh.github.io/moon */ -!function(e,t){"undefined"==typeof module?e.Moon=t():module.exports=t()}(this,function(){"use strict";var u=/"[^"]*"|'[^']*'|\d+[a-zA-Z$_]\w*|\.[a-zA-Z$_]\w*|[a-zA-Z$_]\w*:|([a-zA-Z$_]\w*)/g,a=["NaN","event","false","in","m","null","this","true","typeof","undefined"],s=function(e,t){for(var n,i=!1;null!==(n=u.exec(e));){var r=n[1];void 0!==r&&-1===a.indexOf(r)&&"$"!==r[0]&&(i=!0,-1===t.indexOf(r)&&t.push(r))}return i},e={silent:!0},d=/\s+/,v=function(e,t,n,i,r){for(;e"===u)break;if(d.test(u))e+=1;else{for(var a="",o="",c=!1;e"===u||d.test(u)){o=a;break}if("="===u){e+=1;break}a+=u,e+=1}if(0===o.length){var f=void 0;for('"'===(u=t[e])||"'"===u?(f=u,e+=1):"{"===u?(f="}",c=!0,e+=1):f=d;e"!==u;){if("object"==typeof f&&f.test(u)||u===f){e+=1;break}o+=u,e+=1}}r.push({key:a,value:o,expression:c,dynamic:c&&s(o,i)})}}return e},o=function(e,t,n,i,r){for(var u={index:i[0].nextIndex++,type:"",attributes:[],children:[]};e"===a){var o=u.attributes;i.push(u);for(var c=0;c"===t[e+1]){i[i.length-1].children.push(u),e+=2;break}d.test(a)&&(e+=1)||"="===a?e=v(e,t,n,r,u.attributes):(u.type+=a,e+=1)}return e},c=function(e,t,n,i){for(;e"===r){e+=1;break}r}var u=i.pop();return u.type,e},f=function(e,t,n){for(;e"===u){e+=3;break}e+=1}}return e},h=/(?:(?:&(?:amp|gt|lt|nbsp|quot);)|"|\\|\n)/g,l={"&":"&",">":">","<":"<"," ":" ",""":'\\"',"\\":"\\\\",'"':'\\"',"\n":"\\n"},p=function(e,t,n,i){for(var r="";e"===u)break;if(d.test(u))e+=1;else{for(var a="",o="",c=!1;e"===u||d.test(u)){o=a;break}if("="===u){e+=1;break}a+=u,e+=1}if(0===o.length){var f=void 0;for('"'===(u=t[e])||"'"===u?(f=u,e+=1):"{"===u?(f="}",c=!0,e+=1):f=d;e"!==u;){if("object"==typeof f&&f.test(u)||u===f){e+=1;break}o+=u,e+=1}}r.push({key:a,value:o,expression:c,dynamic:c&&s(o,i)})}}return e},o=function(e,t,n,i,r){for(var u={index:i[0].nextIndex++,type:"",attributes:[],children:[]};e"===a){var o=u.attributes;i.push(u);for(var c=0;c"===t[e+1]){i[i.length-1].children.push(u),e+=2;break}d.test(a)&&(e+=1)||"="===a?e=v(e,t,n,r,u.attributes):(u.type+=a,e+=1)}return e},c=function(e,t,n,i){for(;e"===r){e+=1;break}r}var u=i.pop();return u.type,e},f=function(e,t,n){for(;e"===u){e+=3;break}e+=1}}return e},h=/(?:(?:&(?:amp|gt|lt|nbsp|quot);)|"|\\|\n)/g,l={"&":"&",">":">","<":"<"," ":" ",""":'\\"',"\\":"\\\\",'"':'\\"',"\n":"\\n"},p=function(e,t,n,i){for(var r="";e { return function MoonComponent() { this.name = name; + this.queued = false; this.view = options.view.map((view) => view.bind(this)); this.m = m(); @@ -89,11 +89,9 @@ export const component = (name, options) => { data[action] = actions[action].bind(this); } - this.queued = false; this.create = create; this.update = update; this.destroy = destroy; - this.set = set; this.on = on; this.off = off; this.emit = emit;