From dc07891c9bd2dbab2bfd7da0b7664d70132a29fb Mon Sep 17 00:00:00 2001 From: Kabir Shah Date: Sun, 28 Apr 2019 00:24:05 -0700 Subject: [PATCH] add support for empty attribute values --- packages/moon/dist/moon.js | 2 +- packages/moon/dist/moon.min.js | 2 +- packages/moon/src/compiler/lexer/lexer.js | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/moon/dist/moon.js b/packages/moon/dist/moon.js index bf253606..5d958662 100644 --- a/packages/moon/dist/moon.js +++ b/packages/moon/dist/moon.js @@ -274,7 +274,7 @@ } else { // Store the key/value pair using the matched value or // expression. - attributes[attributeKey] = attributeExpression === undefined ? attributeValue : scopeExpression(attributeExpression); // Add a wrapper function for events. + attributes[attributeKey] = attributeExpression === undefined ? attributeValue === undefined ? "\"\"" : attributeValue : scopeExpression(attributeExpression); // Add a wrapper function for events. if (attributeKey[0] === "@") { attributes[attributeKey] = "function($event){" + attributes[attributeKey] + "}"; diff --git a/packages/moon/dist/moon.min.js b/packages/moon/dist/moon.min.js index b1b99da5..f17233d8 100644 --- a/packages/moon/dist/moon.min.js +++ b/packages/moon/dist/moon.min.js @@ -4,4 +4,4 @@ * Released under the MIT License * https://kbrsh.github.io/moon */ -!function(e,n){"undefined"==typeof module?e.Moon=n():module.exports=n()}(this,function(){"use strict";var v={element:0,text:1,component:2};var c,N=/^\s+$/,A=/<([\w\d-_]+)([^>]*?)(\/?)>/g,k=/\s*([\w\d-_:@]*)(?:=(?:("[^"]*"|'[^']*')|{([^{}]*)}))?/g,n=/"[^"]*"|'[^']*'|\d+[a-zA-Z$_]\w*|\.[a-zA-Z$_]\w*|[a-zA-Z$_]\w*:|([a-zA-Z$_]\w*)/g,t=["NaN","false","in","null","this","true","typeof","undefined","window"];function E(e){return e.replace(n,function(e,n){return void 0===n||"$"===n[0]||-1!==t.indexOf(n)?e:"data."+n})}function r(e){e=e.trim();for(var n=[],t=0;t",t+2),i=e.slice(t+2,o);0,n.push({type:"tagClose",value:i}),t=o+1;continue}if("!"===a&&"-"===e[t+2]&&"-"===e[t+3]){var d=e.indexOf("--\x3e",t+4);0,t=d+3;continue}A.lastIndex=t;var l=A.exec(e);0;for(var u=l[0],p=l[1],f=l[2],s=l[3],c={},v=void 0;null!==(v=k.exec(f));){var h=v[0],m=v[1],w=v[2],g=v[3];0===h.length?k.lastIndex+=1:(c[m]=void 0===g?w:E(g),"@"===m[0]&&(c[m]="function($event){"+c[m]+"}"))}n.push({type:"tagOpen",value:p,attributes:c,closed:"/"===s}),t+=u.length}else if("{"===r){var y="";for(t+=1;t]*?)(\/?)>/g,k=/\s*([\w\d-_:@]*)(?:=(?:("[^"]*"|'[^']*')|{([^{}]*)}))?/g,n=/"[^"]*"|'[^']*'|\d+[a-zA-Z$_]\w*|\.[a-zA-Z$_]\w*|[a-zA-Z$_]\w*:|([a-zA-Z$_]\w*)/g,t=["NaN","false","in","null","this","true","typeof","undefined","window"];function E(e){return e.replace(n,function(e,n){return void 0===n||"$"===n[0]||-1!==t.indexOf(n)?e:"data."+n})}function r(e){e=e.trim();for(var n=[],t=0;t",t+2),i=e.slice(t+2,o);0,n.push({type:"tagClose",value:i}),t=o+1;continue}if("!"===a&&"-"===e[t+2]&&"-"===e[t+3]){var d=e.indexOf("--\x3e",t+4);0,t=d+3;continue}A.lastIndex=t;var l=A.exec(e);0;for(var u=l[0],p=l[1],f=l[2],s=l[3],c={},v=void 0;null!==(v=k.exec(f));){var h=v[0],m=v[1],w=v[2],g=v[3];0===h.length?k.lastIndex+=1:(c[m]=void 0===g?void 0===w?'""':w:E(g),"@"===m[0]&&(c[m]="function($event){"+c[m]+"}"))}n.push({type:"tagOpen",value:p,attributes:c,closed:"/"===s}),t+=u.length}else if("{"===r){var y="";for(t+=1;t