- From: Michail Schwab <notifications@github.com>
- Date: Thu, 17 Sep 2020 08:23:57 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Thursday, 17 September 2020 15:24:09 UTC
I propose the addition of a `setAttributes` function to the NodeList prototype to support bulk-setting attribute values on a collection of nodes: `NodeList.prototype.setAttributes = function(this: NodeList, attribute: string, values: (string|number)[]) {}` Many popular JS frameworks, such as jQuery ([link](https://www.w3schools.com/jquery/html_attr.asp)) and D3.js ([link](https://github.com/d3/d3-selection)), come with such `attr` or similar functions that allow bulk-setting attribute values for many nodes at once. Internally, these functions have to loop over the selection of nodes and call the `setAttribute` function on individual nodes. When hundreds of nodes are updated at once, the overhead from the repeated traversal from JS function calls down to browsers' internal attribute changes adds up to significant performance costs. See related [crbug](https://crbug.com/978513). With the addition of a `setAttributes` function, users and framework creators would not have to manually loop over the nodes, simplifying the implementation, while browser creators could optimize the implementation and performance for bulk-setting attributes. -- 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
Received on Thursday, 17 September 2020 15:24:09 UTC