Skip to content
This repository has been archived by the owner on Jan 24, 2018. It is now read-only.

document.querySelector on ie7 #66

Closed
ruyadorno opened this issue Sep 18, 2012 · 4 comments
Closed

document.querySelector on ie7 #66

ruyadorno opened this issue Sep 18, 2012 · 4 comments

Comments

@ruyadorno
Copy link

Everything was broken on ie7 just because of this line of code using document.querySelector (src/skrollr.js - line: 287)

I used a simple workaround and my site is working now.

https://developer.mozilla.org/en-US/docs/DOM/Document.querySelector

@Prinzhorn
Copy link
Owner

How does your "simple workaround" look like?

If you want to use anchor-targets you need querySelector and if you don't use anchor-targets, then the line will never be executed.

What I was already thinking about was to create a poor-mans polyfill for querySelector which maps querySelector('#foo') to getElementById('foo'), because I guess that's used the most. I would only take a few lines of code inside the IE plugin. And if a complex selector reaches the polyfill, it could throw an exception.

@ruyadorno
Copy link
Author

I just replaced the querySelector with a jquery selector, like that:

if(document.querySelector){
    anchorTarget = document.querySelector(attr.value);
} else {
    anchorTarget = $(attr.value)[0];
}

I was using anchor-target somewhere in the project and everything worked fine on ie7 after that, so I supposed it worked

@Prinzhorn
Copy link
Owner

Well, if there's jQuery on your page, then you can use it of course. But that's not a general-purpose solution.

@Prinzhorn
Copy link
Owner

With IE 7 you can now at least use IDs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants