From 96da99bebc4a3dd0a46a64e361562cf898f46dce Mon Sep 17 00:00:00 2001 From: Kabir Shah Date: Fri, 24 Mar 2017 17:42:59 -0700 Subject: [PATCH] ensure empty attributes have meta/values --- dist/moon.js | 11 ++++++----- dist/moon.min.js | 2 +- src/compiler/lexer.js | 11 ++++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/dist/moon.js b/dist/moon.js index 2c0b9c00..8560f731 100644 --- a/dist/moon.js +++ b/dist/moon.js @@ -833,15 +833,16 @@ incrementChar(); } - if (noValue) { - attrs[attrName] = ""; - continue; - } - var attrValue = { meta: {}, value: "" }; + + if (noValue) { + attrs[attrName] = attrValue; + continue; + } + var quoteType = " "; // Exit equal sign and setup quote type diff --git a/dist/moon.min.js b/dist/moon.min.js index 0599ce3d..db1a2e11 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()}var u={meta:{},value:""};if(c)o[p]=u;else{var 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