Skip to content

Commit 1a6f924

Browse files
refactor(multiple): Updated components to use host binding for ngSkipHydration (#26763)
This adds the skip hydration host binding to every component where direct dom manipulation occurs that would break hydration. This allows anyone that uses material components to not have to worry about manually adding this attribute themselves.
1 parent ead1f98 commit 1a6f924

File tree

18 files changed

+25
-1
lines changed

18 files changed

+25
-1
lines changed

src/cdk/table/table.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ export interface RenderRow<T> {
205205
host: {
206206
'class': 'cdk-table',
207207
'[class.cdk-table-fixed-layout]': 'fixedLayout',
208+
'ngSkipHydration': 'true',
208209
},
209210
encapsulation: ViewEncapsulation.None,
210211
// The "OnPush" status for the `MatTable` component is effectively a noop, so we are removing it.

src/material/autocomplete/autocomplete.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ export abstract class _MatAutocompleteBase
330330
inputs: ['disableRipple'],
331331
host: {
332332
'class': 'mat-mdc-autocomplete',
333+
'ngSkipHydration': 'true',
333334
},
334335
providers: [{provide: MAT_OPTION_PARENT_COMPONENT, useExisting: MatAutocomplete}],
335336
animations: [panelAnimation],

src/material/chips/chip-listbox.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export const MAT_CHIP_LISTBOX_CONTROL_VALUE_ACCESSOR: any = {
7575
'[attr.aria-disabled]': 'disabled.toString()',
7676
'[attr.aria-multiselectable]': 'multiple',
7777
'[attr.aria-orientation]': 'ariaOrientation',
78+
'ngSkipHydration': 'true',
7879
'[class.mat-mdc-chip-list-disabled]': 'disabled',
7980
'[class.mat-mdc-chip-list-required]': 'required',
8081
'(focus)': 'focus()',

src/material/legacy-autocomplete/autocomplete.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {_MatAutocompleteBase} from '@angular/material/autocomplete';
3535
inputs: ['disableRipple'],
3636
host: {
3737
'class': 'mat-autocomplete',
38+
'ngSkipHydration': 'true',
3839
},
3940
providers: [{provide: MAT_LEGACY_OPTION_PARENT_COMPONENT, useExisting: MatLegacyAutocomplete}],
4041
})

src/material/legacy-chips/chip-list.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export class MatLegacyChipListChange {
109109
'(blur)': '_blur()',
110110
'(keydown)': '_keydown($event)',
111111
'[id]': '_uid',
112+
'ngSkipHydration': 'true',
112113
},
113114
providers: [{provide: MatLegacyFormFieldControl, useExisting: MatLegacyChipList}],
114115
styleUrls: ['chips.css'],

src/material/legacy-form-field/form-field.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export const MAT_LEGACY_FORM_FIELD_DEFAULT_OPTIONS =
153153
'[class.ng-invalid]': '_shouldForward("invalid")',
154154
'[class.ng-pending]': '_shouldForward("pending")',
155155
'[class._mat-animation-noopable]': '!_animationsEnabled',
156+
'ngSkipHydration': 'true',
156157
},
157158
inputs: ['color'],
158159
encapsulation: ViewEncapsulation.None,

src/material/legacy-menu/menu.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
'[attr.aria-label]': 'null',
4040
'[attr.aria-labelledby]': 'null',
4141
'[attr.aria-describedby]': 'null',
42+
'ngSkipHydration': 'true',
4243
},
4344
animations: [matMenuAnimations.transformMenu, matMenuAnimations.fadeInItems],
4445
providers: [{provide: MAT_MENU_PANEL, useExisting: MatLegacyMenu}],

src/material/legacy-select/select.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export class MatLegacySelectTrigger {}
149149
'(keydown)': '_handleKeydown($event)',
150150
'(focus)': '_onFocus()',
151151
'(blur)': '_onBlur()',
152+
'ngSkipHydration': 'true',
152153
},
153154
animations: [
154155
matLegacySelectAnimations.transformPanelWrap,

src/material/legacy-table/table.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class MatLegacyRecycleRows {}
4646
host: {
4747
'class': 'mat-table',
4848
'[class.mat-table-fixed-layout]': 'fixedLayout',
49+
'ngSkipHydration': 'true',
4950
},
5051
providers: [
5152
// TODO(michaeljamesparsons) Abstract the view repeater strategy to a directive API so this code

src/material/legacy-tabs/tab-group.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import {
5454
'class': 'mat-tab-group',
5555
'[class.mat-tab-group-dynamic-height]': 'dynamicHeight',
5656
'[class.mat-tab-group-inverted-header]': 'headerPosition === "below"',
57+
'ngSkipHydration': 'true',
5758
},
5859
})
5960
export class MatLegacyTabGroup extends _MatTabGroupBase {

0 commit comments

Comments
 (0)