olivernn / davis.js

RESTful degradable JavaScript routing using pushState
http://davisjs.com
532 stars 58 forks source link

Fix form handling in IE 10. #74

Open dumbmatter opened 11 years ago

dumbmatter commented 11 years ago

In IE10, it seems that normal links are routed fine, but forms are not. Minimal example: http://jsfiddle.net/xg4Hr/2/ - In Firefox and Chrome, clicking the GET and POST buttons display "GET" and "POST" as you'd expect. In IE10, the Davis.js routing is ignored and you get a 404 error. I narrowed the problem down to the originChecks function in davis.listener.js, on this line:

a.href = elem.action

In Firefox and Chrome, this will make a.host equal to the domain name. In IE10, the port number gets stuck on the end of a.host, for some reason. This makes this.A(a) on the next line return false since Davis.js thinks it is an external link. I worked around this by creating a2 to compare with a.