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

dataAttributes option #125

Closed
yyx990803 opened this issue Feb 21, 2014 · 13 comments
Closed

dataAttributes option #125

yyx990803 opened this issue Feb 21, 2014 · 13 comments

Comments

@yyx990803
Copy link
Member

<component width="100" height="100"></component>
Vue.component('component', {
    dataAttributes: ['width', 'height'],
    ready: function () {
        console.log(this.width)
        console.log(this.height)
    }
})

This seems to be a better solution than v-data, which is confusing. v-data will likely be removed in the next release.

@thelinuxlich
Copy link

Why we have to declare what are the attributes of the components? Can't we just use whatever the user writes as attribute automatically?

@yyx990803
Copy link
Member Author

because then we have to blacklist native attributes depending on the element type, which can be cumbersome. A whitelist approach is explicit and safer.

@duckbox
Copy link

duckbox commented Feb 22, 2014

I think 'dataAttributes' is a bit misleading, potential confusion with the datatset api ?

Perhaps 'bindAttributes' ?

For example, this seems odd,

<component data-qty="2"></component>
dataAttributes: ['data-qty']

Whereas,

bindAttributes: ['data-qty'],
ready : function(){ 
  console.log( this.qty );
}

We'd need to rename the binding key in this instance as well, this['data-qty'], seems messy.

data-qty="2"
\\--
this.qty === 2

@yyx990803
Copy link
Member Author

yes, but bindAttributes also sounds misleading because we are not really binding it, its just a starting value.

Maybe paramAttributes?

@bpierre
Copy link

bpierre commented Feb 22, 2014

elementAttributes, htmlAttributes, tagAttributes, domAttributes, attributes

@jcaxmacher
Copy link

+1 for paramAttributes
On Feb 22, 2014 8:29 AM, "Pierre Bertet" notifications@github.com wrote:

elementAttributes, htmlAttributes, tagAttributes, domAttributes,
attributes

Reply to this email directly or view it on GitHubhttps://github.com/yyx990803/vue/issues/125#issuecomment-35802549
.

@duckbox
Copy link

duckbox commented Feb 22, 2014

Ah, mis-thought the whole binding part. Initial data, I follow now!

Absolutely, paramAttributes sounds perfect for what you describe.

@marfalkov
Copy link

how about the dead simple attr ?

@yyx990803
Copy link
Member Author

@marfalkov there is already an attributes option which is a hash of attribute key/values to be added to the element.

@bpierre
Copy link

bpierre commented Feb 22, 2014

So this is the exact opposite. Maybe the names could reflect that, with something like setAttributes and getAttributes?

@marfalkov
Copy link

setAttributes and getAttributes sounds good

@yyx990803
Copy link
Member Author

I don't think they are logical counterparts - attributes is part of the element options while paramAttributes is a component configuration option.

yyx990803 added a commit that referenced this issue Feb 23, 2014
@marfalkov
Copy link

@yyx990803 that makes sense.

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

6 participants