Skip to content

Compiler: v-on access _cache in hoisted element outside render function if handler is empty #1716

Closed
@rhengles

Description

@rhengles

Version

3.0.0-rc.3

Reproduction link

https://jsbin.com/rafugesite/edit?html,js,console,output

Steps to reproduce

sometimes you create a v-on:event="" while developing but forget to call anything inside the event handler. When the handler is empty, the element is hoisted and that generates a code that tries to access the "_cache" variable outside the render(_ctx, _cache) function.

This causes an error that is not easy to understand.

What is expected?

Compile without error (empty handler doesn't do anything), or maybe print a warning "empty v-on handler found"

What is actually happening?

ReferenceError: _cache is not defined

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