Skip to content

Props are not properly inherited from mixins / extended components #30

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

Open
philipfeldmann opened this issue Sep 10, 2018 · 3 comments
Open

Comments

@philipfeldmann
Copy link

philipfeldmann commented Sep 10, 2018

I'm having a bunch of components that all share some properties, so I've moved them into a mixin (also tried with extending from a parent component).

The prop binding works perfectly when using the component normally, in an SPA for example. When building it as a webcomponent though, the prop binding will no longer be recognized: The component is still able to access the prop attribute correctly, but will always chose the default value - or undefined if no default is provided.

Example:

Mixin:

export default {
props: {
    theme: {
      type: String,
      default: 'defaultTheme',
    }
  },
}

MyComponent:

<template>
  <div>{{ theme }}</div>
</template

<script>
export default {
  name: 'Test',
  mixins: [theme],
}
</script>

Using the Webcompenent:

<webcomponent-test theme="custom"></webcomponent-test>
This will display 'defaultTheme' instead of 'custom'.
When adding the prop directly to the component it works fine though.

@karol-f
Copy link

karol-f commented Oct 5, 2018

It's not pretty solution, but meanwhile you can

import themeMixin from './theneMixin';

<script>
export default {
  name: 'Test',
  props: {...themeMixin.props}
}
</script>

You can also lodash merge on the whole "export default" object

@aradt
Copy link

aradt commented Feb 19, 2020

Following...
this can be a good feature with .sync

@m-mohr
Copy link

m-mohr commented Feb 18, 2021

Wow, this is a really annoying bug. Just spent half a day trying to figure out why my component misbehaved. It was this bug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants