Skip to content

Commit d071775

Browse files
crisbetoandrewseguin
authored andcommitted
refactor(expansion): constructor breaking changes for 8.0 (#15722)
* Applies the breaking changes for `material/expansion` for 8.0. * Fixes a symbol that made it into the upgrade schematic by accident. BREAKING CHANGES: * The `_document` and `_animationMode` parameters are now required.
1 parent 9c70aa3 commit d071775

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/lib/expansion/expansion-panel.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ export const MAT_EXPANSION_PANEL_DEFAULT_OPTIONS =
101101
export class MatExpansionPanel extends CdkAccordionItem implements AfterContentInit, OnChanges,
102102
OnDestroy {
103103

104-
// @breaking-change 8.0.0 Remove `| undefined` from here
105-
// when the `_document` constructor param is required.
106-
private _document: Document | undefined;
104+
private _document: Document;
107105

108106
/** Whether the toggle indicator should be hidden. */
109107
@Input()
@@ -146,9 +144,8 @@ export class MatExpansionPanel extends CdkAccordionItem implements AfterContentI
146144
_changeDetectorRef: ChangeDetectorRef,
147145
_uniqueSelectionDispatcher: UniqueSelectionDispatcher,
148146
private _viewContainerRef: ViewContainerRef,
149-
// @breaking-change 8.0.0 _document and _animationMode to be made required
150-
@Inject(DOCUMENT) _document?: any,
151-
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string,
147+
@Inject(DOCUMENT) _document: any,
148+
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode: string,
152149
@Inject(MAT_EXPANSION_PANEL_DEFAULT_OPTIONS) @Optional()
153150
defaultOptions?: MatExpansionPanelDefaultOptions) {
154151
super(accordion, _changeDetectorRef, _uniqueSelectionDispatcher);
@@ -215,7 +212,7 @@ export class MatExpansionPanel extends CdkAccordionItem implements AfterContentI
215212

216213
/** Checks whether the expansion panel's content contains the currently-focused element. */
217214
_containsFocus(): boolean {
218-
if (this._body && this._document) {
215+
if (this._body) {
219216
const focusedElement = this._document.activeElement;
220217
const bodyElement = this._body.nativeElement;
221218
return focusedElement === bodyElement || bodyElement.contains(focusedElement);

src/lib/schematics/ng-update/data/constructor-checks.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
3434
{
3535
pr: 'https://github.com/angular/material2/pull/15723',
3636
changes: ['MatList', 'MatListItem']
37+
},
38+
{
39+
pr: 'https://github.com/angular/material2/pull/15722',
40+
changes: ['MatExpansionPanel']
3741
}
3842
],
3943

tools/public_api_guard/lib/expansion.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export declare class MatExpansionModule {
3232
}
3333

3434
export declare class MatExpansionPanel extends CdkAccordionItem implements AfterContentInit, OnChanges, OnDestroy {
35-
_animationMode?: string | undefined;
35+
_animationMode: string;
3636
_body: ElementRef<HTMLElement>;
3737
_bodyAnimationDone: Subject<AnimationEvent>;
3838
_headerId: string;
@@ -43,7 +43,7 @@ export declare class MatExpansionPanel extends CdkAccordionItem implements After
4343
afterCollapse: EventEmitter<void>;
4444
afterExpand: EventEmitter<void>;
4545
hideToggle: boolean;
46-
constructor(accordion: MatAccordionBase, _changeDetectorRef: ChangeDetectorRef, _uniqueSelectionDispatcher: UniqueSelectionDispatcher, _viewContainerRef: ViewContainerRef, _document?: any, _animationMode?: string | undefined, defaultOptions?: MatExpansionPanelDefaultOptions);
46+
constructor(accordion: MatAccordionBase, _changeDetectorRef: ChangeDetectorRef, _uniqueSelectionDispatcher: UniqueSelectionDispatcher, _viewContainerRef: ViewContainerRef, _document: any, _animationMode: string, defaultOptions?: MatExpansionPanelDefaultOptions);
4747
_containsFocus(): boolean;
4848
_getExpandedState(): MatExpansionPanelState;
4949
_hasSpacing(): boolean;

0 commit comments

Comments
 (0)