Skip to content

Commit

Permalink
Fall back to <html> if #js-repo-pjax-container is missing
Browse files Browse the repository at this point in the history
This allows this module to be used with [Turbolinks] sites like GitLab.
For a demo:

* Visit https://gitlab.com/gitlab-org/gitlab-ce
* Paste the contents of this file into the console
* Paste the following into the console:

```javascript
gitHubInjection(window, function(err) {
  if (err) {
    return console.error(err);
  }
  console.warn("XXX INJECTION");
});
```

* Click the "Activity" link
* Notice "XXX INJECTION" printed to the console

[Turbolinks]: https://github.com/turbolinks/turbolinks

See OctoLinker/OctoLinker#113
  • Loading branch information
josephfrazier committed Sep 1, 2016
1 parent ed77e40 commit 9c8e2e0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -17,7 +17,7 @@ var gitHubInjection = function (global, cb) {
throw new Error('Callback is not a function');
}

var domElement = global.document.getElementById('js-repo-pjax-container');
var domElement = global.document.getElementById('js-repo-pjax-container') || global.document.documentElement;
if (!domElement || !global.MutationObserver) {
return cb(null);
}
Expand Down

0 comments on commit 9c8e2e0

Please sign in to comment.