Closed ampprojectbot closed 3 years ago
When is it possible for
ampdoc.getRootNode().documentElement
to be undefined?
/cc @ampproject/wg-viewers since the stacktrace doesn't seem to provide many clues. Seems to be occurring only on Android browsers.
getRootNode()
is defined as a !Document|!ShadowRoot
. There's no documentElement
in ShadowRoot
interface. I'm a bit surprised we are not getting a compiler warning here. But in either case - this needs to be fixed.
Can shadow root docs be opted in to navigation interception? How do shadow docs specify capabilities/opt-ins?
Navigation
is definitely used. The viewer-interception is not possible, of course. So the fix here could simply be to check that documentElement
exists. Or simply ampdoc.getRootNode().documentElement?.hasAttribute(...)
would be enough. Though a cleaner approach would probably be explicitly checking for a ampdoc.isSingleDoc()
.
Details
Error report: link First seen: May 2, 2020 Frequency: ~ 2,240/day
Stacktrace
Notes
@ammaxwell
modifiedsrc/service/navigation.js:735-775
in #27649 (Apr 24, 2020)@ammaxwell
modifiedsrc/service/navigation.js:559-562
in #27649 (Apr 24, 2020)Seen in:
Possible assignees:
@ammaxwell
/cc @ampproject/release-on-duty