fabbricadigitale / paper-chip

A chip web component made with Polymer 2 following Material Design guidelines
http://webcomponents.org/element/fabbricadigitale/paper-chip
MIT License
31 stars 16 forks source link

Support value property in declarative mode #44

Closed alelb closed 6 years ago

alelb commented 7 years ago

Use case 1

<paper-chip>xyz-label</paper-chip> value (property) : undefined label (visual) : xyz-label

Use case 2

<paper-chip value="xyz"></paper-chip> value (property) : xyz label (visual) : xyz

Use case 3

<paper-chip value="xyz">xyz-label</paper-chip> value (property) : xyz label (visual) : xyz-label

leodido commented 7 years ago

:+1:

leodido commented 7 years ago

I implemented the declarative part (with a slot fallback) of the use case 1.

The property label on the chip instance does not exist yet.

leodido commented 7 years ago

Currently this is the behavior.

When the <paper-chip> contains an HTML element with slot attribute equal to "label" (ie., <div slot="label">content</div>), its content becomes the visible content of the <paper-chip>.

Otherwise the <paper-chip> element fallbacks to use the text content in its light DOM, if any, as the visible content.

This behavior is similar to the <option> label attribute behavior (ref.).

leodido commented 7 years ago

Also use case 3 works now. :tada: