Skip to content

Commit

Permalink
iterate through if siblings correctly and fix empty else clause text …
Browse files Browse the repository at this point in the history
…content
  • Loading branch information
kbrsh committed Apr 28, 2019
1 parent e74b36d commit b823ad5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/moon/dist/moon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/moon/dist/moon.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/moon/src/compiler/generator/components/if.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function generateNodeIf(element, parent, index) {
if (parent !== null) {
const siblings = parent.children;

for (let i = index + 1; i < siblings.length; i++) {
for (let i = index + 1; i < siblings.length;) {
const sibling = siblings[i];

if (sibling.type === "else-if") {
Expand Down Expand Up @@ -66,7 +66,7 @@ export function generateNodeIf(element, parent, index) {

// Generate an empty `else` clause represented by an empty text node.
if (emptyElseClause) {
prelude += `else{${variable}={type:${types.text},name:"text",data:{children:[]}};}`;
prelude += `else{${variable}={type:${types.text},name:"text",data:{"":"",children:[]}};}`;
}

return {
Expand Down

0 comments on commit b823ad5

Please sign in to comment.