Skip to content

Fix for matches resolving document.body at require time. #33

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

Merged
merged 1 commit into from
Dec 13, 2017

Conversation

vdh
Copy link
Contributor

@vdh vdh commented Oct 20, 2017

A fix for issue #29

Delayed the resolution of document.body inside matches to the first call, instead of at require time. Before DOMContentLoaded has fired, matches will return null.

Delayed the resolution of `document.body` inside `matches` to the first call, instead of at require time. Before `DOMContentLoaded` has fired, `matches` will return `null`.
@robinknox
Copy link

Hi @jquense any chance you could review this? I get the same error about matches being null on my Cordova Meteor build which uses react bootstrap.

@jquense
Copy link
Member

jquense commented Dec 4, 2017

i've noted my thoughts on this category of changes in other places. Something that changes a single method to use a lazily evaluated document.body doesn't fix the problem, it just moves it for one method. Any fix to this will need to be holistic to the all of the dom-helpers package

@jquense jquense closed this Dec 4, 2017
@vdh
Copy link
Contributor Author

vdh commented Dec 5, 2017

@jquense I did have a look over all the other utils in dom-helpers, and as far as I could tell, matches is the only one that attempts to reference document.body immediately at require-time, and AFAIK that's the only thing that isn't available until after DOMContentLoaded.

I avoided making any further changes to any of the other utils, both because I couldn't diagnose any other potential problems to justify more changes, and also because I didn't want to get on your bad side by making any unnecessary refactoring beyond the essential changes to fix #29

I've been using Webpack's NormalModuleReplacementPlugin to successfully patch matches with this fix, and nothing else in dom-helpers appears to break due to loading in the head.

If there's any details about other problems I'm missing here, please let me know, because I really want to help out fix this issue.

@jquense
Copy link
Member

jquense commented Dec 5, 2017

Huh, maybe there isn't anything else left... I'll take look and circle back

@robinknox
Copy link

Hi @jquense just wondering if you've had time to take a look for any other changes needing done before this can go in?

@jquense jquense reopened this Dec 13, 2017
@jquense jquense merged commit 364b441 into react-bootstrap:master Dec 13, 2017
@jquense
Copy link
Member

jquense commented Dec 13, 2017

ya'll are right this is the only instance, sorry for the noise there. thanks!

@vdh vdh deleted the body-matches-null-fix branch February 9, 2018 05:27
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