Skip to content

The solution for props name start with "data-" when hyphenated prop names been deprecated #1034

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
butsalt opened this issue Jul 10, 2015 · 2 comments

Comments

@butsalt
Copy link

butsalt commented Jul 10, 2015

I'm commonly using props start with data-. data-* is recommended to exchange proprietary information. Through this way, I don't need to worry about the attribute that I use to exchange data will cause any impact on dom.

props: {
    "data-checked": {
        type: Boolean
    }
}

If hyphenated prop names have been deprecated, I wish I can use props start with 'data-' like this in future:

<my-component data-checked></my-component>
props: {
    "checked": Boolean
}
this.checked //true

And

<my-component data-my-msg="something"></my-component>
props: {
    "myMsg": String
}
this.myMsg //"something"

If not find properer attribute, then

<my-component my-msg="something"></my-component>
props: {
    "myMsg": String
}
this.myMsg //"something"
@young-steveo
Copy link

👍 This would be awesome if configurable via a global Vue.config option, like parseDataProps.

<my-component data-my-msg="something"></my-component>
props: {

    // with parseDataProps : false
    dataMyMsg : String,

    // with parseDataProps : true
    myMsg : String
}

@yyx990803
Copy link
Member

@young-steveo I'm not sure if the config is necessary here - it seems very unlikely to conflict with 3rd party libs, and even if it does you can use the non-data-prefixed syntax to avoid it.

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

3 participants