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

Fix: define check #668

Merged
merged 1 commit into from
Feb 16, 2018
Merged

Fix: define check #668

merged 1 commit into from
Feb 16, 2018

Conversation

tonyjin
Copy link
Contributor

@tonyjin tonyjin commented Feb 16, 2018

Global define check was causing errors, adding a window.define check and also fixing document viewer to correctly rely on minified pdf.js.

@boxcla
Copy link

boxcla commented Feb 16, 2018

Verified that @tonyjin has signed the CLA. Thanks for the pull request!

Copy link
Contributor

@jeremypress jeremypress left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't break a unit test?

Global define check was causing errors, adding a window.define check and also fixing document viewer to correctly rely on minified pdf.js.
@tonyjin
Copy link
Contributor Author

tonyjin commented Feb 16, 2018

@jeremypress it did, but in an odd way. I'm not exactly clear why, but this worked:

const amdPresent = !!window.define && typeof define === 'function' && !!define.amd;
const defineRef = amdPresent ? define : undefined;

if (disableAMD && amdPresent) {
    define = undefined;
}

and this didn't:

const amdPresent = !!window.define && typeof define === 'function' && !!define.amd;
let defineRef;

if (disableAMD && amdPresent) {
    defineRef = define;
    define = undefined;
}

Something to do with hoisting?

@tonyjin tonyjin merged commit 2edc0ff into box:master Feb 16, 2018
@tonyjin tonyjin deleted the fix-define branch February 16, 2018 02:13
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

Successfully merging this pull request may close these issues.

3 participants