Problem with <base> on IE7
domakas opened this issue · 0 comments
When using respond.js on website with base path set, and relative urls to stylesheets, respond.js doesn't work on IE7.
Assume I am on website with
<base href="http://test.com/" />
<link rel="stylesheet" href="styles/main.css" />
I assume this is to strange logic in ripCSS function
href = sheet.href;
<...>
if( (!/^([a-zA-Z:]*\/\/)/.test( href ) && !base) || href.replace( RegExp.$1, "" ).split( "/" )[0] === w.location.host ){
This check assumes that stylesheed href will be relative with no base defined OR the href will be absolute with same origin as host. This works fine on IE8 and greater, however
document.getElementsByTagName('link')[0].href
on IE7 will always return href which is actually specified (>=IE8 returns href with origin http://test.com/styles/main.css, IE7 returns relative styles/main.css), so code in if statement never runs.
Removing && !base
actually fixes the issue, but I assume it was put there for a reason, so I'm not sure how this can be solved in correct way.