kubetail-org / loadjs

A tiny async loader / dependency manager for modern browsers (899 bytes)
MIT License
2.57k stars 149 forks source link

loadjs reports *false* error loading css on Edge 18 #81

Closed moos closed 5 years ago

moos commented 5 years ago

Loading a css file in Edge 18 (rel. Nov. 13, 2018) is causing a security error:

screen shot 2018-12-06 at 10 39 15 am

This is occurring on the line if (!e.sheet.cssText.length) result = 'e'; and is masked by the try/catch. However, the resource is loaded correctly.

Bin: https://jsbin.com/zuvaset/edit?html,console PS: Edge 18 is available to try for free (1/2 hr. at a time!) on browserstack.

moos commented 5 years ago

Maybe related? https://github.com/Modernizr/Modernizr/issues/2296

amorey commented 5 years ago

Thanks for creating an example page! I think the issue is that the CSS file is a cross-domain file so when the code tries to access cssText it gets a SecurityError. This PR should fix the problem: https://github.com/muicss/loadjs/pull/82/files#diff-ef6e4b9de64d186abdf1a510bed822aaR141

I tested the code on IE Edge 18 and it seems to be working. Can you try out this version to see if you notice any problems? https://cdn.rawgit.com/muicss/loadjs/crossdomaincss-bugfix/examples/assets/loadjs/loadjs.js

moos commented 5 years ago

Yes - confirming the fix both with my application and the test page (update). Thanks for the quick fix.

amorey commented 5 years ago

Thanks! I merged the changes into the master and published a new version (v3.5.5). Here's a new version of the payload: https://cdn.rawgit.com/muicss/loadjs/3.5.5/dist/loadjs.min.js

Let me know if you notice any other issues with LoadJS!