Skip to content

Two bugs about this compiler #3

@Leopoldthecoder

Description

@Leopoldthecoder

After version 1.2.0, we find some errors related to vue-template-es2015-compiler. Here's a reproduction: https://github.com/QingWei-Li/vue-compiler-strip-with-bug .

Basically, there are two errors corresponding to two console.errors if you try to run the demo above:

  • ReferenceError: prop is not defined
    This is because <div :attr="obj[prop]">123</div> in template is compiled to _vm.obj[prop] but it should be _vm.obj[_vm.prop]
  • ReferenceError: _h is not defined
    If inline-template is used in the template, contents before inline-template is compiled fine but contents after it gets some error. For example:
  <div>正常:{{ name }}</div>
  <inline inline-template>
    <div>{{ name }}</div>
  </inline>
  <div>错误:{{ name }}</div>

will be compiled to

return _vm._h('div', [_vm._h('div', ["正常:" + _vm._s(_vm.name)]), " ", _vm._h('inline', {
  inlineTemplate: {
    render: function() {
      var _vm=this;
      return _vm._h('div', [_vm._s(_vm.name)])
    },
    staticRenderFns: []
  }
}), " ", _h('div', ["错误:" + _s(name)])])

The last line should be _vm._h('div', ["错误:" + _vm._s(_vm.name)]).

That's what we've found so far.

Here's another thing: is there any chance that with in render function is not entirely removed but can be configured by users? If in some cases users need this implementation, they can add with back. This line seems to make with configurable, but I'm not sure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions