Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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