diff --git a/dist/moon.js b/dist/moon.js index b066a71e..2c0b9c00 100644 --- a/dist/moon.js +++ b/dist/moon.js @@ -1530,6 +1530,12 @@ } }; + specialDirectives[Moon.config.prefix + "show"] = { + duringPropGenerate: function (value, meta, vnode) { + return '"m-show": ' + compileTemplate(value, false) + ', '; + } + }; + specialDirectives[Moon.config.prefix + "for"] = { afterGenerate: function (value, meta, code, vnode) { var parts = value.split(" in "); @@ -1658,12 +1664,7 @@ }; directives[Moon.config.prefix + "show"] = function (el, val, vnode) { - var evaluated = new Function("return " + val); - if (!evaluated()) { - el.style.display = 'none'; - } else { - el.style.display = 'block'; - } + el.style.display = val ? '' : 'none'; }; directives[Moon.config.prefix + "mask"] = function (el, val, vnode) {}; diff --git a/dist/moon.min.js b/dist/moon.min.js index 1d4f7d0e..0599ce3d 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,this.cache={},this.signals={},this.dep={target:null,map:{}}}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||S,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 r={},n={},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){var r=function(r){e.$observer.observe(r);var n={get:function(){var n=null;return e.$observer.cache[r]?n=e.$observer.cache[r]:(e.$observer.dep.target=r,n=t[r].get.call(e),e.$observer.dep.target=null,e.$observer.cache[r]=n),n}};t[r].set&&(n.set=function(n){return t[r].set.call(e,n)}),Object.defineProperty(e.$data,r,n)};for(var n in t)r(n)};e.prototype.observe=function(e){var t=this;this.signals[e]=function(){t.cache[e]=null}},e.prototype.notify=function(e){if(this.dep.map[e])for(var t=0;t",e.current);return n===-1?(e.tokens.push({type:"comment",value:t.slice(e.current)}),void(e.current=r)):(e.tokens.push({type:"comment",value:t.slice(e.current,n)}),void(e.current=n+3))},T=function(e){var t=e.input,r=(t.length,"/"===t.charAt(e.current+1));e.tokens.push({type:"tagStart",close:r}),e.current+=r?2:1;var n=N(e);j(e);var o="/"===t.charAt(e.current);e.tokens.push({type:"tagEnd",close:!1}),e.current+=o?2:1,o&&(e.tokens.push({type:"tagStart",close:!0}),e.tokens.push({type:"tag",value:n}),e.tokens.push({type:"attribute",value:{}}),e.tokens.push({type:"tagEnd",close:!1}))},N=function(e){for(var t=e.input,r=t.length,n=e.current;n"!==o&&" "!==o)break;n++}for(var i=n;i"===o||" "===o)break;i++}var s=t.slice(n,i);return e.tokens.push({type:"tag",value:s}),e.current=i,s},j=function(e){for(var t=e.input,r=t.length,n=e.current,o={},i=t.charAt(n),s=t.charAt(n+1),a=function(){n++,i=t.charAt(n),s=t.charAt(n+1)};n"!==i&&("/"!==i||">"!==s);)if(" "!==i){for(var p="",c=!1;"="!==i&&n"!==i||"/"===i&&">"!==s)){c=!0;break}p+=i,a()}if(c)o[p]="";else{var u={meta:{},value:""},l=" ";for(a(),"'"===i||'"'===i?(l=i,a()):u.value+=i;(i!==l&&">"!==i||"/"===i&&">"!==s)&&n1&&(a=p.shift(),s=p.join("(").slice(0,-1));var c="";n.shift();for(var u=0;u",e.current);return n===-1?(e.tokens.push({type:"comment",value:t.slice(e.current)}),void(e.current=r)):(e.tokens.push({type:"comment",value:t.slice(e.current,n)}),void(e.current=n+3))},T=function(e){var t=e.input,r=(t.length,"/"===t.charAt(e.current+1));e.tokens.push({type:"tagStart",close:r}),e.current+=r?2:1;var n=N(e);j(e);var o="/"===t.charAt(e.current);e.tokens.push({type:"tagEnd",close:!1}),e.current+=o?2:1,o&&(e.tokens.push({type:"tagStart",close:!0}),e.tokens.push({type:"tag",value:n}),e.tokens.push({type:"attribute",value:{}}),e.tokens.push({type:"tagEnd",close:!1}))},N=function(e){for(var t=e.input,r=t.length,n=e.current;n"!==o&&" "!==o)break;n++}for(var i=n;i"===o||" "===o)break;i++}var s=t.slice(n,i);return e.tokens.push({type:"tag",value:s}),e.current=i,s},j=function(e){for(var t=e.input,r=t.length,n=e.current,o={},i=t.charAt(n),s=t.charAt(n+1),a=function(){n++,i=t.charAt(n),s=t.charAt(n+1)};n"!==i&&("/"!==i||">"!==s);)if(" "!==i){for(var p="",c=!1;"="!==i&&n"!==i||"/"===i&&">"!==s)){c=!0;break}p+=i,a()}if(c)o[p]="";else{var u={meta:{},value:""},l=" ";for(a(),"'"===i||'"'===i?(l=i,a()):u.value+=i;(i!==l&&">"!==i||"/"===i&&">"!==s)&&n1&&(a=p.shift(),s=p.join("(").slice(0,-1));var c="";n.shift();for(var u=0;u