Skip to content

Does createDecorator can't decorate classes? #155

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

Closed
vwxyutarooo opened this issue Sep 30, 2017 · 2 comments · Fixed by #157
Closed

Does createDecorator can't decorate classes? #155

vwxyutarooo opened this issue Sep 30, 2017 · 2 comments · Fixed by #157

Comments

@vwxyutarooo
Copy link

I'm not sure is it bug or correct behave, Following code was working until v5.0.1.

const Test = createDecorator((options) => {
  const mergedOptions = Object.assign({}, {
    name: 'component-sample',
    props: Object.assign({}, {
      a: {
        type: String,
        default: ''
      }
    }, options.props)
  }, options);

  options = mergedOpitons;
});


@Component({
  props: {
    b: {
      type: String,
      default: ''
    }
  }
})
@Test
export default class ComponentSample extends Vue {}

Wen I update to 5.0.2, then createDecorator not called which shows in above.
Wwhat's happend between 5.0.1 and 5.0.2? And any suggestion to alternative.
Thanks.

@ktsn
Copy link
Member

ktsn commented Sep 30, 2017

Hmm, createDecorator was actually not intended to use for class decorator. 😞

The problem is that the internal object that stores applied custom decorators is changed in v5.0.2. It was a singleton object until v5.0.1 but it will be created for each class component since v5.0.2 to solve #104.

I guess we can simply solve this. I'll investigate it later.

@oyaschuk
Copy link

As an alternative you can apply your decorator to render function (or any other).

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

Successfully merging a pull request may close this issue.

3 participants