Skip to content

FocusTrap: 'Node is not defined' in server side rendering #8981

Closed
@leo6104

Description

@leo6104

Bug, feature request, or proposal:

Bug

What is the expected behavior?

the error not occur.

What is the current behavior?

0|mapia-mo |     ERROR ReferenceError: Node is not defined
0|mapia-mo |     at FocusTrap._getFirstTabbableElement (/var/app/current/server.js:28081:75)
0|mapia-mo |     at FocusTrap._getRegionBoundary (/var/app/current/server.js:27994:55)
0|mapia-mo |     at FocusTrap.focusFirstTabbableElement (/var/app/current/server.js:28038:55)
0|mapia-mo |     at FocusTrap.focusInitialElement (/var/app/current/server.js:28023:21)
0|mapia-mo |     at SafeSubscriber._next (/var/app/current/server.js:27917:71)
0|mapia-mo |     at SafeSubscriber.__tryOrUnsub (/var/app/current/server.js:27392:16)
0|mapia-mo |     at SafeSubscriber.next (/var/app/current/server.js:27339:22)
0|mapia-mo |     at Subscriber._next (/var/app/current/server.js:27279:26)
0|mapia-mo |     at Subscriber.next (/var/app/current/server.js:27243:18)
0|mapia-mo |     at TakeSubscriber._next (/var/app/current/server.js:41499:30)
0|mapia-mo |     at TakeSubscriber.Subscriber.next (/var/app/current/server.js:27243:18)
0|mapia-mo |     at SafeSubscriber.schedulerFn [as _next] (/var/app/current/server.js:4610:52)
0|mapia-mo |     at SafeSubscriber.__tryOrUnsub (/var/app/current/server.js:27392:16)
0|mapia-mo |     at SafeSubscriber.next (/var/app/current/server.js:27339:22)
0|mapia-mo |     at Subscriber._next (/var/app/current/server.js:27279:26)
0|mapia-mo |     at Subscriber.next (/var/app/current/server.js:27243:18)
0|mapia-mo |     at EventEmitter.Subject.next (/var/app/current/server.js:24318:25)
0|mapia-mo |     at EventEmitter.emit (/var/app/current/server.js:4590:46)
0|mapia-mo |     at /var/app/current/server.js:4995:79
0|mapia-mo |     at ZoneDelegate.invoke (/var/app/current/server.js:154462:26)
0|mapia-mo |     at Zone.run (/var/app/current/server.js:154212:43)
0|mapia-mo |     at NgZone.runOutsideAngular (/var/app/current/server.js:4972:69)
0|mapia-mo |     at checkStable (/var/app/current/server.js:4995:26)
0|mapia-mo |     at Object.onHasTask (/var/app/current/server.js:5037:21)
0|mapia-mo |     at ZoneDelegate.hasTask (/var/app/current/server.js:154515:37)
0|mapia-mo |     at ZoneDelegate._updateTaskCount (/var/app/current/server.js:154535:22)
0|mapia-mo |     at Zone._updateTaskCount (/var/app/current/server.js:154359:34)
0|mapia-mo |     at Zone.runTask (/var/app/current/server.js:154279:30)
0|mapia-mo |     at ZoneTask.invokeTask (/var/app/current/server.js:154569:34)
0|mapia-mo |     at ZoneTask.invoke (/var/app/current/server.js:154558:48)
0|mapia-mo |     at data.args.(anonymous function) (/var/app/current/server.js:155251:25)
0|mapia-mo |     at _combinedTickCallback (internal/process/next_tick.js:138:11)
0|mapia-mo |     at process._tickDomainCallback (internal/process/next_tick.js:218:9)

What are the steps to reproduce?

What is the use-case or motivation for changing an existing behavior?

in ssr, sidenav open and focustrap trigger.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

angular 5.1.1
material2 5.0.1

Is there anything else we should know?

https://github.com/angular/material2/blob/623be22e58d0074a109ac03bdf00afa7c60291ac/src/cdk/a11y/focus-trap.ts#L226
https://github.com/angular/material2/blob/623be22e58d0074a109ac03bdf00afa7c60291ac/src/cdk/a11y/focus-trap.ts#L248
this line might be cause

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions