aanand / deadweight

NOT MAINTAINED
MIT License
1.19k stars 52 forks source link

Refactor for performance and features #32

Open MaxLap opened 9 years ago

MaxLap commented 9 years ago

This is a set of changes that improve deadweight's performance and adds support for more css.

Normalizing the selectors to minimize the number that needs to be checked.

By making a tree with selectors that imply each other, we can only search a subset of the selectors at a time. Ex: if you have the two selectors: ".hello" and ".hello.world", then ".hello.world" implies that ".hello" would match. So until you find a ".hello", there is no reason to look for a ".hello.world". This can greatly improve the speed nested styles.

Now supporting many pseudo-classes (Based on nokogiri's supported pseudoclasses, needed to update the Gemfile.lock for nokogiri to handle some of them correctly). Additionnally, we strip the :hover and :valid since logically, if you find the element, that the :hover is also found...

When a rule is not supported, it is now handled correctly. Output wise, it remains a simple "unused" rule. That could be improved in the future to distinguish them.

MaxLap commented 9 years ago

Just wanted to say that the reason the build fails is because Nokogiri 1.6.6.2 isn't supported for 1.8.7 it seems.

aanand commented 9 years ago

Thanks! I have very little time to look after deadweight these days, but I'll take a look as soon as I can.