Skip to content

Warning using compile() in render() on method calls #7910

Open
@grillonbleu

Description

@grillonbleu

Vue version

3.2.45

Link to minimal reproduction

https://codesandbox.io/s/fervent-platform-8m2hlu?file=/src/components/ContentRender.vue

Steps to reproduce

I have a component whose template is compiled dynamically through the compile() function. The use case is an online vue-based IDE which gives a real time preview of edited fragments.

It works great so far, except for the following warning. I get it twice for every time the compiled template uses a component method:

[Vue warn]: Property undefined was accessed during render but is not defined on instance.

Here is a minimal component which triggers the issue:

<script>
import { compile } from "vue";
export default {
  name: "ContentRender",
  methods: {
    hello: function (x) {
      return `hello ${x}`;
    },
  },
  render: function (vm) {
    const template = `<div :title="hello('world')">
      {{hello('world')}},
      {{hello('world')}},
      {{hello('world')}}
    </div>`;
    const compiledTemplate = compile(template);
    return compiledTemplate(vm);
  },
};
</script>

It can be observed here: https://codesandbox.io/s/fervent-platform-8m2hlu?file=/src/components/ContentRender.vue

What is expected?

Execution with no warning is expected.

What is actually happening?

Following warning appears twice for every component method call:

[Vue warn]: Property undefined was accessed during render but is not defined on instance.

The method calls otherwise resolve successfully.

System Info

No response

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions