Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splitting breaks when called from inside IIFE #41

Open
josephrexme opened this issue Jul 30, 2019 · 3 comments
Open

Splitting breaks when called from inside IIFE #41

josephrexme opened this issue Jul 30, 2019 · 3 comments

Comments

@josephrexme
Copy link

Because it assumes this will always be window here:

(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  typeof define === 'function' && define.amd ? define(factory) :
  (global.Splitting = factory());
}(this, (function () { 'use strict';
...

When called in a scope other than the global scope, it breaks. I can send in a PR with this change

(global || window).Splitting = factory();
@notoriousb1t
Copy link
Collaborator

A PR is welcome, but changing the dist/ files isn't a permanent solution as those are generated files. It would break the next time the code was re-compiled.

What situation is Splitting being included in where it isn't in the global scope?

@shshaw
Copy link
Owner

shshaw commented Jul 31, 2019 via email

@josephrexme
Copy link
Author

josephrexme commented Jul 31, 2019

document is available but this is not window as assumed when you run it this way:

(function() {
  Splitting();
})();

so the line global.Splitting throws the error about trying to set a property Splitting of undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants