rodneyrehm / viewport-units-buggyfill

Making viewport units (vh|vw|vmin|vmax) work properly in Mobile Safari.
MIT License
1.59k stars 151 forks source link

IE raises "Access denied" error in some cases #38

Closed gaearon closed 8 years ago

gaearon commented 9 years ago

I'm getting occasional localized errors in my JS logs translating as "Access denied" from IE 11 with stacks like this:

Error: Toegang geweigerd. // Error: Access denied

  at findProperties (app/~/viewport-units-buggyfill/viewport-units-buggyfill.js?:189)
  at func (app/~/viewport-units-buggyfill/viewport-units-buggyfill.js?:164)
  at func (app/~/viewport-units-buggyfill/viewport-units-buggyfill.js?:90)

I don't think the line numbers are very accurate, but from my understand this is caused by accessing document.styleSheets when some stylesheet is loaded from another host.

Shall we try-catch it?

rodneyrehm commented 9 years ago

we already have something in place to deal with foreign resources: importCrossOriginLinks. We should try making that work before simply silencing something. Maybe the try-catch then becomes unnecessary?

gaearon commented 9 years ago

The problem is document.styleSheets itself throws in some cases (maybe has to do with IE permissions). How do we work around that?

rodneyrehm commented 9 years ago

it probably throws when accessing something you shouldn't. the only way I see this would work is by dopping the forEach and going with a for () { try{ … } catch(e){} } loop. do you want to try it out and send a PR?

gaearon commented 9 years ago

Submitted as #39.

I have not tested this yet (written in browser). I also don't like complete error swallowing, shall we at least do console.warn?

jabes commented 9 years ago

I have made this PR (https://github.com/rodneyrehm/viewport-units-buggyfill/pull/64) which fixed this issue for me. I received this error in IE9 after calling sheet.cssRules on a remote stylesheet from inside an iframe. Since the CSSRuleList should always be an array-like object, it is better to use typeof.

rodneyrehm commented 8 years ago

fixed by merging #64