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

Loses class and other passed attributes #8

Closed
OEvgeny opened this issue Sep 19, 2017 · 11 comments
Closed

Loses class and other passed attributes #8

OEvgeny opened this issue Sep 19, 2017 · 11 comments

Comments

@OEvgeny
Copy link

OEvgeny commented Sep 19, 2017

I've noticed that createHOC looses data.attributes in produced components which leads to loosing class and other attributes in actual DOM.
E.g.

 export const BackBtn = createHOC(IconBtn, {
  name: 'BackBtn',
  functional: true,
  // render (h, ctx) {
  //   return h(IconBtn, { ...ctx.data, props: { ...ctx.props, icon: 'arrow_back' } })
  // }
}, {
  props: { icon: 'arrow_back' }
})

When using in template like

<back-btn class="green--text"></back-btn>

Does not include class green-text
But when defined like:


export const BackBtn = createHOC({}, {
  name: 'BackBtn',
  functional: true,
  render (h, ctx) {
    return h(IconBtn, { ...ctx.data, props: { ...ctx.props, icon: 'arrow_back' } })
  }
})

It does.

@jackmellis
Copy link
Owner

Ah the unstable world of functional Vue components!

I haven't yet found a way to inherit attributes/classes/etc. between functional hocs. I'd love it anyone could come up with a solution.

If you try the same with non-functional components it should work, so it depends whether you'd consider that as a workaround. Luckily, functional components in Vue aren't quite as essential as in React.

@OEvgeny
Copy link
Author

OEvgeny commented Sep 20, 2017

@jackmellis Wow good to know. I'll think on a fix too. Should I leave it opened?

@jackmellis
Copy link
Owner

Yeah I'd like to keep this issue open for now, HOCs and Functional components feel like they belong together (thanks React) so if anyone can put forward a solution it'd be greatly appreciated!

@LinusBorg
Copy link

Hope I find the time to take a look. At first sight, the createRenderFn does recognize context, so this should be achievable ...

@adamchenwei
Copy link

same here, pretty headachy.

@adamchenwei
Copy link

adamchenwei commented Oct 17, 2018

what's the work around that does not involve adding new param into the wrapped component, just for appending class name and other cust params with values?

@adamchenwei
Copy link

just realize this has been A WHOLE YEAR already lol wow.... boy....

@jackmellis
Copy link
Owner

Yep, no progress I'm afraid. The workaround mentioned above is that if you use createHOC({ functional: true }) classes and styles should still find there way into the wrapped component.

@adamchenwei
Copy link

@LinusBorg ^^^ any hope? blockers?

@LinusBorg
Copy link

Sorry but I haven't really been working on this ever since, and won't have time to get back into it.

@adamchenwei
Copy link

saw your discussion there in vue main repo, thought helpful for anyone else jump in here, as its top result in google search...

vuejs/vue#6201

@OEvgeny OEvgeny closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants