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

Add is-node & fix is-browser-window not to check for SimpleDOM #35

Merged
merged 2 commits into from
Dec 1, 2017

Conversation

chasenlehara
Copy link
Member

This adds is-node from can-util and changes is-browser-window to use is-node instead of checking for SimpleDOM’s presence.

This change was made because in 4.0, this check was returning false when run in the main production build of CanJS (where can-simple-dom is also packaged).

This adds [is-node from can-util](https://github.com/canjs/can-util/tree/7e8669a666072dcbdcc34402b640a67d38ea5784/js/is-node) and changes is-browser-window to use `is-node` instead of checking for SimpleDOM’s presence.

This change was made because in 4.0, [this check](https://github.com/canjs/can-util/blob/7e8669a666072dcbdcc34402b640a67d38ea5784/dom/events/events.js#L81) was returning false when run in the main production build of CanJS (where can-simple-dom is also packaged).
Copy link
Contributor

@matthewp matthewp left a comment

Choose a reason for hiding this comment

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

LGTM

return typeof window !== "undefined" &&
typeof document !== "undefined" && typeof SimpleDOM === "undefined";
typeof document !== "undefined" &&
isNode === false;
Copy link
Contributor

Choose a reason for hiding this comment

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

the isNode I'm not 100% sure on long-term. I think NWJS should be considered a browser window. I'm not sure how we can sniff this out, but isNode ==== false is fine for now. We'll need something later.

Copy link
Contributor

Choose a reason for hiding this comment

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

done-autorender has a change for when running in nwjs. I agree though, using clientWidth or something would be a better solution long-term.

Copy link
Member Author

Choose a reason for hiding this comment

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

Opened an issue to fix this long-term: #36

@chasenlehara
Copy link
Member Author

I realized that isNode could sometimes be undefined, so I made this change to make sure that’s not the case: 561c1e9

@chasenlehara chasenlehara merged commit 644106d into master Dec 1, 2017
@chasenlehara chasenlehara deleted the fix-is-browser-window branch December 1, 2017 18:19
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.

None yet

3 participants