Skip to content
This repository was archived by the owner on Jun 21, 2020. It is now read-only.
This repository was archived by the owner on Jun 21, 2020. It is now read-only.

Change argument to a collection of DOM nodes #6

@jackjennings

Description

@jackjennings

After using this in a few projects, it seems like it would be a better API if the function accepted a collection of DOM elements, rather than a data attribute. The active and inactive streams would then also be updated to emit elements, rather than "names".

Benefits:

  • Delegate querying elements to the parent program. This allows any group of elements to be used, and doesn't force the data-attribute approach currently being used. This also means that we can remove the dependency on @standard-library/q-prime.
  • Reduced querying—if the collection of nodes is already available in the parent program, the DOM query currently in the function is duplicative. Also, by only returning a "name", doing anything with that active "name" mean performing another query to get the DOM nodes.

Issues:

  • The function currently takes names instead of elements in order to return only unique names (and to remove duplicates if there are elements with the same name). If this argument is changed and retaining this behavior is desired, another argument might need to be supplied, e.g.:
illume(nodes, { uniqueBy: node => node.dataset.name })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions