Skip to content

Setting props before mounting the web component causes them to be overwritten by default values #34

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
TomCaserta opened this issue Sep 20, 2018 · 0 comments · May be fixed by #81
Open

Comments

@TomCaserta
Copy link

TomCaserta commented Sep 20, 2018

Given a web component which accepts an input property eg.

import Vue from 'vue';
import Component from 'vue-class-component';
import { Prop } from 'vue-property-decorator';

@Component({
    name: 'my-custom-element',
})
export default class ExampleComponent extends Vue {
    @Prop({
        default: () => ({ anObject: 'Testing!' })
    }) someProp: { anObject: string };
}

And then creating it via JS:

const custom = document.createElement('my-custom-element');
custom.someProp = { anObject: 'Changed!' };

document.body.appendChild(custom);

The value of someProp is immediately overwritten once the component has been attached to the DOM. If we move the custom.someProp assignment after the call to appendChild it works but that shouldn't be necessary.

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

Successfully merging a pull request may close this issue.

1 participant