{"record":{"id":"31ebdcca79b2b987","repo":"Meituan-Dianping/mpvue","slug":"text-children-i-text-trim-between-v-if-and","errorCode":null,"errorMessage":"text \"${children[i].text.trim()}\" between v-if and v-else(-if) will be ignored.","messagePattern":"text \"(.+?)\" between v-if and v-else\\(-if\\) will be ignored\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/weex-template-compiler/build.js","lineNumber":1708,"sourceCode":"      exp: el.elseif,\n      block: el\n    });\n  } else if (process.env.NODE_ENV !== 'production') {\n    warn(\n      \"v-\" + (el.elseif ? ('else-if=\"' + el.elseif + '\"') : 'else') + \" \" +\n      \"used on element <\" + (el.tag) + \"> without corresponding v-if.\"\n    );\n  }\n}\n\nfunction findPrevElement (children) {\n  var i = children.length;\n  while (i--) {\n    if (children[i].type === 1) {\n      return children[i]\n    } else {\n      if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {\n        warn(\n          \"text \\\"\" + (children[i].text.trim()) + \"\\\" between v-if and v-else(-if) \" +\n          \"will be ignored.\"\n        );\n      }\n      children.pop();\n    }\n  }\n}\n\nfunction addIfCondition (el, condition) {\n  if (!el.ifConditions) {\n    el.ifConditions = [];\n  }\n  el.ifConditions.push(condition);\n}\n\nfunction processOnce (el) {\n  var once$$1 = getAndRemoveAttr(el, 'v-once');","sourceCodeStart":1690,"sourceCodeEnd":1726,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/packages/weex-template-compiler/build.js#L1690-L1726","documentation":"Text content found between a v-if element and its v-else/v-else-if sibling is discarded, since only element nodes participate in the if/else chain. The compiler warns about the specific text (unless it's a single space) and pops it from the children list.","triggerScenarios":"Placing non-whitespace text (or comments) between an element with v-if and the following element with v-else/v-else-if, so findPrevElement encounters a non-element child with text !== ' ' during dev-mode compilation.","commonSituations":"Formatting templates with explanatory text between conditional blocks, leftover stray characters between elements, or whitespace-significant editing that left text nodes in between.","solutions":["Remove the text between the v-if and v-else elements","Move the text inside one of the conditional branches","Keep only plain whitespace between the conditional siblings"],"exampleFix":"// before\n<div v-if=\"ok\">A</div>\nnote here\n<div v-else>B</div>\n// after\n<div v-if=\"ok\">A</div>\n<div v-else>B</div>","handlingStrategy":"validation","validationCode":"function textBetweenIfElse(template) {\n  // flag non-whitespace text between a v-if element and a following v-else\n  const re = /v-if=[^>]*>([^<]+)<[^>]*v-else/;\n  const m = template.match(re);\n  return m && m[1].trim() ? `stray text \"${m[1].trim()}\" between v-if and v-else` : null;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep only whitespace between v-if and v-else siblings","Move explanatory text inside a conditional branch","Run vue/template linters that catch stray text in conditional chains"],"tags":["v-if","v-else","whitespace","template","vue","weex"],"backgroundTag":"text-between-if-and-else","analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}