diff --git a/dist/moon.js b/dist/moon.js index 7873a48d..9280fa53 100644 --- a/dist/moon.js +++ b/dist/moon.js @@ -1085,28 +1085,23 @@ var endOfText = input.substring(current).search(tagOrCommentStartRE); - // Only Text if (endOfText === -1) { + // Only Text state.tokens.push({ type: "text", value: input.slice(current) }); state.current = len; return; + } else if (endOfText !== 0) { + // End of Text Found + endOfText += current; + state.tokens.push({ + type: "text", + value: input.slice(current, endOfText) + }); + state.current = endOfText; } - - // No Text at All - if (endOfText === 0) { - return; - } - - // End of Text Found - endOfText += current; - state.tokens.push({ - type: "text", - value: input.slice(current, endOfText) - }); - state.current = endOfText; }; var lexComment = function (state) { @@ -1118,22 +1113,21 @@ var endOfComment = input.indexOf("-->", current); - // Only an unclosed comment if (endOfComment === -1) { + // Only an unclosed comment state.tokens.push({ type: "comment", value: input.slice(current) }); state.current = len; - return; + } else { + // End of Comment Found + state.tokens.push({ + type: "comment", + value: input.slice(current, endOfComment) + }); + state.current = endOfComment + 3; } - - // End of Comment Found - state.tokens.push({ - type: "comment", - value: input.slice(current, endOfComment) - }); - state.current = endOfComment + 3; }; var lexTag = function (state) { @@ -1210,7 +1204,7 @@ break; } - // If there is a space, the attribute ended + // If there is a space, skip if (char === " ") { incrementChar(); continue; @@ -1221,11 +1215,11 @@ var noValue = false; while (current < len && char !== "=") { - if (char !== " " && char !== ">" && char !== "/" && nextChar !== ">") { - attrName += char; - } else { + if (char === " " || char === ">" || char === "/" && nextChar === ">") { noValue = true; break; + } else { + attrName += char; } incrementChar(); } @@ -1236,7 +1230,7 @@ meta: {} }; - if (noValue) { + if (noValue === true) { attributes[attrName] = attrValue; continue; } diff --git a/dist/moon.min.js b/dist/moon.min.js index 6e0016b9..86b0083d 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.setters={},this.clear={},this.target=null,this.map={}}function t(t){void 0===t&&(t={}),this.$options=t;var r=this;this.$id=a++,y(this,"$name",t.name,"root");var n=t.data;this.$data=void 0===n?{}:"function"==typeof n?n():n,y(this,"$render",t.render,k),y(this,"$hooks",t.hooks,{});var i=t.methods;void 0!==i&&s(r,i),this.$events={},this.$dom={},this.$observer=new e(this),this.$destroyed=!0,this.$queued=!1;var o=t.computed;void 0!==o&&l(this,o),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;};"},a=0,s=function(e,t){for(var r in t)!function(t,r){e.$data[t]=function(){return r.apply(e,arguments)}}(r,t[r])},l=function(e,t){for(var r in t)!function(r){var n=e.$observer;n.observe(r),Object.defineProperty(e.$data,r,{get:function(){var i=null;return void 0===n.cache[r]?(n.target=r,i=t[r].get.call(e),n.target=null,n.cache[r]=i):i=n.cache[r],i},set:k});var i=null;void 0!==(i=t[r].set)&&(n.setters[r]=i)}(r)};e.prototype.observe=function(e){var t=this;this.clear[e]=function(){t.cache[e]=void 0}},e.prototype.notify=function(e,t){var r=null;if(void 0!==(r=this.map[e]))for(var n=0;nc?u:c,p=0,d=0;p"===o||" "===o)break;i+=o,n++}var a={type:"tag",value:i};return e.tokens.push(a),e.current=n,a},W=function(e,t){for(var r=t.input,n=r.length,i=t.current,o=r.charAt(i),a=r.charAt(i+1),s=function(){i++,o=r.charAt(i),a=r.charAt(i+1)},l={};i"!==o&&("/"!==o||">"!==a);)if(" "!==o){for(var u="",c=!1;i"===o||"/"===o||">"===a){c=!0;break}u+=o,s()}var v={name:u,value:"",meta:{}};if(c)l[u]=v;else{s();var f=" ";for("'"!==o&&'"'!==o||(f=o,s());i1&&(a=c.shift(),u=c.join("(").slice(0,-1),q(u,i));for(var v="",f=0;fc?u:c,p=0,d=0;p"===o||" "===o)break;i+=o,n++}var a={type:"tag",value:i};return e.tokens.push(a),e.current=n,a},W=function(e,t){for(var r=t.input,n=r.length,i=t.current,o=r.charAt(i),a=r.charAt(i+1),s=function(){i++,o=r.charAt(i),a=r.charAt(i+1)},l={};i"!==o&&("/"!==o||">"!==a);)if(" "!==o){for(var u="",c=!1;i"===o||"/"===o&&">"===a){c=!0;break}u+=o,s()}var v={name:u,value:"",meta:{}};if(!0!==c){s();var f=" ";for("'"!==o&&'"'!==o||(f=o,s());i1&&(a=c.shift(),u=c.join("(").slice(0,-1),q(u,i));for(var v="",f=0;f", current); - // Only an unclosed comment if(endOfComment === -1) { + // Only an unclosed comment state.tokens.push({ type: "comment", value: input.slice(current) }); state.current = len; - return; + } else { + // End of Comment Found + state.tokens.push({ + type: "comment", + value: input.slice(current, endOfComment) + }); + state.current = endOfComment + 3; } - - // End of Comment Found - state.tokens.push({ - type: "comment", - value: input.slice(current, endOfComment) - }); - state.current = endOfComment + 3; } const lexTag = function(state) { @@ -163,7 +157,7 @@ const lexAttributes = function(tagToken, state) { break; } - // If there is a space, the attribute ended + // If there is a space, skip if(char === " ") { incrementChar(); continue; @@ -174,11 +168,11 @@ const lexAttributes = function(tagToken, state) { let noValue = false; while(current < len && char !== "=") { - if((char !== " ") && (char !== ">") && (char !== "/" && nextChar !== ">")) { - attrName += char; - } else { + if((char === " ") || (char === ">") || (char === "/" && nextChar === ">")) { noValue = true; break; + } else { + attrName += char; } incrementChar(); } @@ -189,7 +183,7 @@ const lexAttributes = function(tagToken, state) { meta: {} } - if(noValue) { + if(noValue === true) { attributes[attrName] = attrValue; continue; }