Closed binarykitchen closed 10 years ago
I've also encountered issues with PhantomJS doing this kind of thing, and if I remember correctly it's because PhantomJS does not implement matchMedia? I did a quick google, lo and behold it turns out I'd tweeted about this before :) https://twitter.com/WickyNilliams/status/393457167329931264
I think I resorted to writing a fake version of matchMedia in the end, or something like that.
I'm going to close this as I'm sure it's not a bug, but feel free to continue the discussion
@WickyNilliams Thanks for coming back to me. How did you write that fake version of matchMedia?
I am curious how you approached writing a fake version of matchMedia also.
@cmndo
You could do something like:
// Makes sure you code won't throw an error (window.matchMedia || window.matchMedia = function(mediaQuery) { return { matches: false, media: mediaQuery, addListener: function() {}, removeListener: function() {} }; });
Or try out this project I worked on to support browsers without any form of matchMedia or matchMedium. This has not been tested in PhantomJS.
https://github.com/weblinc/media-match
Hope this helps.
Thanks for pointing to media-match but the code does not look like it's maintained, so not thanks. Still stuck :(
@binarykitchen
I worked on that media-match solution and haven't had the need to update it in sometime.
Seems like a pretty low investment for you to try out as long as your test is really simple. If it doesn't work then it's not a huge deal, you've crossed off one more solution. I might be able to help if we can narrow down where it fails.
Up to you, good luck.
Guys, I am not sure about it so don't take it too serious.
I have some e2e test scripts here for PhantomJS and it looks like the internal window resize events have no impact on enquire.js. No events are fired there.
Has anyone of you the same problem?