- From: Lea Verou <notifications@github.com>
- Date: Wed, 25 Nov 2020 09:36:24 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 25 November 2020 17:36:36 UTC
> To clarify further what I'm proposing after this discussion: > > `Element.setAttributes = function(elements: HTMLElement[], attributeValues: {[attrName: string]: (string|number)[]})` > > This allows setting a set of attribute values to a set of elements, and also allows the combined setting of multiple attributes. I'm not quite sure I follow this syntax since I don't use TS, but the function should accept both singular nodes and arrays. We shouldn't have to pointlessly wrap a single element with an array to set multiple attributes on it. Similarly, we shouldn't need to wrap a single attribute-value pair with an object literal just to set it on multiple elements. jQuery did this very well: You could provide the name and value as separate arguments, or as one object literal, with many pairs. You could also operate on 0, 1, or multiple elements. As for values that differ per element, one solution would be to allow callbacks as the values, similarly to how `String#replace()` behaves differently with a string argument vs a function argument. This is also something that jQuery’s `attr()` method allowed. -- 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-733850594
Received on Wednesday, 25 November 2020 17:36:36 UTC