Skip to content
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

Attrs Fallthrough #625

Closed
zeng450026937 opened this issue Jan 16, 2020 · 2 comments
Closed

Attrs Fallthrough #625

zeng450026937 opened this issue Jan 16, 2020 · 2 comments

Comments

@zeng450026937
Copy link

Version

3.0.0-alpha.1

Reproduction link

https://codepen.io/itoito-cn/pen/WNbgrdN

Steps to reproduce

import { defineComponent } from 'vue';

export default defineComponent({
  props: ['foo'],
  setup(props, context) {
    return () => [
      h('div', 'content 1'),
      h('div', 'content 2'),
      h('div', context.attrs),
    ];
  },
});

What is expected?

attrs fallthrough should not warn when attrs is used during render

in this scenario, it's better if we also check the access from setupContext to prevent warning.

What is actually happening?

we don't have any approach to prevent warning if an arrow function is returned as render function within setup().

@posva
Copy link
Member

posva commented Jan 16, 2020

I can't see the warning you are talking about:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>

    <script type="module">
      import {
        h,
        createApp,
        defineComponent
      } from 'https://unpkg.com/[email protected]/dist/vue.esm.js'

      const Comp = defineComponent({
        props: ['foo'],
        setup(props, context) {
          return () => [
            h('div', 'content 1'),
            h('div', 'content 2'),
            h('div', context.attrs)
          ]
        }
      })

      const app = createApp()
      app.mount(Comp, '#app')
    </script>
  </body>
</html>

Next time, please provide a repro

@posva posva closed this as completed Jan 16, 2020
@zeng450026937
Copy link
Author

zeng450026937 commented Jan 16, 2020

ok, i fixed the reproduction code.

https://codepen.io/itoito-cn/pen/WNbgrdN

it's not make sense if you don't pass any properties when we're talking about arrt fallthrough.
you should not close it so quickly...

-> markAttrsAccessed() is only called from componentProxy

@yyx990803 yyx990803 reopened this Jan 16, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants