extract_part only checked for the closing brace under the if selector_range.cover? selectors_count condition. Because of this, it never knew that the media block had closed. This fix moves that check outside of that condition.
count_selectors_of_rule incorrectly counted the closing brace of the media query as a selector. This fix takes this into account.
@matthewd and @esbeka contributed the original implementation of this in #26 maybe they can review your changes to verify that everything is cool? After that I would cut a new release.
I noticed media query blocks weren't properly being handled when they occur entirely before the split. For instance, for the following CSS:
We would expect that the split would just contain this:
However, without this fix, it ends up containing this:
This was caused by two issues:
extract_part
only checked for the closing brace under theif selector_range.cover? selectors_count
condition. Because of this, it never knew that the media block had closed. This fix moves that check outside of that condition.count_selectors_of_rule
incorrectly counted the closing brace of the media query as a selector. This fix takes this into account.