Skip to content

Commit 209748f

Browse files
committed
Merge branch 'master' of https://github.com/angular/material2
2 parents e8a74bb + bb69483 commit 209748f

File tree

103 files changed

+1196
-377
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+1196
-377
lines changed

.clang-format

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ ColumnLimit: 100
44

55
TabWidth: 2
66
ContinuationIndentWidth: 4
7-
MaxEmptyLinesToKeep : 2
7+
MaxEmptyLinesToKeep: 2
88

99
AllowShortBlocksOnASingleLine: false
1010
AllowShortIfStatementsOnASingleLine: false
1111
AllowShortLoopsOnASingleLine: false
1212
AllowShortFunctionsOnASingleLine: Empty
13+
JavaScriptWrapImports: true
14+

.huskyrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"hooks": {
3+
"pre-commit": "check-clang-format \"\\`yarn format\\`\""
4+
}
5+
}

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
## 7.3.2 "jute-box" (2019-02-11)
2+
3+
4+
### Bug Fixes
5+
6+
* **autocomplete:** set aria-haspopup ([#15079](https://github.com/angular/material2/issues/15079)) ([45bd5d4](https://github.com/angular/material2/commit/45bd5d4))
7+
* **checkbox:** unable to click to select if text is marked ([#15062](https://github.com/angular/material2/issues/15062)) ([4819c5b](https://github.com/angular/material2/commit/4819c5b)), closes [#14967](https://github.com/angular/material2/issues/14967)
8+
* **drag-drop:** set class when item or list is disabled ([#14769](https://github.com/angular/material2/issues/14769)) ([c543cf6](https://github.com/angular/material2/commit/c543cf6)), closes [#14760](https://github.com/angular/material2/issues/14760)
9+
* **drag-drop:** standalone draggable drag class not being applied with OnPush change detection ([#14727](https://github.com/angular/material2/issues/14727)) ([2f63195](https://github.com/angular/material2/commit/2f63195))
10+
* **icon:** add notranslate class ([#14889](https://github.com/angular/material2/issues/14889)) ([39fa928](https://github.com/angular/material2/commit/39fa928))
11+
* **menu:** prevent removal of mat-elevation class ([#15035](https://github.com/angular/material2/issues/15035)) ([8069641](https://github.com/angular/material2/commit/8069641))
12+
* **slide-toggle:** input element should use switch role ([#15073](https://github.com/angular/material2/issues/15073)) ([3af7748](https://github.com/angular/material2/commit/3af7748)), closes [#14949](https://github.com/angular/material2/issues/14949)
13+
* **tree:** opposite direction padding not being reset on change ([#14816](https://github.com/angular/material2/issues/14816)) ([ae4a5ae](https://github.com/angular/material2/commit/ae4a5ae))
14+
15+
16+
117
## 7.3.1 "liquidcrystal-sandwich" (2019-02-04)
218

319

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ and which pieces are blocked) and make a comment.
2626
Also see our [`help wanted`](https://github.com/angular/material2/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
2727
label.
2828

29-
High level stuff planned for Q4 2018 (October - Dec):
30-
* Improve our own build and automation tooling
31-
* Fix bugs and reduce some technical debt inside Google
32-
* Working on long-term plans on how to collaborate with the MDC Web team
33-
* Designs for advanced table improvements (column resize, selection directives, inline-edit)
29+
#### High level stuff planned for Q1 → Q2 2019 (January - June):
30+
* Most of the Angular Material team is on loan to the framework team
31+
helping with [Ivy](https://blog.angular.io/a-plan-for-version-8-0-and-ivy-b3318dfc19f7).
32+
We've been using the Angular CDK and Angular Material tests to validate code paths as well
33+
as helping debug issues in switching Google applications to the new rendering pipeline.
34+
* We're also working with the Material Design team on a strategy to collaborate more deeply.
35+
We'll have more to share on this once our plans are further along.
36+
* Assorted bugfixes and minor feature improvements.
37+
* Design for API enhancements to the tree component to improve ergonomics.
3438

3539

3640
#### Available features

guides/theming-your-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ For example:
9393
// Get a relative color for a hue ('lighter' or 'darker')
9494
outline-color: mat-color($accent, lighter);
9595

96-
// Get a constrast color for a hue by adding `-contrast` to any other key.
96+
// Get a contrast color for a hue by adding `-contrast` to any other key.
9797
border-color: mat-color($primary, '100-contrast');
9898
}
9999
```

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"node": ">= 5.4.1"
1313
},
1414
"scripts": {
15-
"build": "gulp :publish:build-releases",
15+
"build": "gulp build-release-packages",
1616
"dev-app": "gulp serve:devapp",
1717
"test": "gulp test",
1818
"lint": "gulp lint",
@@ -24,9 +24,10 @@
2424
"stage-release": "ts-node --project tools/release/ tools/release/stage-release.ts",
2525
"publish-release": "ts-node --project tools/release/ tools/release/publish-release.ts",
2626
"check-release-output": "ts-node --project tools/release tools/release/check-release-output.ts",
27-
"preinstall": "node ./tools/npm/check-npm.js"
27+
"preinstall": "node ./tools/npm/check-npm.js",
28+
"format": "git-clang-format"
2829
},
29-
"version": "7.3.1",
30+
"version": "7.3.2",
3031
"requiredAngularVersion": ">=7.0.0",
3132
"dependencies": {
3233
"@angular/animations": "^7.2.1",
@@ -79,6 +80,7 @@
7980
"axe-webdriverjs": "^1.1.1",
8081
"browser-sync": "^2.26.3",
8182
"chalk": "^1.1.3",
83+
"clang-format": "^1.2.4",
8284
"codelyzer": "^4.5.0",
8385
"conventional-changelog": "^3.0.5",
8486
"dgeni": "^0.4.10",
@@ -98,6 +100,7 @@
98100
"hammerjs": "^2.0.8",
99101
"highlight.js": "^9.11.0",
100102
"http-rewrite-middleware": "^0.1.6",
103+
"husky": "^1.3.1",
101104
"inquirer": "^6.2.0",
102105
"jasmine-core": "^3.3.0",
103106
"karma": "^3.1.4",

scripts/saucelabs/start-tunnel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e -o pipefail
44

5-
tunnelFileName="sc-4.5.3-linux.tar.gz"
5+
tunnelFileName="sc-4.5.1-linux.tar.gz"
66
tunnelUrl="https://saucelabs.com/downloads/${tunnelFileName}"
77

88
tunnelTmpDir="/tmp/material-saucelabs"

src/cdk/a11y/_a11y.scss

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
}
1919
}
2020

21-
/**
22-
* Applies styles for users in high contrast mode. Note that this only applies
23-
* to Microsoft browsers. Chrome can be included by checking for the `html[hc]`
24-
* attribute, however Chrome handles high contrast differently.
25-
* @param target Which kind of high contrast setting to target. Defaults to `active`, can be
26-
* `white-on-black` or `black-on-white`.
27-
*/
21+
// Applies styles for users in high contrast mode. Note that this only applies
22+
// to Microsoft browsers. Chrome can be included by checking for the `html[hc]`
23+
// attribute, however Chrome handles high contrast differently.
24+
//
25+
// @param target Which kind of high contrast setting to target. Defaults to `active`, can be
26+
// `white-on-black` or `black-on-white`.
2827
@mixin cdk-high-contrast($target: active) {
2928
@media (-ms-high-contrast: $target) {
3029
@content;

src/cdk/a11y/live-announcer/live-announcer-token.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {InjectionToken} from '@angular/core';
10+
11+
// The tokens for the live announcer are defined in a separate file from LiveAnnouncer
12+
// as a workaround for https://github.com/angular/angular/issues/22559
13+
14+
/** Possible politeness levels. */
15+
export type AriaLivePoliteness = 'off' | 'polite' | 'assertive';
16+
17+
export const LIVE_ANNOUNCER_ELEMENT_TOKEN =
18+
new InjectionToken<HTMLElement | null>('liveAnnouncerElement', {
19+
providedIn: 'root',
20+
factory: LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY,
21+
});
22+
23+
/** @docs-private */
24+
export function LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY(): null {
25+
return null;
26+
}
27+
28+
/** Object that can be used to configure the default options for the LiveAnnouncer. */
29+
export interface LiveAnnouncerDefaultOptions {
30+
/** Default politeness for the announcements. */
31+
politeness?: AriaLivePoliteness;
32+
33+
/** Default duration for the announcement messages. */
34+
duration?: number;
35+
}
36+
37+
/** Injection token that can be used to configure the default options for the LiveAnnouncer. */
38+
export const LIVE_ANNOUNCER_DEFAULT_OPTIONS =
39+
new InjectionToken<LiveAnnouncerDefaultOptions>('LIVE_ANNOUNCER_DEFAULT_OPTIONS');

src/cdk/a11y/live-announcer/live-announcer.spec.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import {ComponentFixture, fakeAsync, flush, inject, TestBed, tick} from '@angula
44
import {By} from '@angular/platform-browser';
55
import {A11yModule} from '../index';
66
import {LiveAnnouncer} from './live-announcer';
7-
import {LIVE_ANNOUNCER_ELEMENT_TOKEN} from './live-announcer-token';
7+
import {
8+
LIVE_ANNOUNCER_ELEMENT_TOKEN,
9+
LIVE_ANNOUNCER_DEFAULT_OPTIONS,
10+
LiveAnnouncerDefaultOptions,
11+
} from './live-announcer-tokens';
812

913

1014
describe('LiveAnnouncer', () => {
@@ -189,6 +193,47 @@ describe('LiveAnnouncer', () => {
189193
expect(customLiveElement.textContent).toBe('Custom Element');
190194
}));
191195
});
196+
197+
describe('with a default options', () => {
198+
beforeEach(() => {
199+
return TestBed.configureTestingModule({
200+
imports: [A11yModule],
201+
declarations: [TestApp],
202+
providers: [{
203+
provide: LIVE_ANNOUNCER_DEFAULT_OPTIONS,
204+
useValue: {
205+
politeness: 'assertive',
206+
duration: 1337
207+
} as LiveAnnouncerDefaultOptions
208+
}],
209+
});
210+
});
211+
212+
beforeEach(inject([LiveAnnouncer], (la: LiveAnnouncer) => {
213+
announcer = la;
214+
ariaLiveElement = getLiveElement();
215+
}));
216+
217+
it('should pick up the default politeness from the injection token', fakeAsync(() => {
218+
announcer.announce('Hello');
219+
220+
tick(2000);
221+
222+
expect(ariaLiveElement.getAttribute('aria-live')).toBe('assertive');
223+
}));
224+
225+
it('should pick up the default politeness from the injection token', fakeAsync(() => {
226+
announcer.announce('Hello');
227+
228+
tick(100);
229+
expect(ariaLiveElement.textContent).toBe('Hello');
230+
231+
tick(1337);
232+
expect(ariaLiveElement.textContent).toBeFalsy();
233+
}));
234+
235+
});
236+
192237
});
193238

194239
describe('CdkAriaLive', () => {

src/cdk/a11y/live-announcer/live-announcer.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ import {
2121
SkipSelf,
2222
} from '@angular/core';
2323
import {Subscription} from 'rxjs';
24-
import {LIVE_ANNOUNCER_ELEMENT_TOKEN} from './live-announcer-token';
25-
24+
import {
25+
AriaLivePoliteness,
26+
LiveAnnouncerDefaultOptions,
27+
LIVE_ANNOUNCER_ELEMENT_TOKEN,
28+
LIVE_ANNOUNCER_DEFAULT_OPTIONS,
29+
} from './live-announcer-tokens';
2630

27-
/** Possible politeness levels. */
28-
export type AriaLivePoliteness = 'off' | 'polite' | 'assertive';
2931

3032
@Injectable({providedIn: 'root'})
3133
export class LiveAnnouncer implements OnDestroy {
@@ -36,7 +38,9 @@ export class LiveAnnouncer implements OnDestroy {
3638
constructor(
3739
@Optional() @Inject(LIVE_ANNOUNCER_ELEMENT_TOKEN) elementToken: any,
3840
private _ngZone: NgZone,
39-
@Inject(DOCUMENT) _document: any) {
41+
@Inject(DOCUMENT) _document: any,
42+
@Optional() @Inject(LIVE_ANNOUNCER_DEFAULT_OPTIONS)
43+
private _defaultOptions?: LiveAnnouncerDefaultOptions) {
4044

4145
// We inject the live element and document as `any` because the constructor signature cannot
4246
// reference browser globals (HTMLElement, Document) on non-browser environments, since having
@@ -82,8 +86,9 @@ export class LiveAnnouncer implements OnDestroy {
8286
announce(message: string, politeness?: AriaLivePoliteness, duration?: number): Promise<void>;
8387

8488
announce(message: string, ...args: any[]): Promise<void> {
85-
let politeness: AriaLivePoliteness;
86-
let duration: number;
89+
const defaultOptions = this._defaultOptions;
90+
let politeness: AriaLivePoliteness | undefined;
91+
let duration: number | undefined;
8792

8893
if (args.length === 1 && typeof args[0] === 'number') {
8994
duration = args[0];
@@ -94,8 +99,17 @@ export class LiveAnnouncer implements OnDestroy {
9499
this.clear();
95100
clearTimeout(this._previousTimeout);
96101

102+
if (!politeness) {
103+
politeness =
104+
(defaultOptions && defaultOptions.politeness) ? defaultOptions.politeness : 'polite';
105+
}
106+
107+
if (duration == null && defaultOptions) {
108+
duration = defaultOptions.duration;
109+
}
110+
97111
// TODO: ensure changing the politeness works on all environments we support.
98-
this._liveElement.setAttribute('aria-live', politeness! || 'polite');
112+
this._liveElement.setAttribute('aria-live', politeness);
99113

100114
// This 100ms timeout is necessary for some browser + screen-reader combinations:
101115
// - Both JAWS and NVDA over IE11 will not announce anything without a non-zero timeout.

src/cdk/a11y/public-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export * from './key-manager/list-key-manager';
1212
export * from './focus-trap/focus-trap';
1313
export * from './interactivity-checker/interactivity-checker';
1414
export * from './live-announcer/live-announcer';
15-
export * from './live-announcer/live-announcer-token';
15+
export * from './live-announcer/live-announcer-tokens';
1616
export * from './focus-monitor/focus-monitor';
1717
export * from './fake-mousedown';
1818
export * from './a11y-module';

src/cdk/bidi/bidi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class MyWidget implements OnDestroy {
2020
constructor(dir: Directionality) {
2121
this.isRtl = dir.value === 'rtl';
2222

23-
_dirChangeSubscription = dir.change.subscribe(() => {
23+
this._dirChangeSubscription = dir.change.subscribe(() => {
2424
this.flipDirection();
2525
});
2626
}

src/cdk/bidi/dir.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ export class Dir implements Directionality, AfterContentInit, OnDestroy {
4747
get dir(): Direction { return this._dir; }
4848
set dir(value: Direction) {
4949
const old = this._dir;
50+
const normalizedValue = value ? value.toLowerCase() : value;
5051

5152
this._rawDir = value;
52-
this._dir = (value === 'ltr' || value === 'rtl') ? value : 'ltr';
53+
this._dir = (normalizedValue === 'ltr' || normalizedValue === 'rtl') ? normalizedValue : 'ltr';
5354

5455
if (old !== this._dir && this._isInitialized) {
5556
this.change.emit(this._dir);

src/cdk/bidi/directionality.spec.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ describe('Directionality', () => {
1111

1212
TestBed.configureTestingModule({
1313
imports: [BidiModule],
14-
declarations: [ElementWithDir, ElementWithPredefinedAutoDir, InjectsDirectionality],
14+
declarations: [
15+
ElementWithDir,
16+
ElementWithPredefinedAutoDir,
17+
InjectsDirectionality,
18+
ElementWithPredefinedUppercaseDir,
19+
],
1520
providers: [{provide: DIR_DOCUMENT, useFactory: () => fakeDocument}],
1621
}).compileComponents();
1722
}));
@@ -134,6 +139,13 @@ describe('Directionality', () => {
134139
expect(fixture.componentInstance.dir.value).toBe('ltr');
135140
});
136141

142+
it('should be case-insensitive', () => {
143+
const fixture = TestBed.createComponent(ElementWithPredefinedUppercaseDir);
144+
fixture.detectChanges();
145+
146+
expect(fixture.componentInstance.dir.value).toBe('rtl');
147+
});
148+
137149
});
138150
});
139151

@@ -158,6 +170,14 @@ class ElementWithPredefinedAutoDir {
158170
@ViewChild(Dir) dir: Dir;
159171
}
160172

173+
@Component({
174+
template: '<div dir="RTL"></div>'
175+
})
176+
class ElementWithPredefinedUppercaseDir {
177+
@ViewChild(Dir) dir: Dir;
178+
}
179+
180+
161181
/** Test component with Dir directive. */
162182
@Component({
163183
selector: 'injects-directionality',

0 commit comments

Comments
 (0)