From 530e142be3480cbb492ee5b43e012f991c01e6d2 Mon Sep 17 00:00:00 2001 From: Kabir Shah Date: Mon, 3 Apr 2017 09:48:15 -0700 Subject: [PATCH] throw error if no closing delimiter for template is given --- dist/moon.js | 16 ++++++++++++++++ dist/moon.min.js | 2 +- src/compiler/template.js | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/dist/moon.js b/dist/moon.js index e6c0ff24..31575d0e 100644 --- a/dist/moon.js +++ b/dist/moon.js @@ -817,16 +817,32 @@ var template = state.template; var length = template.length; while (state.current < length) { + // Match Text Between Templates var value = scanTemplateStateUntil(state, openRE); if (value) { state.output += value; } + // If we've reached the end, there are no more templates + if (state.current === length) { + break; + } + + // Exit The Opening Tag state.current += 2; + // Get the name of the opening tag var name = scanTemplateStateUntil(state, closeRE); + // If we've reached the end, the tag was unclosed + if (state.current === length) { + if ("development" !== "production") { + error('Expected closing delimiter "}}" after "' + name + '"'); + } + break; + } + if (name) { var modifiers = ""; var modifierIndex = null; diff --git a/dist/moon.min.js b/dist/moon.min.js index d64b8f4a..881f23f4 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||y,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},I=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=H(e);q(e);var i="/"===t.charAt(e.current);e.tokens.push({type:"tagEnd",close:!1}),e.current+=i?2:1,i&&(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}))},H=function(e){for(var t=e.input,r=t.length,n=e.current;n"!==i&&" "!==i)break;n++}for(var o=n;o"===i||" "===i)break;o++}var s=t.slice(n,o);return e.tokens.push({type:"tag",value:s}),e.current=o,s},q=function(e){for(var t=e.input,r=t.length,n=e.current,i={},o=t.charAt(n),s=t.charAt(n+1),a=function(){n++,o=t.charAt(n),s=t.charAt(n+1)};n"!==o&&("/"!==o||">"!==s);)if(" "!==o){for(var u="",c=!1;"="!==o&&n"!==o||"/"===o&&">"!==s)){c=!0;break}u+=o,a()}var p={name:u,value:"",meta:{}};if(c)i[u]=p;else{var l=" ";for(a(),"'"===o||'"'===o?(l=o,a()):p.value+=o;(o!==l&&">"!==o||"/"===o&&">"!==s)&&n1&&(a=u.shift(),s=u.join("(").slice(0,-1));var c="";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},I=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=H(e);q(e);var i="/"===t.charAt(e.current);e.tokens.push({type:"tagEnd",close:!1}),e.current+=i?2:1,i&&(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}))},H=function(e){for(var t=e.input,r=t.length,n=e.current;n"!==i&&" "!==i)break;n++}for(var o=n;o"===i||" "===i)break;o++}var s=t.slice(n,o);return e.tokens.push({type:"tag",value:s}),e.current=o,s},q=function(e){for(var t=e.input,r=t.length,n=e.current,i={},o=t.charAt(n),s=t.charAt(n+1),a=function(){n++,o=t.charAt(n),s=t.charAt(n+1)};n"!==o&&("/"!==o||">"!==s);)if(" "!==o){for(var u="",c=!1;"="!==o&&n"!==o||"/"===o&&">"!==s)){c=!0;break}u+=o,a()}var p={name:u,value:"",meta:{}};if(c)i[u]=p;else{var l=" ";for(a(),"'"===o||'"'===o?(l=o,a()):p.value+=o;(o!==l&&">"!==o||"/"===o&&">"!==s)&&n1&&(a=u.shift(),s=u.join("(").slice(0,-1));var c="";n.shift();for(var p=0;p