From 5c08af71bc1c5134b0f83da82dd828112b434ab6 Mon Sep 17 00:00:00 2001 From: Kabir Shah Date: Sat, 15 Apr 2017 10:43:58 -0700 Subject: [PATCH] allow lexer to handle unclosed elements (fixes #35) --- dist/moon.js | 5 +++-- dist/moon.min.js | 2 +- src/compiler/lexer.js | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dist/moon.js b/dist/moon.js index 59035cf3..b32bb73d 100644 --- a/dist/moon.js +++ b/dist/moon.js @@ -999,7 +999,7 @@ var lexText = function (state) { var input = state.input; var len = input.length; - var endOfText = input.substring(state.current).search(tagStartRE) + state.current; + var endOfText = input.substring(state.current).search(tagStartRE); // Only Text if (endOfText === -1) { @@ -1012,11 +1012,12 @@ } // No Text at All - if (endOfText === state.current) { + if (endOfText === 0) { return; } // End of Text Found + endOfText += state.current; state.tokens.push({ type: "text", value: input.slice(state.current, endOfText) diff --git a/dist/moon.min.js b/dist/moon.min.js index c1e88c91..d4e53a16 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){this.$opts=t||{};var r=this;this.$id=a++,this.$name=this.$opts.name||"root",this.$data=this.$opts.data||{},this.$render=this.$opts.render||b,this.$hooks=this.$opts.hooks||{};var n=this.$opts.methods;void 0!==n&&s(r,n),this.$events={},this.$dom={},this.$observer=new e(this),this.$destroyed=!0,this.$queued=!1;var i=this.$opts.computed;void 0!==i&&l(this,i),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:b});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;ns?a:s,c=0;c"===o||" "===o)break;i+=o,n++}var a={type:"tag",value:i};return e.tokens.push(a),e.current=n,a},z=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 p={name:u,value:"",meta:{}};if(c)l[u]=p;else{s();var f=" ";for("'"!==o&&'"'!==o||(f=o,s());i1&&(s=l.shift(),a=l.join("(").slice(0,-1));var u="";n.shift();for(var c=0;cs?a:s,c=0;c"===o||" "===o)break;i+=o,n++}var a={type:"tag",value:i};return e.tokens.push(a),e.current=n,a},z=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 p={name:u,value:"",meta:{}};if(c)l[u]=p;else{s();var f=" ";for("'"!==o&&'"'!==o||(f=o,s());i1&&(s=l.shift(),a=l.join("(").slice(0,-1));var u="";n.shift();for(var c=0;c