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

Linter complains paper-listbox attr-for-selected name when placed on paper-item #565

Closed
dman777 opened this issue Jul 5, 2018 · 3 comments

Comments

@dman777
Copy link

dman777 commented Jul 5, 2018

When using paper-listbox and attr-for-selected="value" with paper-item, the linter complains below. Is this a error on the linter part? Everything looks legit Polymer wise. It doesn't matter what name I use for the attr-for-selected, it will complain.

                value="[[picklistValues.ENHANCEDYESNO_DATANOTCOLLECTED]]">
                ~~~~~

src/sp-elements/sp-static-forms/sp-disabilities/sp-disabilities-form-edit.html(404,17) warning [set-unknown-attribute] - paper-item elements do not have a property named value. Consider instead:  role$

                <paper-listbox
                  attr-for-selected="value"
                  selected="yes"
                  class="dropdown-content">
                  <paper-item
                    value="[[picklistValues.ENHANCEDYESNO_YES]]">
                    Yes
                  </paper-item>
@morbidick
Copy link

morbidick commented Jul 5, 2018

you have to set it as an attribute:

                  <paper-item
                    value$="[[picklistValues.ENHANCEDYESNO_YES]]">
                    Yes
                  </paper-item>

By default Polymer data binding sets property values.

@dman777
Copy link
Author

dman777 commented Jul 5, 2018

Thanks.

Could the verbiage need refinement? the value is a attribute. From documentation, $ is used for html native attributes or dynamic values. But the without the $, value is still a attribute.

@jsilvermist
Copy link
Contributor

jsilvermist commented Jul 5, 2018

paper-listbox is getting the selected attribute using:

var propValue = item[dashToCamelCase(this.attrForSelected)];
return propValue != undefined ? propValue :
                                item.getAttribute(this.attrForSelected);

So it's getting the property first, and if it's not set it falls back to the attribute.

In this case, value isn't defined on paper-item as a property, so binding to it's attribute instead is a good way to avoid any issues with the linter, as I don't believe it should cause a linter error.

value="[[foo]]" will generate: el.value = this.foo;
value$="[[foo]]" will generate: el.setAttribute('value', this.foo) (More or less, slightly different in the case of boolean attributes)

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

3 participants