mattdesl / dom-css

fast dom CSS styling
MIT License
152 stars 13 forks source link

multiple elements support (nodeList) #8

Open baptistebriel opened 9 years ago

baptistebriel commented 9 years ago

hi matt, i was wondering, is there a possibility to support the nodeList as the params' element?

i.e:

css(document.querySelectorAll('.el'), 'width', '200px')

otherwise i guess i'll just do a simple forEach but it'd be great to be able to pass a nodeList or array directly. let me know what you think!

mattdesl commented 9 years ago

Array + NodeList would be handy.

But how would css.get() behave? It might create a bit of weirdness / inconsistency in the API.

baptistebriel commented 9 years ago

hm, that's true.. maybe it could return an array, do you think it'd be weird?

mattdesl commented 9 years ago

This is what jquery does:

Get the value of a computed style property for the first element in the set of matched elements or set one or more CSS properties for every matched element.

http://api.jquery.com/css/

A bit weird... But I guess it works for jQuery :grimacing: So we could do the same.

baptistebriel commented 9 years ago

I don't see that much use cases where you'd like to get an array of CSS props, but for setting a value sometimes it'd prevent from doing a forEach..

I guess this is more an enhancement but not sure if it fits with the goals of the module.