spine / spine

Lightweight MVC library for building JavaScript applications
http://spine.github.io
MIT License
3.66k stars 426 forks source link

route not matching in IE #554

Open reco opened 10 years ago

reco commented 10 years ago

the following route matches in all browsers but IE

class App extends Spine.Controller
  constructor: ->
    super

    @routes
      '/': ->
        console.log 'match /'

    Spine.Route.setup
      history: true
      shim: false

app = new App el: $("body")

demo: https://dl.dropboxusercontent.com/u/125755/route.html adding a @navigate "/" also works in IE demo: https://dl.dropboxusercontent.com/u/125755/routewithnavigate.html

i would expect the route to also mach without the navigate in IE

adambiggs commented 10 years ago

Which version(s) of IE do you see this in?

reco commented 10 years ago

6,7,8,9

adambiggs commented 10 years ago

Well now, that's not good... Thanks for reporting this!

reco commented 10 years ago

this is my temporary fix. after

Spine.Route.setup()

i call

@navigate window.location.pathname
reco commented 10 years ago

the fallback to history false works if the you match an empty route

'': -> @log 'asdf'

but then '/' does not mach anymore also this is only an issue with IEs not supporting the html5 history

johnpangalos commented 10 years ago

This was my fix, I appended the routes file in line 134. In ie9 the path is window.location.pathname instead of window.location.hash (as noted by rico)

Also I am using the js version not the coffee script version

if (path == ''){
  path = window.location.pathname;
  if (path.substr(0, 1) !== '/') {
    path = '/' + path;
  }
}