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';
21
21
import { InteractivityChecker } from './interactivity-checker' ;
22
22
import { DOCUMENT } from '@angular/common' ;
23
23
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 ;
24
30
25
31
/**
26
32
* Class that allows for trapping focus within a DOM element.
@@ -223,7 +229,7 @@ export class FocusTrap {
223
229
let children = root . children || root . childNodes ;
224
230
225
231
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 ?
227
233
this . _getFirstTabbableElement ( children [ i ] as HTMLElement ) :
228
234
null ;
229
235
@@ -245,7 +251,7 @@ export class FocusTrap {
245
251
let children = root . children || root . childNodes ;
246
252
247
253
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 ?
249
255
this . _getLastTabbableElement ( children [ i ] as HTMLElement ) :
250
256
null ;
251
257
Original file line number Diff line number Diff line change @@ -421,7 +421,8 @@ export class MatIconRegistry {
421
421
let svg = this . _svgElementFromString ( '<svg></svg>' ) ;
422
422
423
423
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 ) {
425
426
svg . appendChild ( element . childNodes [ i ] . cloneNode ( true ) ) ;
426
427
}
427
428
}
Original file line number Diff line number Diff line change @@ -177,7 +177,10 @@ <h2>Select</h2>
177
177
178
178
< h2 > Sidenav</ h2 >
179
179
< 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 >
181
184
Main content
182
185
< button > Click me</ button >
183
186
</ mat-sidenav-container >
You can’t perform that action at this time.
0 commit comments