Skip to content

Commit

Permalink
perf(cdk/a11y): tree-shake warnings in production (#23967)
Browse files Browse the repository at this point in the history
(cherry picked from commit 39921f4)
  • Loading branch information
arturovt authored and zarend committed Nov 23, 2021
1 parent f05a9c6 commit b92f0bc
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/cdk/a11y/focus-trap/focus-trap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,26 +164,28 @@ export class FocusTrap {
*/
private _getRegionBoundary(bound: 'start' | 'end'): HTMLElement | null {
// Contains the deprecated version of selector, for temporary backwards comparability.
let markers = this._element.querySelectorAll(
const markers = this._element.querySelectorAll(
`[cdk-focus-region-${bound}], ` + `[cdkFocusRegion${bound}], ` + `[cdk-focus-${bound}]`,
) as NodeListOf<HTMLElement>;

for (let i = 0; i < markers.length; i++) {
// @breaking-change 8.0.0
if (markers[i].hasAttribute(`cdk-focus-${bound}`)) {
console.warn(
`Found use of deprecated attribute 'cdk-focus-${bound}', ` +
`use 'cdkFocusRegion${bound}' instead. The deprecated ` +
`attribute will be removed in 8.0.0.`,
markers[i],
);
} else if (markers[i].hasAttribute(`cdk-focus-region-${bound}`)) {
console.warn(
`Found use of deprecated attribute 'cdk-focus-region-${bound}', ` +
`use 'cdkFocusRegion${bound}' instead. The deprecated attribute ` +
`will be removed in 8.0.0.`,
markers[i],
);
if (typeof ngDevMode === 'undefined' || ngDevMode) {
for (let i = 0; i < markers.length; i++) {
// @breaking-change 8.0.0
if (markers[i].hasAttribute(`cdk-focus-${bound}`)) {
console.warn(
`Found use of deprecated attribute 'cdk-focus-${bound}', ` +
`use 'cdkFocusRegion${bound}' instead. The deprecated ` +
`attribute will be removed in 8.0.0.`,
markers[i],
);
} else if (markers[i].hasAttribute(`cdk-focus-region-${bound}`)) {
console.warn(
`Found use of deprecated attribute 'cdk-focus-region-${bound}', ` +
`use 'cdkFocusRegion${bound}' instead. The deprecated attribute ` +
`will be removed in 8.0.0.`,
markers[i],
);
}
}
}

Expand All @@ -207,7 +209,10 @@ export class FocusTrap {

if (redirectToElement) {
// @breaking-change 8.0.0
if (redirectToElement.hasAttribute(`cdk-focus-initial`)) {
if (
(typeof ngDevMode === 'undefined' || ngDevMode) &&
redirectToElement.hasAttribute(`cdk-focus-initial`)
) {
console.warn(
`Found use of deprecated attribute 'cdk-focus-initial', ` +
`use 'cdkFocusInitial' instead. The deprecated attribute ` +
Expand Down

0 comments on commit b92f0bc

Please sign in to comment.