nuxodin/ie11CustomProperties

4.0.0 has script errors in IE11

teetotum opened this issue · 5 comments

@nuxodin First things first: thank you for this library. I'm amazed this library exists and it seems to be exactly what I need in my current project. I just installed the 4.0.0 version and imported into my index.js and fired it up in IE11 and had a script error. (my project is ES6 and is transpiled down to ES5)

Error: usage before declaration
line 214 in ie11CustomProperties.js
the used variable is styles_of_getter_properties
and I think this happens because it is declared in line 197 as a const and IE11 does not recognize the keyword const and therefore seems to ignore it.
You used const throughout the script file. To my knowledge this therefore would not work in IE11
(Maybe this got into the file by accident: might be some tool changed all var to const onSave? Prettier or eslint?)

Hi Teetotum
The script does need a transpiler.
Its recommened to load the polyfill like this:

<script>window.MSInputMethodContext && document.documentMode && document.write('<script src="yourJsPath/ie11CustomProperties.js"><\x2fscript>');</script>

If you do so, the scripts only loads by IE11

This is the same problem i reported. IE11 supports const just fine, the problem is the call order. The declarations of these variables need to be moved to the top of the script, otherwise they may be used before they are declared:

// beta
const styles_of_getter_properties = {};
	
// draw queue
let drawQueue = new Set();
let collecting = false;
let drawing = false;

Ah yes - my bad. You are both correct regarding that IE11 supports const. So this wasn't the cause. But the issue that the order of declaration and the order of execution are mismatched still remains.

The script does need a transpiler.

I assume this is a typo and you meant the script does not need a transpiler.

Thank you for your feedback.
The new version 4.0.1 should now work fine.

I think it should work now, so i close the issue.