From 5342b8a11dfdf71091a9d42aa402bf16293459f1 Mon Sep 17 00:00:00 2001 From: Kabir Shah Date: Fri, 7 Apr 2017 13:36:00 -0700 Subject: [PATCH] refactor special directive after generation --- dist/moon.js | 6 +++--- dist/moon.min.js | 2 +- src/compiler/generator.js | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dist/moon.js b/dist/moon.js index 85440f47..d47169cf 100644 --- a/dist/moon.js +++ b/dist/moon.js @@ -1232,15 +1232,15 @@ if ((specialDirective = specialDirectives[attrName]) !== undefined) { // Generate Special Directives // Special directive found that generates code after initial generation, push it to its known special directives to run afterGenerate later - if (specialDirective.afterGenerate) { - if (!vnode.specialDirectivesAfter) { + if (specialDirective.afterGenerate !== undefined) { + if (vnode.specialDirectivesAfter === undefined) { vnode.specialDirectivesAfter = {}; } vnode.specialDirectivesAfter[attr] = attrInfo; } // Invoke any special directives that need to change values of props during code generation - if (specialDirective.duringPropGenerate) { + if (specialDirective.duringPropGenerate !== undefined) { generatedObject += specialDirective.duringPropGenerate(attrInfo.value, attrInfo.meta, vnode); } diff --git a/dist/moon.min.js b/dist/moon.min.js index 4db991d1..a560410f 100644 --- a/dist/moon.min.js +++ b/dist/moon.min.js @@ -4,4 +4,4 @@ * Released under the MIT License * http://moonjs.ga */ -!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||$,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={},i={},o={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 r in t)!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)}(r)};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;ta?s:a,p=0;p",e.current);if(n===-1)return 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)}),e.current=n+3},V=function(e){var t=e.input,r=(t.length,"/"===t.charAt(e.current+1));e.current+=r?2:1;var n=H(e);q(n,e);var i="/"===t.charAt(e.current);e.current+=i?2:1,(r||i)&&(n.close=!0)},H=function(e){for(var t=e.input,r=t.length,n=e.current,i="";n"===o||" "===o)break;i+=o,n++}var s={type:"tag",value:i};return e.tokens.push(s),e.current=n,s},q=function(e,t){for(var r=t.input,n=r.length,i=t.current,o=r.charAt(i),s=r.charAt(i+1),a=function(){i++,o=r.charAt(i),s=r.charAt(i+1)},u={};i"!==o&&("/"!==o||">"!==s);)if(" "!==o){for(var l="",p=!1;i"===o||"/"===o||">"===s){p=!0;break}l+=o,a()}var c={name:l,value:"",meta:{}};if(p)u[l]=c;else{a();var f=" ";for("'"!==o&&'"'!==o||(f=o,a());i1&&(a=u.shift(),s=u.join("(").slice(0,-1));var l="";n.shift();for(var p=0;pa?s:a,p=0;p",e.current);if(n===-1)return 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)}),e.current=n+3},V=function(e){var t=e.input,r=(t.length,"/"===t.charAt(e.current+1));e.current+=r?2:1;var n=H(e);q(n,e);var i="/"===t.charAt(e.current);e.current+=i?2:1,(r||i)&&(n.close=!0)},H=function(e){for(var t=e.input,r=t.length,n=e.current,i="";n"===o||" "===o)break;i+=o,n++}var s={type:"tag",value:i};return e.tokens.push(s),e.current=n,s},q=function(e,t){for(var r=t.input,n=r.length,i=t.current,o=r.charAt(i),s=r.charAt(i+1),a=function(){i++,o=r.charAt(i),s=r.charAt(i+1)},u={};i"!==o&&("/"!==o||">"!==s);)if(" "!==o){for(var l="",p=!1;i"===o||"/"===o||">"===s){p=!0;break}l+=o,a()}var c={name:l,value:"",meta:{}};if(p)u[l]=c;else{a();var f=" ";for("'"!==o&&'"'!==o||(f=o,a());i1&&(a=u.shift(),s=u.join("(").slice(0,-1));var l="";n.shift();for(var p=0;p