Define analytics
in the global context to guard against id="analytics"
.
#65
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This defines
analytics
in the global context to guard against HTML elements on the page potentially named "analytics". This is necessary because we now have some docs pages with elements usingid="analytics"
. Unfortunately, due to a historical artifact in web-browser history it was once made possible to access HTML elements, from JavaScript, by their ID on thewindow
object:Unfortunately, Segment.io uses a JavaScript variable named
analytics
, and it's not possible topush
stats into an HTML DIV which happens to also be namedanalytics
and have those stats work. 😸Of course, it's best to use the facilities that were actually designed for that, like
document.getElementById
, but historical reasons have caused thiswindow
access technique to still be the behavior for modern browsers.Ref: https://github.com/apollographql/engine-docs/pull/135
Ref: https://github.com/apollographql/engine-docs/commit/acd4a8e5
Ref: https://github.com/apollographql/engine-docs/blame/ec045186/source/index.md#L21
https://w3c.github.io/html/browsers.html#named-access-on-the-window-object.