-
Notifications
You must be signed in to change notification settings - Fork 412
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
Support IE<10 #14
Comments
See: #3 |
Here's how I see the options: Library
IntegrationUnless we write our own code (which would probably be a bad idea), it's a lot of extra JS code in the router that a portion of users won't need. That's why I made a separate package and didn't directly rely on it. Here are some options on how to do it:
What do you think? |
That seems reasonable. I Need to look more closely at what htm5 history API package is doing. I'm mostly worried about supporting IE 8-9 but not every edge case. But I don't know if IE8-9 is the the primary case, or if there are many others. Sent from my iPhone On Jul 27, 2013, at 11:34 PM, Tom Coleman notifications@github.com wrote:
|
Any news on this or should I keep using the meteor-router for now? Cheers! |
It may be a little while. Still thinking it through. Have some additional thoughts that ill post here when I get a moment. Sent from my iPad On Aug 22, 2013, at 2:19 AM, Kristoffer Klintberg notifications@github.com wrote:
|
I ported my app to the meteor-router, was surprisingly easy actually. |
@cmather I really want to switch edthena over to iron-router, but it's a hard sell if it won't work for IE < 10. If I could vote on a feature, I'd go all in on this one. |
Me too, as 98 % of my projects needs to support IE.
Sent from phone On Tue, Aug 27, 2013 at 11:30 PM, David Weldon notifications@github.com
|
Just launched an app to production today using Iron Router, and discovering that IE8+9 aren't supported :( Is there a workaround (ugly is OK) to this issue? I tried adding the following meteorite packages but didn't help, which I think are fixes for meteor-router...
|
Just re-read this issue, and realized this issue seems to be centered around hashbang URLs. However, I'm getting this error with the root URL in IE8+9 @ newly deployed site http://www.shinglecentral.com/
Something I'm doing wrong, or is it related to this issue? |
Hey @ryw, I'm sorry that happened to you. This should be at the top of the readme file. I'll be doing an update either tonight or tomorrow. The issue with IE<10 is that it doesn't support pushState or replaceState. There is no way to change the url without making a server request. So the typical workaround is to use a hashbang at the end of the url which doesn't cause a server request. It stays client side. If you want to support both: browsers that support pushState, and browsers that don't, you need a library or wrapper. That wrapper says, "If the browser doesn't have a pushState method, fake one, and use hashbangs for the url paths". But this presents its own set of problems that I'm thinking through. As a possible short term fix, you could fork the project, and add History.js (https://github.com/browserstate/history.js/). The work involved is to use History.js in this file: https://github.com/EventedMind/iron-router/blob/master/lib/client/location.js. So instead of just calling But I need to see what happens if someone goes directly to a url like: /posts/5. Another idea is to not try to wrap pushState, but instead, just do a server request if pushState isn't supported. So there's a little bit of thinking required here before we just throw in a History.js like solution to the main project. |
Oh, and you'll also probably need to change the click handler support to work properly on old broken browsers. Here's the equivalent change to the old page.js library that we used to use that made it work with HTML5-History-API (a slightly different polyfill to History.js) visionmedia/page.js#48 |
@ryw I've hacked together a solution that works quite well in IE8+, haven't tested elsewhere. Uses only HTML5-History-API. Check my fork https://github.com/sterlingwes/iron-router |
I spent some time on this today. It looks like there are a couple of options, each with pros and cons. I'll lay out the issues and solutions as I understand them. Issues
Solutions and Questions
cc @gschmidt |
@sterlingwes, I just saw your post and checked out your code. I need to take a closer look at HTML5-History-API but it looks like your changes to iron-router are on the right path for the third solution above. What about the |
@cmather I don't currently use the helpers in my project so I likely neglected that, will revisit. I have to take some time for a more thorough look (tests etc.), but if you decide to go this route I'd be happy to contribute. Thanks for all your work on this. |
That might just be a good plan @sterlingwes. I would like to gain a better understanding of the differences between HTML5-History-API and History.js. Also giving thought to whether this is something that should just be part of the iron-router package at some point; or if it's such an edge case that it should be an opt-in with a separate package. |
Oops, actually I got a little confused here myself. Too much to keep in one mental model :-). The onClick handler of client_router does intercept the click so it should be fine to do the hash stuff here (or in |
Hey, just to weigh in here a little:
El 31/08/2013, a las 11:22 AM, Chris Mather notifications@github.com escribió:
|
@sterlingwes I tried popping your fork into my project, but still looks like IE not loading in production :( http://www.shinglecentral.com — I downloaded your code, put it in a packages/iron-router directory, and removed the meterorite version of iron-router... Any way for you to tell if your fork seems to be deployed @ my URL? |
It's there, but you have other IE compatibility issues with your code. For one, you're using the reserved name |
Looks like it's autoform Meteor-Community-Packages/meteor-autoform#24 |
@sterlingwes thanks Wes — we fixed autoform, sorry for hijacking this issue — back to solving issues in iron-router :) |
@sterlingwes I found a little issue with your solution. For example you have a named route 'creditsBuy' with the path '/credits' the following would happen in this snippet (client_router.js):
It seems that in IE9 (i guess in 8 too) el.pathname is 'credits' and not '/credits'. This leads to the error 'No route found named credits', because in the "go()" function the router thinks its a name but it should be a path. I fixed it by adding a '/' if there is none:
The pathFor Helpers now also seem to work for me. https://github.com/DerMambo/meteor-iron-router/blob/master/lib/client/client_router.js |
@DerMambo thanks for the heads-up. That also helps me revert some changes I made to |
And i found another thing, that might be to consider. I have a twitter bootstrap modal. It is used by putting the id of the modal into the a-tags href. This a-tag opens a modal for example: a href="#modalId" data-toggle="modal">Open Modal Clicking this makes the IronRouter want to show the modalId template and this of course does not exist. I made a quite hacky workaround by adding a new tag to a elements. a href="#modalId" data-toggle="modal" data-iron-router-ignore="true">Open Modal And i check for this in the onClick Event. This really is not very nice, but okay for me for a while ;) I am not sure but maybe you would have to call e.preventDefault() or stopPropagation in the bootstrap script?! |
On the dev branch, the Router will no longer break with IE8-9. Please clone the repo and try it out. However, the way it is implemented is that if history.pushState is not supported, the browser makes a server request. So it will work, but there's a performance penalty. This might be mitigated somewhat with server side rendering and prioritized subscription management from Meteor. I'll come back later and outline some of the design thinking. Going to close this issue but would like to continue discussion. |
I could make it work in combination with Html5-History-API package by patching the normalizePath method of the route: Route.prototype.normalizePath = function(path) {
var origin = Meteor.absoluteUrl();
path = path.replace(origin, '');
var queryStringIndex = path.indexOf('?');
path = ~queryStringIndex ? path.slice(0, queryStringIndex) : path;
//var hashIndex = path.indexOf('#');
//path = ~hashIndex ? path.slice(0, hashIndex) : path;
if (path.charAt(0) !== '/')
path = '/' + path;
return path;
} The problem were the two lines I commented out. These modify the path if there is a hash present. It effectively destroys any support for older browsers where Html5-History-API uses hashes instead of slashes. It's a pretty simple fix, and maybe someone could explain why these two lines are in any way important, they don't seem really helpful to me anyway? By the way, I want to say its really awesome that one can override any iron-router API methods, this makes it so much easier to work with than e.g. angular.js where the core is completely fenced off. |
Allright. I've run into the same challenge as everyone here: getting stuff to run on IE8. With the most recent version of Iron Router, combined with HTML5-History-API, everything seems to work fine, except... <a href="{{pathFor 'home'}}>Home</a>
on Internet Explorer 8 (haven't tried it on 9) this will trigger a full page refresh. However, if you intercept this event and use the Router directly, the page refresh can be avoided! The code would look something like this (sorry for the Coffeescript syntax here): Template.navigation.events
"click a": (event,template)->
event.preventDefault()
Router.go event.currentTarget.href
return That works rather nicely. I have not tested what happens if you start including variables, but I suspect this can easily work as well. What I find odd is that I kind of thought Iron Router was intercepting |
I see this thread is old, but I ran into this last night. I don't care about IE8, but support for IE9 is still important to our company. Though IE<10 is only responsible for ~3% of total site traffic/mo that is ~$50,000 in revenue. I have seen many responses with partial fixes, and even some claiming this was fixed in v0.6. But I'm on iron:router@1.0.7 and most pages of my app are blank and all urls have hash bangs in them. @cmather is there some direction you can point me in? |
So I thought I'd try a simple old polyfill https://cdn.polyfill.io/v1/docs/ |
This includes support for browsers that don't support pushState (i.e. IE<10).
It includes researching whether we should roll our own solution or use a library like history.js. The integration point would be with our Location class location in lib/client/location.js
Ideally, the user shouldn't need to think about this at all, other than possibly providing configuration options to the router. Asking the user to include additional packages to make this work shouldn't be required in my opinion. However, if/when Meteor implements conditional file loading for packages (e.g. based on user-agent) we could dynamically send down the right javascript.
The text was updated successfully, but these errors were encountered: