Skip to content

vue-template-compiler@2.1.0 parse template error: Cannot read property 'text' of undefined #669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
clancyz opened this issue Feb 23, 2017 · 1 comment

Comments

@clancyz
Copy link

clancyz commented Feb 23, 2017

Hi all! I made a simple project with vue-cli(which use vue-template-compiler@2.1.0), and found this error:

Cannot read property 'text' of undefined
    at Object.chars (eval at <anonymous> (app.js:969), <anonymous>:1385:65)
    at parseHTML (eval at <anonymous> (app.js:969), <anonymous>:537:17)
    at parse (eval at <anonymous> (app.js:969), <anonymous>:1203:3)
    at compile$2 (eval at <anonymous> (app.js:969), <anonymous>:2283:13)
    at compile$1 (eval at <anonymous> (app.js:969), <anonymous>:5739:10)
    at Object.compile$$1 [as compile] (eval at <anonymous> (app.js:969), <anonymous>:5931:18)
    at VueComponent.mounted (eval at <anonymous> (app.js:800), <anonymous>:16:22)
    at callHook (eval at <anonymous> (app.js:735), <anonymous>:2754:19)
    at Object.insert (eval at <anonymous> (app.js:735), <anonymous>:1765:5)
    at invokeInsertHook (eval at <anonymous> (app.js:735), <anonymous>:4474:28)

Here is the case:

const compiler = require('vue-template-compiler');
compiler.compile('<pre>\n<span> <span></span></span>\n</pre>');

or directely write in template of a .vue file:

<template>
   <pre>
      <span> <span></span></span>
   </pre>
</template>

This errors occurs in vue-template-compiler/build.js :1385:65

else if (text !== ' ' || children[children.length - 1].text !== ' ') {
      currentParent.children.push({
            type: 3,
            text: text
      });
 }

In this case children is an empty array, so it happens.

Thank you.

@kazupon
Copy link
Member

kazupon commented Feb 23, 2017

Related issues:
#597

This is issue of vue core.
This issue already fixed vuejs/vue#4760
Close.

@kazupon kazupon closed this as completed Feb 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants