angular/material — pull request #978 by gkalpak (2014-12-18 14:34:41+00:00)
Title: mdMedia improvements

This PR contains some improvements to `mdMedia`, split-up in 3 commits as follows:

1. **fix(mdUtil): remove/delete cacheFactory keys when clearing/destroying cache:**
`mdUtil`'s custom `cacheFactory` factory, adds/removes keys when putting/removing a single key, but leaves `keys` untouched when calling `removeAll()` or `destroy()`. As a result, the following problems arise:

- Keys of destroyed caches continue to take up memory.
- The `keys()` method return incorrect results after calling `removeAll()` (i.e. it continues to return the old keys, although they are not present in the cache any more).

This commit fixes these issues, by overriding the `removeAll` and
`destroy` methods as well.

2. **fix(mdMedia): avoid unnecessary digest and make changes apply quicker:**
Previously, the `updateAll()` method relied on `$timeout` for scheduling a digest. This made the possible changes apply after the next rendering and could possibly lead to extra digests.
This commit, replaces the call to `$timeout` with a call to `$evalAsync()`, which avoids an extra digest if one is already in progress and also applies the changes before the next rendering.

3. **test(mdMedia): add more tests and move .spec file to correct location:**
In commit 6397040 `mdMedia` was moved out of the `sidenav` component and into `core`. The .spec file remained in the original folder though.
This commit moves the 'media.spec.js` file to the correct location and adds more tests to more thoroughly cover `mdMedia`'s functionality.