rangy icon indicating copy to clipboard operation
rangy copied to clipboard

When concating rangy with other files - rangy is undefined

Open bettysteger opened this issue 9 years ago • 4 comments

I use grunt for concating (and uglifying) JS files.

Rangy is not available (=undefined) on the global window object when doing this. First I thought there was a problem when uglifying the code - but that is not the case - I commented out the uglify task and just concat the files (with useminPrepare..).

My solution for now is loading rangy over the CDN..

https://cdnjs.cloudflare.com/ajax/libs/rangy/1.3.0/rangy-core.min.js

Maybe someone can tell me what's my problem? :/

bettysteger avatar Apr 04 '16 09:04 bettysteger

Babel adds strict mode to the compiled output. 'this' doesn't refer to the window in global scope in strict mode. You need to change the last word in each file, 'this' to 'window'.

james-tindal avatar Apr 12 '16 08:04 james-tindal

I don't want to manually change the file, because I installed it with bower - or do you think this is the best solution?

bettysteger avatar Apr 12 '16 08:04 bettysteger

I think the only other solution is to submit a pull request to fix the issue. http://stackoverflow.com/questions/32012589/umd-javascript-module-which-also-works-in-strict-mode. Or not have 'strict mode' anywhere in your global scope before rangy.

james-tindal avatar Apr 12 '16 08:04 james-tindal

Babel without strict mode? https://www.npmjs.com/package/babel-preset-es2015-loose

james-tindal avatar May 02 '16 12:05 james-tindal