fp-dom / fd-class

Modify classes of an element
MIT License
6 stars 0 forks source link

API proposal #2

Closed stoeffel closed 9 years ago

stoeffel commented 9 years ago

This is a API proposal for addClass, but the basic idea can be applied to other functions too. Two points are important:

// addClass(getClass:Function(index:Int) --> String, getElements:Function() --> Array);

var setDisabled = addClass(always('disabled'));

setDisabled(query('.item'));

var alternate = addClass(function(index) {
  return (index % 2 === 0)?'even' : 'odd';
});

alternate(query('li'));
hemanth commented 9 years ago

query if normal DOM query it would return a NodeList not an Array, should we implement DOMQuery first?

stoeffel commented 9 years ago

query if normal DOM query it would return a NodeList not an Array, should we implement DOMQuery first?

agreed