From b823ad53690b3f55b0ada54245b66d7720c98f4e Mon Sep 17 00:00:00 2001 From: Kabir Shah Date: Sat, 27 Apr 2019 21:33:57 -0700 Subject: [PATCH] iterate through if siblings correctly and fix empty else clause text content --- packages/moon/dist/moon.js | 4 ++-- packages/moon/dist/moon.min.js | 2 +- packages/moon/src/compiler/generator/components/if.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/moon/dist/moon.js b/packages/moon/dist/moon.js index 6ebeb241..84b67be7 100644 --- a/packages/moon/dist/moon.js +++ b/packages/moon/dist/moon.js @@ -572,7 +572,7 @@ if (parent !== null) { var siblings = parent.children; - for (var i = index + 1; i < siblings.length; i++) { + for (var i = index + 1; i < siblings.length;) { var sibling = siblings[i]; if (sibling.type === "else-if") { @@ -599,7 +599,7 @@ if (emptyElseClause) { - prelude += "else{" + variable + "={type:" + types.text + ",name:\"text\",data:{children:[]}};}"; + prelude += "else{" + variable + "={type:" + types.text + ",name:\"text\",data:{\"\":\"\",children:[]}};}"; } return { diff --git a/packages/moon/dist/moon.min.js b/packages/moon/dist/moon.min.js index fbea6ea5..88d083fe 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","event","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","event","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