clean-css.git
7 years agoVersion 4.0.2 release notes.
Jakub Pawlowicz [Thu, 26 Jan 2017 13:42:58 +0000 (14:42 +0100)]
Version 4.0.2 release notes.

7 years agoFixes #874 - regression in at-rule tokenization.
Jakub Pawlowicz [Thu, 26 Jan 2017 13:35:42 +0000 (14:35 +0100)]
Fixes #874 - regression in at-rule tokenization.

Why:

* Another case after #872 where at-rules were incorrectly
  tokenized because `propertyToken` wasn't reset.

7 years agoBumps web interface to version 4.0.1.
Jakub Pawlowicz [Wed, 25 Jan 2017 10:33:11 +0000 (11:33 +0100)]
Bumps web interface to version 4.0.1.

7 years agoVersion 4.0.1 release notes.
Jakub Pawlowicz [Wed, 25 Jan 2017 10:24:24 +0000 (11:24 +0100)]
Version 4.0.1 release notes.

7 years agoSee #872 - two additional cases.
Jakub Pawlowicz [Wed, 25 Jan 2017 10:13:23 +0000 (11:13 +0100)]
See #872 - two additional cases.

Unrelated to the ticket but should still be handled correctly.

7 years agoFixes #872 - edge case in tokenization.
Jakub Pawlowicz [Wed, 25 Jan 2017 10:12:14 +0000 (11:12 +0100)]
Fixes #872 - edge case in tokenization.

Why:

* On closing curly brace `}` both `ruleToken` and `propertyToken`
  should be nullified to prevent incorrect property assignments.

7 years agoFixes #868 - accept absolute paths in input hash.
Jakub Pawlowicz [Tue, 24 Jan 2017 20:18:03 +0000 (21:18 +0100)]
Fixes #868 - accept absolute paths in input hash.

Thanks to @madwizard-thomas for bug investigation which turned
out to be correct.

Why:

* Internally all local URIs should be represented as relative
  paths normalized to *nix format so nothing else gets propagated
  to output styles or source maps;
* all remote URIs are kept as is.

7 years agoFixes #867 - skips optimizing variable values.
Jakub Pawlowicz [Tue, 24 Jan 2017 14:43:33 +0000 (15:43 +0100)]
Fixes #867 - skips optimizing variable values.

Why:

* It may not be the best idea as we don't know what a value
  represents and where it'll end up.

7 years agoFixes #866 - edge case in `inline` flag handling.
Jakub Pawlowicz [Tue, 24 Jan 2017 12:16:00 +0000 (13:16 +0100)]
Fixes #866 - edge case in `inline` flag handling.

Why:

* When reverse order of options was used, so `remote,local`,
  a resource was incorrectly marked as not allowed;
* apparently we should always default remote URLs to disallowed,
  while local ones should be allowed by default.

7 years agochore(package): update browserify to version 14.0.0 (#871)
greenkeeper[bot] [Wed, 25 Jan 2017 09:19:23 +0000 (10:19 +0100)]
chore(package): update browserify to version 14.0.0 (#871)

https://greenkeeper.io/

7 years agoRe-enables batch tests on Windows. (#869)
Alex Lam S.L [Tue, 24 Jan 2017 09:30:00 +0000 (17:30 +0800)]
Re-enables batch tests on Windows. (#869)

Fix up assertEqualLineByLine(), checks if number of lines are equal before verifying content.

7 years agoSee #858 - updates web interface for clean-css 4.
Jakub Pawlowicz [Mon, 23 Jan 2017 10:00:36 +0000 (11:00 +0100)]
See #858 - updates web interface for clean-css 4.

Why:

* 4.0 changes lots of options and web users should still be able to
  apply all of them.

7 years agoVersion 4.0.0.
Jakub Pawlowicz [Mon, 23 Jan 2017 15:24:57 +0000 (16:24 +0100)]
Version 4.0.0.

7 years agoUpdates acknowledgements section.
Jakub Pawlowicz [Mon, 23 Jan 2017 15:15:05 +0000 (16:15 +0100)]
Updates acknowledgements section.

Thanks @alexlamsl, @ben-eb, @madwizard-thomas, and @ngyikp.

7 years agoSee #864 - adds better docs for optimization levels.
Jakub Pawlowicz [Mon, 23 Jan 2017 14:53:21 +0000 (15:53 +0100)]
See #864 - adds better docs for optimization levels.

It's not obvious if level 2 is used that level 1 is on by
default, and that both configurations can be applied
at the same time.

7 years agoRe-enables protocol tests on Windows.
Jakub Pawlowicz [Mon, 23 Jan 2017 13:06:00 +0000 (14:06 +0100)]
Re-enables protocol tests on Windows.

Thanks to @alexlamsl for bringing it up and testing.

Why:

* Disabled as they errored on Windows in the past, but they seem to
  work fine now.

7 years agoReworks Readme to be more readable.
Jakub Pawlowicz [Mon, 23 Jan 2017 13:04:33 +0000 (14:04 +0100)]
Reworks Readme to be more readable.

Why:

* Provides Table of contents at the top with quick links to
  interesting sections;
* Provides detailed description of available options with examples;
* Provides a FAQ section with various usage scenarios.

7 years agoSee #846 - moves CLI to a separate repository.
Jakub Pawlowicz [Sun, 22 Jan 2017 10:31:09 +0000 (11:31 +0100)]
See #846 - moves CLI to a separate repository.

Moved to https://github.com/jakubpawlowicz/clean-css-cli

Why:

* At least 85% of top dependants use the API (see ticket) so
  removing CLI removes `commander` dependency for them;
* docs will be easier to follow as they describe API only;
* tests run 10x as fast since binary tests took 90% of time;
* CLI will be able to provide its own set of features which
  are not necessarilly provided or requred in API.

Drawbacks:

* It won't be straightforward to quickly test arbitrary CSS
  as binary is not available out of the box.

7 years agoCleans up serializer code.
Jakub Pawlowicz [Fri, 20 Jan 2017 11:30:24 +0000 (12:30 +0100)]
Cleans up serializer code.

Why:

* Makes serialization context always the first argument;
* renamed function names for better clarity.

7 years agoRenames 'star' to 'asterisk'.
Jakub Pawlowicz [Fri, 20 Jan 2017 10:20:20 +0000 (11:20 +0100)]
Renames 'star' to 'asterisk'.

Why:

* This is the character's name.

7 years agoRenames curly bracket constants.
Jakub Pawlowicz [Fri, 20 Jan 2017 10:12:19 +0000 (11:12 +0100)]
Renames curly bracket constants.

Why:

* To match other bracket constants.

7 years agoRenames `Token.BLOCK` to `Token.NESTED_BLOCK`.
Jakub Pawlowicz [Fri, 20 Jan 2017 10:08:03 +0000 (11:08 +0100)]
Renames `Token.BLOCK` to `Token.NESTED_BLOCK`.

Why:

* All CSS blocks can be nested so this name reflects
  this rule better.

7 years agoSimplifies `split` helper code.
Jakub Pawlowicz [Fri, 20 Jan 2017 09:53:20 +0000 (10:53 +0100)]
Simplifies `split` helper code.

Why:

* Much of its complexity was due to old tokenizer which is no more;
* currently it serves as a way to splitting strings where commas
  inside round brackets are ignored.

7 years agoBumps copyright timestamps to 2017.
Jakub Pawlowicz [Fri, 20 Jan 2017 09:45:11 +0000 (10:45 +0100)]
Bumps copyright timestamps to 2017.

7 years agoFixes linting warning in specificity module.
Jakub Pawlowicz [Fri, 20 Jan 2017 09:44:29 +0000 (10:44 +0100)]
Fixes linting warning in specificity module.

7 years agoMoves API options setup to `options` folder-space.
Jakub Pawlowicz [Fri, 20 Jan 2017 09:42:05 +0000 (10:42 +0100)]
Moves API options setup to `options` folder-space.

Why:

* So it lives alongside optimization level and formatting setup.

7 years agoBumps online version to clean-css 3.4.24.
Jakub Pawlowicz [Fri, 20 Jan 2017 08:09:58 +0000 (09:09 +0100)]
Bumps online version to clean-css 3.4.24.

7 years agoVersion 3.4.24 release notes.
Jakub Pawlowicz [Fri, 20 Jan 2017 07:40:59 +0000 (08:40 +0100)]
Version 3.4.24 release notes.

7 years agoFixes #859 - avoids `-webkit-border-radius` optimizations.
Jakub Pawlowicz [Mon, 16 Jan 2017 16:55:38 +0000 (17:55 +0100)]
Fixes #859 - avoids `-webkit-border-radius` optimizations.

Why:

* Apparently it doesn't support shortening 4 values to 2, as the
  latter is taken as a horizontal + vertical radius in all corners;
* disabling any optimizations as a precaution;
* see http://jsfiddle.net/qnGKj/2881/

7 years agoSee #856 - adds missing History.md entry.
Jakub Pawlowicz [Fri, 20 Jan 2017 07:31:00 +0000 (08:31 +0100)]
See #856 - adds missing History.md entry.

7 years agoFixes #863 - adds `transform` callback for custom optimizations.
Jakub Pawlowicz [Thu, 19 Jan 2017 19:50:59 +0000 (20:50 +0100)]
Fixes #863 - adds `transform` callback for custom optimizations.

Why:

* So users can apply custom optimizations without forking clean-css
  and learning how to plug such optimization in;
* may also aid in rewriting URLs after introduction of `rebaseTo`.

7 years agoFixes #856 - allows `minify` to return a promise.
Jakub Pawlowicz [Thu, 19 Jan 2017 14:01:32 +0000 (15:01 +0100)]
Fixes #856 - allows `minify` to return a promise.

Why:

* Useful as an alternative to callback API;
* future Node.js versions will support `await` mechanism
  which requires supporting promises.

7 years agoAdds `overrideProperties` level 2 optimizations flag.
Jakub Pawlowicz [Wed, 18 Jan 2017 17:02:16 +0000 (18:02 +0100)]
Adds `overrideProperties` level 2 optimizations flag.

Why:

* Previously property overriding was controlled via `mergeIntoShorthands`
  flag which was confusing.

7 years agoMoves 'compacting' code to 'properties' folder-space.
Jakub Pawlowicz [Wed, 18 Jan 2017 16:46:03 +0000 (17:46 +0100)]
Moves 'compacting' code to 'properties' folder-space.

Why:

* All those optimizations are dealing with properties so the new
  name better reflects its role;

Also:

* renames `overrideCompactor` to `overrideProperties`;
* renames `compactorOptimize` to `optimizeProperties`.
* cleans up property optimizing code calling from level 2 optimizations
  due to removal of aggressive merging, see #290.

7 years agoRenames `compactShorthands` level 2 option to `mergeIntoShorthands`.
Jakub Pawlowicz [Wed, 18 Jan 2017 15:46:04 +0000 (16:46 +0100)]
Renames `compactShorthands` level 2 option to `mergeIntoShorthands`.

Why:

* It better describes what this option does.

7 years agoMakes compactable code more explicit.
Jakub Pawlowicz [Wed, 18 Jan 2017 15:17:09 +0000 (16:17 +0100)]
Makes compactable code more explicit.

Why:

* All unprefixed properties has to be declared explicitely,
  while vendor prefixed ones can be generated from them.

7 years agoSee #290 - adds removing IE filters.
Jakub Pawlowicz [Wed, 18 Jan 2017 13:56:34 +0000 (14:56 +0100)]
See #290 - adds removing IE filters.

Why:

* Internet Explorer `filter` / `-ms-filter` are unsupported since
  IE 10, which is also clean-css new default compatibility;
* can be restored by using `ie7`, `ie8`, or `ie9` compatibility
  modes.

7 years agoSee #290 - removes aggressive merging.
Jakub Pawlowicz [Wed, 18 Jan 2017 06:51:39 +0000 (07:51 +0100)]
See #290 - removes aggressive merging.

Why:

* Aggressive merging was replaced by override merging;
* it supports much more properties now so aggressive merging won't
  be missed;
* it also overrides based on understandability not merely a
  position in output file.

Side notes:

* This is a safe change as if a property is not configured to
  be overridable it won't be;
* overhauls `canOverride` functionality to prevent features like
  vendor prefixes or variables from overriding widely supported
  values;
* overhauls validating values by allowing known values, which
  strictly doesn't make it a full validator but rather a way
  of telling if a value *may* be valid.

7 years agoSee #290 - reworks `border` overriding.
Jakub Pawlowicz [Mon, 16 Jan 2017 07:38:46 +0000 (08:38 +0100)]
See #290 - reworks `border` overriding.

Why:

* Border is a complex case where both `border` and all its
  components: `border-color`, `border-style`, and `border-width`
  are components. Also `border-(bottom|left|right|top)` are
  shorthands too.
* this commit restores aggressive merging shorthand overriding right
  inside shorthand compacting code.

7 years agoSee #290 - disables `font` shorthand overriding.
Jakub Pawlowicz [Sun, 15 Jan 2017 11:14:26 +0000 (12:14 +0100)]
See #290 - disables `font` shorthand overriding.

Why:

* It's a shorthand property, so not straightforward to implement
  in shorthand/override compacting;
* pending in #254.

7 years agoSee #290 - disables `transition` shorthand overriding.
Jakub Pawlowicz [Sun, 15 Jan 2017 11:11:38 +0000 (12:11 +0100)]
See #290 - disables `transition` shorthand overriding.

Why:

* It's a shorthand property, so not straightforward to implement
  in shorthand/override compacting;
* pending in #861.

7 years agoSee #290 - disables `animation` shorthand overriding.
Jakub Pawlowicz [Sun, 15 Jan 2017 11:08:19 +0000 (12:08 +0100)]
See #290 - disables `animation` shorthand overriding.

Why:

* It's a shorthand property, so not straightforward to implement
  in shorthand/override compacting;
* pending in #860.

7 years agoSee #857 - removes redundant source map code.
Jakub Pawlowicz [Sun, 15 Jan 2017 11:25:15 +0000 (12:25 +0100)]
See #857 - removes redundant source map code.

Thanks to @alexlamsl for spotting it.

Why:

* Tracking input source map is done in #minify method already.

7 years agoFixes #857 - normalizes CleanCSS API interface.
Jakub Pawlowicz [Sun, 15 Jan 2017 10:28:13 +0000 (11:28 +0100)]
Fixes #857 - normalizes CleanCSS API interface.

Why:

* `sourceMap` option has to be a boolean now;
* input source map can be passed as a 2nd argument to `minify`
  method, making callback a 3rd;
* all other options are stateless so should be the `sourceMap`.

7 years agoRefactors validator into a set of functions.
Jakub Pawlowicz [Sat, 14 Jan 2017 21:35:28 +0000 (22:35 +0100)]
Refactors validator into a set of functions.

Why:

* There's no need to keep it as an object, since configuration
  can also be passed in.

7 years agoSee #799 - speeds up serializing code.
Jakub Pawlowicz [Sat, 14 Jan 2017 10:30:04 +0000 (11:30 +0100)]
See #799 - speeds up serializing code.

Why:

* Instead of using an `if` branch implements wrapping and tracking
  as a callback with `no-op` implementation when wrapping is disabled.

7 years agoSee #799 - adds an option to wrap output at arbitrary column.
Jakub Pawlowicz [Sat, 14 Jan 2017 10:19:41 +0000 (11:19 +0100)]
See #799 - adds an option to wrap output at arbitrary column.

Why:

* As not all clients (i.e. email clients) like CSS in one line.

7 years agoSee #799 - changes formatting defaults.
Jakub Pawlowicz [Fri, 13 Jan 2017 22:46:17 +0000 (23:46 +0100)]
See #799 - changes formatting defaults.

Why:

* When formatting is turned on it defaults to no formatting, so
  any options need to be applied on top of these;
* adds `beautify` preset for the previous default, e.g.
  `cleancss --format beautify one.css`.

7 years agoSee #799 - renames `beautify` option to `format`.
Jakub Pawlowicz [Fri, 13 Jan 2017 11:05:39 +0000 (12:05 +0100)]
See #799 - renames `beautify` option to `format`.

Why:

* It makes more sense as it controls formatting in general;
* see #209 where `beautify` was introduced.

7 years agoSee #799 - adds granular formatting options.
Jakub Pawlowicz [Thu, 12 Jan 2017 21:55:16 +0000 (22:55 +0100)]
See #799 - adds granular formatting options.

Why:

* To allow better control over how output is formatted;
* also gets rid of `keepBreaks` option in favor to
  `{ beautify: 'keep-breaks' }` shortcut.

7 years agoSee #773 - speeds up specificity lookup.
Jakub Pawlowicz [Wed, 11 Jan 2017 19:20:25 +0000 (20:20 +0100)]
See #773 - speeds up specificity lookup.

Why:

* Calculating it is slow, but, since it's done repeatedly for
  the same selectors, it can be cached quite effectively.

7 years agoFixes #773 - adds reordering based on selector specificity.
Jakub Pawlowicz [Wed, 11 Jan 2017 17:20:00 +0000 (18:20 +0100)]
Fixes #773 - adds reordering based on selector specificity.

Why:

* Rules with different specificity can be safely reordered as those
  with higher value will always override those with lower;
* there is no way to determine whether the latter can be ignored
  because HTML context is not known;
* this is a level 2 optimization which are off by default.

7 years agoSee #425 - nitpicking natural sorting algorithm.
Jakub Pawlowicz [Wed, 11 Jan 2017 07:40:03 +0000 (08:40 +0100)]
See #425 - nitpicking natural sorting algorithm.

Thanks to @alexlamsl for spotting these.

7 years agoFixes #425 - enables natural method of sorting selectors.
Jakub Pawlowicz [Tue, 10 Jan 2017 17:04:07 +0000 (18:04 +0100)]
Fixes #425 - enables natural method of sorting selectors.

Still defaults to standard sorting but natural becomes
a new option. Controlled via `selectorsSortingMethod`
option in level 1 optimizations.

Why:

* Natural way could be a more compression-efficient way;
* it's easier to read for a human.

7 years agoSee #425 - adds natural sorting algorithm.
Jakub Pawlowicz [Thu, 5 Jan 2017 11:35:17 +0000 (12:35 +0100)]
See #425 - adds natural sorting algorithm.

Why:

* We need it to sort selectors accordingly.

7 years agoAlways run CI on Node.js 7 too.
Jakub Pawlowicz [Wed, 11 Jan 2017 07:43:39 +0000 (08:43 +0100)]
Always run CI on Node.js 7 too.

At this moment it's a current version of Node.js so it'd be good
to run tests on it.

See: https://github.com/nodejs/LTS

7 years agoFixes #853 - renames level 2 options.
Jakub Pawlowicz [Tue, 10 Jan 2017 13:39:51 +0000 (14:39 +0100)]
Fixes #853 - renames level 2 options.

Why:

* To match level 1 wording which feels more natural.

7 years agoRestores proper multiple level handling in CLI.
Jakub Pawlowicz [Tue, 10 Jan 2017 12:42:35 +0000 (13:42 +0100)]
Restores proper multiple level handling in CLI.

Why:

* Apparently the earlier change to a single dash option
  broke using multiple optimization levels at once.
  This commit restores it.

7 years agoAdds examples of `all` keyword in level 1/2 optimizations.
Jakub Pawlowicz [Tue, 10 Jan 2017 11:11:22 +0000 (12:11 +0100)]
Adds examples of `all` keyword in level 1/2 optimizations.

Why:

* So the option is documented properly.

7 years agoAllows `all` shortcut in level 1 optimizations config.
Jakub Pawlowicz [Tue, 10 Jan 2017 11:05:27 +0000 (12:05 +0100)]
Allows `all` shortcut in level 1 optimizations config.

Why:

* To enable/disable all options at once;
* note non-boolean options are ignored when `all` / `*` is used.

7 years agoInverts some level 1 options for consistency.
Jakub Pawlowicz [Tue, 10 Jan 2017 10:09:48 +0000 (11:09 +0100)]
Inverts some level 1 options for consistency.

@alexlamsl made a good point that when we have `all` shortcut,
to set all options at once, it'd be good if value given would
mean the same to all options.

7 years agoAdds granular control over level 1 optimizations.
Jakub Pawlowicz [Mon, 9 Jan 2017 14:17:39 +0000 (15:17 +0100)]
Adds granular control over level 1 optimizations.

Why:

* So users can turn them on/off selectively;
* still keeping sane defaults for most users.

Note: moves `properties.fontWeight` compatibility flag to level 1
optimizations as that's not a compatibility flag, but rather a
user preference - see #756.

7 years agoRenames level 1 optimizations test file.
Jakub Pawlowicz [Mon, 9 Jan 2017 20:36:15 +0000 (21:36 +0100)]
Renames level 1 optimizations test file.

7 years agoReorganizes level 1 optimizations.
Jakub Pawlowicz [Mon, 9 Jan 2017 13:48:34 +0000 (14:48 +0100)]
Reorganizes level 1 optimizations.

Why:

* Slightly more coherent now, will get more love in 4.1.

7 years agoSee #731 - adds granular control over level 2 optimizations.
Jakub Pawlowicz [Mon, 9 Jan 2017 12:52:43 +0000 (13:52 +0100)]
See #731 - adds granular control over level 2 optimizations.

Why:

* So users can selectively disable certain optimizations if they
  want to.

7 years agoRuns benchmark on each optimization level.
Jakub Pawlowicz [Mon, 9 Jan 2017 10:52:12 +0000 (11:52 +0100)]
Runs benchmark on each optimization level.

7 years agoSee #791 - normalizes stored paths.
Jakub Pawlowicz [Mon, 9 Jan 2017 09:44:51 +0000 (10:44 +0100)]
See #791 - normalizes stored paths.

Stores all paths internally as normalized to *nix format but
still outputs Windows friendly paths if needed.

`source-map` does it internally so there's no need to transform
paths in source maps.

7 years agoReorganizes optimizer around levels.
Jakub Pawlowicz [Sun, 8 Jan 2017 17:04:18 +0000 (18:04 +0100)]
Reorganizes optimizer around levels.

Why:

* Gets rid of the flat structure where levels' code was mixed;
* moves level 2 compacting into a namespace (folderspace?).

7 years agoSee #807 - disables restructuring optimizations.
Jakub Pawlowicz [Sun, 8 Jan 2017 11:09:50 +0000 (12:09 +0100)]
See #807 - disables restructuring optimizations.

Can be brought back with:

* `{ level: { 2: { restructuring: true } } }` in API;
* `-O2 restructuring:on` in CLI.

Why:

* Those can be slow on big files;
* Need further optimizations and code cleanup, see #533.

7 years agoSee #842 - removes HTML comments from selectors.
Alex Lam S.L [Sun, 8 Jan 2017 10:36:26 +0000 (11:36 +0100)]
See #842 - removes HTML comments from selectors.

Kudos to @alexlamsl for the fix.

Why:

* Apparently anything wrapped between HTML comments still gets
  processed by browsers.

7 years agoSee #850 - restores `-On` CLI option.
Jakub Pawlowicz [Sun, 8 Jan 2017 09:52:37 +0000 (10:52 +0100)]
See #850 - restores `-On` CLI option.

Thanks @alexlamsl for figuring it out!

7 years agoFixes #717 - makes level 1 optimizations default.
Jakub Pawlowicz [Fri, 6 Jan 2017 13:26:12 +0000 (14:26 +0100)]
Fixes #717 - makes level 1 optimizations default.

Why:

* This way is safer for end user;
* Leaves level 2 optimizations up to end user to test and decide if
  the end result is good enough.

7 years agoFixes #836 - enables level `0` optimizations.
Jakub Pawlowicz [Fri, 6 Jan 2017 12:56:24 +0000 (13:56 +0100)]
Fixes #836 - enables level `0` optimizations.

Why:

* Some people may need to bundle and rebase CSS without applying
  any optimizations.

7 years agoSee #850 - allows `on` or `off` as level option values.
Jakub Pawlowicz [Fri, 6 Jan 2017 11:26:18 +0000 (12:26 +0100)]
See #850 - allows `on` or `off` as level option values.

Why:

* In CLI mode it makes more sense to use these instead of `true`
  or `false` as in API (JavaScript) context.

7 years agoSee #850 - cleans up optimization level code.
Jakub Pawlowicz [Fri, 6 Jan 2017 11:18:47 +0000 (12:18 +0100)]
See #850 - cleans up optimization level code.

Why:

* For better readability.

7 years agoSee #850 - allows overriding all options.
Jakub Pawlowicz [Fri, 6 Jan 2017 10:56:57 +0000 (11:56 +0100)]
See #850 - allows overriding all options.

Why:

* Use `all` or `*` to reset all options to a given value.

Example:

```js
new CleanCSS({
  level: {
    2: {
      all: false,
      mediaMerging: true
    }
  }
});
```

7 years agoFixes #850 - implements optimization levels.
Jakub Pawlowicz [Thu, 5 Jan 2017 22:14:26 +0000 (23:14 +0100)]
Fixes #850 - implements optimization levels.

Why:

* To logically split optimizations into three groups - level 0
  (not implemented yet), level 1, and level 2 (default);
* To allow more fine-grained control over what's optimized on
  each level (pending);
* To have a future-proof way of setting it for both API & CLI.

7 years agoRemoves `benchmark` API option.
Jakub Pawlowicz [Thu, 5 Jan 2017 13:46:02 +0000 (14:46 +0100)]
Removes `benchmark` API option.

Why:

* total time is reported under `stats`;
* it was seriously impaired since optimizing got encapsulated
  and not invoked directly from lib/clean.js.

7 years agoFixed #828 - `-chrome-` hack support.
Jakub Pawlowicz [Wed, 4 Jan 2017 21:22:05 +0000 (22:22 +0100)]
Fixed #828 - `-chrome-` hack support.

Why:

* It was incorrectly handled by property extractor.

7 years agoFixes #460 - unescaped semicolon in selector.
Jakub Pawlowicz [Wed, 4 Jan 2017 20:24:26 +0000 (21:24 +0100)]
Fixes #460 - unescaped semicolon in selector.

Why:

* Such rules should be dropped. Warnings are already in place.

7 years agoFixes #806 - skip optimizing variable properties.
Jakub Pawlowicz [Wed, 4 Jan 2017 17:43:50 +0000 (18:43 +0100)]
Fixes #806 - skip optimizing variable properties.

Why:

* So far it's impossible to find out real property values so
  breaking up shorthands into components doesn't work.
* In theory one could optimize cases where all component values
  are given and one of them is a variable, but it's an additional
  complexity probably not worth the hassle.

7 years agoSee #796 - adds missing History.md entry.
Jakub Pawlowicz [Wed, 4 Jan 2017 17:09:44 +0000 (18:09 +0100)]
See #796 - adds missing History.md entry.

7 years agoReuses `rulesOverlap` helper.
Jakub Pawlowicz [Wed, 4 Jan 2017 17:06:29 +0000 (18:06 +0100)]
Reuses `rulesOverlap` helper.

Why:

* It's used in more than one place and the code was not reused.

7 years agoFixes #796 - enables semantic merging for `@media` blocks.
Jakub Pawlowicz [Tue, 3 Jan 2017 16:37:56 +0000 (17:37 +0100)]
Fixes #796 - enables semantic merging for `@media` blocks.

* It's off by default and can be enabled via `semanticMerging` flag;
* Handles all cases and BEM classes.

7 years agoSee #689 - fixes regression in parsing property blocks.
Jakub Pawlowicz [Wed, 4 Jan 2017 15:23:05 +0000 (16:23 +0100)]
See #689 - fixes regression in parsing property blocks.

Why:

* New tokenizer introduced an issue where a semicolon ending a
  property block was handled incorrectly.

7 years agoFixes a bug ignoring incorrect properties in complex restructuring.
Jakub Pawlowicz [Sun, 1 Jan 2017 11:45:33 +0000 (12:45 +0100)]
Fixes a bug ignoring incorrect properties in complex restructuring.

Why:

* Apparently there was a wrong value returned from sorting callback
  which only manifested in complex stylesheets being restructured.

7 years agoSee #290 - allows `font-weight` overriding.
Jakub Pawlowicz [Sun, 1 Jan 2017 11:25:57 +0000 (12:25 +0100)]
See #290 - allows `font-weight` overriding.

Why:

* Another step to move away from aggressive merging.

7 years agoSee #290 - allows `height` overriding.
Jakub Pawlowicz [Sun, 1 Jan 2017 11:19:47 +0000 (12:19 +0100)]
See #290 - allows `height` overriding.

Why:

* Another step to move away from aggressive merging.

7 years agoFixes #750 - allows `width` overriding.
Jakub Pawlowicz [Sat, 31 Dec 2016 18:02:31 +0000 (19:02 +0100)]
Fixes #750 - allows `width` overriding.

Why:

* Width can be overriden easily using `unit` overrider.

7 years agoSee #829 - another performance optimization.
Jakub Pawlowicz [Sat, 31 Dec 2016 10:34:32 +0000 (11:34 +0100)]
See #829 - another performance optimization.

Why:

* Well, if a selector doesn't have a colon there is no point
  looking for any pseudo classes/elements.

7 years agoSee #829 - fixes a typo in method name.
Jakub Pawlowicz [Fri, 30 Dec 2016 21:55:20 +0000 (22:55 +0100)]
See #829 - fixes a typo in method name.

7 years agoSee #829 - some performance tweaks.
Jakub Pawlowicz [Fri, 30 Dec 2016 21:50:09 +0000 (22:50 +0100)]
See #829 - some performance tweaks.

Why:

* Uses flat loops instead of callbacks;
* Checks for number of matches before invoking costly calculations.

7 years agoFixes #829 - adds more strict selector merging rules.
Jakub Pawlowicz [Fri, 30 Dec 2016 21:23:29 +0000 (22:23 +0100)]
Fixes #829 - adds more strict selector merging rules.

Why:

* Instead of blacklisting unmergeable selectors we're now
  whitelisting the valid ones and reject all other.

7 years agoFixes #739 - error when a closing brace is missing.
Jakub Pawlowicz [Fri, 30 Dec 2016 11:49:02 +0000 (12:49 +0100)]
Fixes #739 - error when a closing brace is missing.

Why:

* When such content gets parsed into a block we should ignore
  the whole declaration as browsers do.

7 years agoSee #703 - adds `ie11` alias to default compatibility.
Jakub Pawlowicz [Fri, 30 Dec 2016 10:47:05 +0000 (11:47 +0100)]
See #703 - adds `ie11` alias to default compatibility.

7 years agoSee #703 - re-enables `background` longhand merging.
Jakub Pawlowicz [Fri, 30 Dec 2016 06:40:08 +0000 (07:40 +0100)]
See #703 - re-enables `background` longhand merging.

Why:

* See #577 and #579 - these two clearly state the issue is about
  IE8 not IE9+, and according to tests and caniuse.com tables
  using `background-(clip|origin|size)` in `background` shorthand
  is supported on IE9+;
* At this point I have no idea why it was disabled at the time.
  One idea is that it was disabled because IE9 doesn't support
  `properties.spaceAfterClosingBrace` and these two issues
  overlappedi at the time of 3.2 branch. (both were "fixed" in 3.3);
* Let's enable it again, since the default mode is now IE10+.

** Important note **: Safari <7 and Android stock browser <4.4
does not support it either so you'll likely have to disable if
you still support those. Just use `--compatibility ie8` to do so.

Test case: https://jsfiddle.net/7zLwv7o0/5/

7 years agoSee #703 - adds `ie10` alias to default compatibility.
Jakub Pawlowicz [Thu, 29 Dec 2016 11:32:52 +0000 (12:32 +0100)]
See #703 - adds `ie10` alias to default compatibility.

7 years agoSee #703 - changes default compatibility to IE10+.
Jakub Pawlowicz [Tue, 27 Dec 2016 20:15:10 +0000 (21:15 +0100)]
See #703 - changes default compatibility to IE10+.

Why:

* It's high time to move it up as IE9 is relatively old now.
* Adds `ie9` compatibility mode to make it easy to go back
  to 3.x default.

7 years agoSimplifies compatibility mode definitions.
Jakub Pawlowicz [Tue, 27 Dec 2016 15:51:40 +0000 (16:51 +0100)]
Simplifies compatibility mode definitions.

Why:

* Using inheritance it's clear which properties change.

7 years agoFixes #785 - adds `@font-face` de-duplication.
Jakub Pawlowicz [Tue, 27 Dec 2016 14:12:28 +0000 (15:12 +0100)]
Fixes #785 - adds `@font-face` de-duplication.

Why:

* Extra `@font-face` rules can be safely removed.
* There's no API/CLI switch to turn it off as it's pending
  a refactoring in v4 - see #842.