- From: yuzhehan <notifications@github.com>
- Date: Fri, 04 Dec 2020 18:13:11 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/895/739107560@github.com>
Thanks for the clarification!
I see three variations of bulk setting attributes API.
1. Method for setting multiple attributes for a single element. Example in [Lea's comment](https://github.com/whatwg/dom/issues/895#issuecomment-726836174).
```javascript
interface Element {
[CEReactions] undefined setAttributes( DOMStringMap attributes );
}
```
2. Method for setting the same set of attributes for a list of elements. It builds on top of 1 where the method loops internally and invokes setAttributes() for each element. I don't see any precedence for defining static methods in the DOM spec. Maybe it should become its own object, ElementSetter | BulkSetter ?
```javascript
interface ElementSetter {
undefined setAttributes(sequence<Element>, DOMStringMap attributes);
}
```
3. Method for setting one attribute for a list of elements where the values are unique to each element in the list.
```javascript
interface ElementSetter {
undefined setAttributes(sequence<Element>, DOMString qualifiedName, sequence<DOMString> values);
}
```
These APIs should simplify the implementations of jQuery ([link](https://www.w3schools.com/jquery/html_attr.asp)) and D3.js ([link](https://github.com/d3/d3-selection)) and improve performance by eliminating the needs to access DOM inside a loop.
@michaschwab @LeaVerou @developit Do these APIs meets your needs? At least for setting attributes?
@annevk mentioned above that invoking multiple setter should be tackled in a separate issue. Was that in reference to setting both attributes and properties? Do you have any suggestions on where to define these APIs, for 2 and 3?
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/895#issuecomment-739107560
Received on Saturday, 5 December 2020 02:13:24 UTC