Splitting
Splitting copied to clipboard
Splitting breaks when called from inside IIFE
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();
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?
I am curious how you're running Splitting to get this error.
One thing to be aware of as well: Splitting is dependent on document
methods/properties for generating elements, so it will error out if you try
to call it without document
being available.
Check out issues #20 and #28 for some discussion on this https://github.com/shshaw/Splitting/issues/20 https://github.com/shshaw/Splitting/issues/28
On Tue, Jul 30, 2019 at 10:48 PM Christopher Wallis < [email protected]> wrote:
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?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/shshaw/Splitting/issues/41?email_source=notifications&email_token=AAF5XQZZ7FHG3IDR6HJEYT3QCEDR7A5CNFSM4IH2CFCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3F7LJI#issuecomment-516683173, or mute the thread https://github.com/notifications/unsubscribe-auth/AAF5XQ55QOBQF3ZGOYETSEDQCEDR7ANCNFSM4IH2CFCA .
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