Skip to content

...attributes -- Component API and Discoverability #586

@NullVoxPopuli

Description

@NullVoxPopuli

A couple co-workers brought up some interesting points this morning.

Given that
...attributes can be placed anywhere in a component

You

  • don't know if ...attributes is used at all (everyone should be using ...attributes though -- the calling context is in charge of layout, and you may want to pass layout classes or aria attributes to your sub-component )
  • don't know what element ...attributes will be placed on.
    • is it the outer-most element? (imo, it should be)
    • is it some other element? (this, to me, means that the abstractions need to be re-worked so that ...attributes can be the outer-most element
  • don't know that args are or aren't overwriting the attributes
    • for example:
      <div ...attributes aria-label={{@ariaLabel}}>

Questions for the community:

  • should we add a lint rule to suggest that ...attributes should only be used in the top-most element?
  • should we have some additional tooling ((u)ELS?) to tell us if ...attributes is used, if any @args overwrite / merge any of the attributes.

The main thing we're after here is clarity without having to know implicit community convention -- because implicit community convention can't be programmatically enforced atm.

Related: ember-learn/guides-source#1286
(the specific component in that link, Input, isn't important to this issue, but the problem is there)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions