File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed
universal-app/kitchen-sink Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,12 @@ import {take} from 'rxjs/operators/take';
2121import { InteractivityChecker } from './interactivity-checker' ;
2222import { DOCUMENT } from '@angular/common' ;
2323
24+ /**
25+ * Node type of element nodes. Used instead of Node.ELEMENT_NODE
26+ * which is unsupported in Universal.
27+ * @docs -private
28+ */
29+ const ELEMENT_NODE_TYPE = 1 ;
2430
2531/**
2632 * Class that allows for trapping focus within a DOM element.
@@ -223,7 +229,7 @@ export class FocusTrap {
223229 let children = root . children || root . childNodes ;
224230
225231 for ( let i = 0 ; i < children . length ; i ++ ) {
226- let tabbableChild = children [ i ] . nodeType === Node . ELEMENT_NODE ?
232+ let tabbableChild = children [ i ] . nodeType === ELEMENT_NODE_TYPE ?
227233 this . _getFirstTabbableElement ( children [ i ] as HTMLElement ) :
228234 null ;
229235
@@ -245,7 +251,7 @@ export class FocusTrap {
245251 let children = root . children || root . childNodes ;
246252
247253 for ( let i = children . length - 1 ; i >= 0 ; i -- ) {
248- let tabbableChild = children [ i ] . nodeType === Node . ELEMENT_NODE ?
254+ let tabbableChild = children [ i ] . nodeType === ELEMENT_NODE_TYPE ?
249255 this . _getLastTabbableElement ( children [ i ] as HTMLElement ) :
250256 null ;
251257
Original file line number Diff line number Diff line change @@ -421,7 +421,8 @@ export class MatIconRegistry {
421421 let svg = this . _svgElementFromString ( '<svg></svg>' ) ;
422422
423423 for ( let i = 0 ; i < element . childNodes . length ; i ++ ) {
424- if ( element . childNodes [ i ] . nodeType === Node . ELEMENT_NODE ) {
424+ // Note: 1 corresponds to `Node.ELEMENT_NODE` which we can't use in Universal.
425+ if ( element . childNodes [ i ] . nodeType === 1 ) {
425426 svg . appendChild ( element . childNodes [ i ] . cloneNode ( true ) ) ;
426427 }
427428 }
Original file line number Diff line number Diff line change @@ -177,7 +177,10 @@ <h2>Select</h2>
177177
178178< h2 > Sidenav</ h2 >
179179< mat-sidenav-container >
180- < mat-sidenav opened > On the side</ mat-sidenav >
180+ < mat-sidenav opened >
181+ On the side
182+ < button > Button for testing focus trapping</ button >
183+ </ mat-sidenav >
181184 Main content
182185 < button > Click me</ button >
183186</ mat-sidenav-container >
You can’t perform that action at this time.
0 commit comments