spine / spine

Lightweight MVC library for building JavaScript applications

Home Page:http://spine.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

route not matching in IE

reco opened this issue · comments

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

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

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

this is my temporary fix. after

Spine.Route.setup()

i call

@navigate window.location.pathname

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

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;
  }
}