A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

Extend <datalist> for integration with <tbody>, <ul>, <select>, etc


Hi all,

First post so please forgive the poor formatting.

I am of the opinion that the <datalist> tag could be used a a general way to abstract on-page data from the page representation. This could be done most uniformly by adding the list attribute to several established elements. For example,

The goal of adding the list attribute to these elements is to minimize on-page data duplication. Sure the same results could be accomplished with JavaScript but that leads to maintainability issues.

I am of the opinion that the most optimal (for JavaScript developers – not to actually do) implementation would allow JavaScript to work with these elements via normal DOM traversal i.e. document.querySelectorAll('tr') should return an array of valid <tr> elements regardless of if the <tbody> was created with list="data" or not.

Up for discussion is if editing these elements in JavaScript should change the <datalist> thereby updating all other uses.

Feature Type: Spec Extension
Use Case: Reduce on-page data duplication
Requires: Native implementation of new attributes
Items of Discussion: Including but not limited to the following; necessity, implementation details, standardization of functionality, alternate use cases, other elements that could also be extended.
Other Details: Elements extended to include list= attribute should also fire onchange event for scripting hooks if they do not already. This event allows libraries to extend normal functionality for sorting, selecting, and altering data representation.