iron-component-page icon indicating copy to clipboard operation
iron-component-page copied to clipboard

attributes vs. properties

Open Scarygami opened this issue 10 years ago • 13 comments

A recurring problem that people seem to have is the new attribute to property mapping in 1.0.

They try something like <custom-element myProperty="{{something}}"> because myProperty is listed in the element docs, where they should be using <custom-element my-property="{{something}}">

It would be nice to somehow display both the property and the attribute name in the generated docs. Especially beginners won't find their way all the way to the "property name mapping" part in the docs.

Scarygami avatar Jun 12 '15 09:06 Scarygami

Gets me all the time, still. Great idea for linter mode. I've added it to the linter idea list.

atotic avatar Jun 12 '15 16:06 atotic

Is this "Polymer linter" already available somewhere for testing/contributing or is it just an idea so far? :)

Scarygami avatar Jun 12 '15 17:06 Scarygami

I think it is a work in progress

On Fri, Jun 12, 2015 at 10:42 AM, Gerwin Sturm [email protected] wrote:

Is this "Polymer linter" already available somewhere for testing/contributing or is it just an idea so far? :)

— Reply to this email directly or view it on GitHub https://github.com/PolymerElements/iron-component-page/issues/32#issuecomment-111570719 .

atotic avatar Jun 12 '15 17:06 atotic

Adding this to the docs is also a good idea.

This and the auto-generated change events (property-changed) are subtleties that are obvious to the folks writing the API docs, but obscure to newcomers, especially if they go straight to the catalog.

arthurevans avatar Jun 12 '15 23:06 arthurevans

My vote would be to have a toggle that flips "Properties" to "Attributes" and back, changing the formatting of the names but leaving everything else intact.

For <prop>-changed events, there are two ways I see to go about it -- have a toggle to show/hide them or have a separate section that just collects them into a comma-separated list. Any preference?

mbleigh avatar Jun 12 '15 23:06 mbleigh

i'd love to see element generators, either as part of the demo, or a separate page. Nothing makes me happier as a developer than having an interactive playground.

atotic avatar Jun 12 '15 23:06 atotic

Would be cool for sure, but I think out of scope for this issue ;)

mbleigh avatar Jun 12 '15 23:06 mbleigh

For the events, I was thinking "Show/Hide generated."

Not sure about the flipping attributes/properties ... It makes it more compact but less discoverable (and possibly a little bit opaque).

arthurevans avatar Jun 15 '15 17:06 arthurevans

Some elements have 10+ properties, meaning you're going to have a huge repeating section if you separate them out. A toggle helps reinforce that they're the same.

On further thinking, maybe it would be even better to have an "attribute name" along with the property name so there's no toggle needed. Show both at the same time for each one.

mbleigh avatar Jun 15 '15 17:06 mbleigh

Yeah, I agree on not repeating them. Just adding an attribute name sounds good.

arthurevans avatar Jun 15 '15 18:06 arthurevans

Because this behavior (and the property-changed events) are specific to Polymer, we should really add them to the autogenerated docs, so users on WC.org don't need to know Polymer-specific conventions to use the elements appropriately.

@aomarks WDYT? This is probably in the wrong repo, but would love to see this move forward.

arthurevans avatar Oct 02 '17 23:10 arthurevans

@arthurevans I need to check the analyzer output again, but we should be generating both an attribute record and property record, and we may be able to associate them because they have the same source range.

While the specific camel-case property name to kebab-case attribute name is from Polymer, I think the general idea that some attributes are associated with properties is general enough to keep in iron-component page, so we can link the docs of them.

justinfagnani avatar Oct 02 '17 23:10 justinfagnani

I think showing the attributes is a good idea, and https://github.com/PolymerElements/iron-doc-viewer/issues/125 is the same request.

aomarks avatar Oct 03 '17 03:10 aomarks