eugenii / jqueryrotate

Automatically exported from code.google.com/p/jqueryrotate
1 stars 0 forks source link

eval to detect IE prevents using jqueryrotate in Chrome packaged aops #81

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create packaged app for Chrome that uses jqueryrotate
2. Load extension
What is the expected output? 

No error, rotation works.

What do you see instead?

Rotation doesn't work and there are errors in js console: 

Uncaught Error: Code generation from strings disallowed for this context

and 

Uncaught TypeError: Object [object Object] has no method 'rotate

What version of the product are you using? On what operating system?

jQueryRotate 2.2 in Chromium 18 and Google Chrome 21 on Linux

Original issue reported on code.google.com by itk...@gmail.com on 16 Sep 2012 at 11:31

GoogleCodeExporter commented 9 years ago
Removing eval in line
http://code.google.com/p/jqueryrotate/source/browse/trunk/jQueryRotate.js?spec=s
vn127&r=120#16

fixes the issue.

Original comment by itk...@gmail.com on 16 Sep 2012 at 11:32

GoogleCodeExporter commented 9 years ago
In compressed version it's cut off, please read comment above.:)

Original comment by wil...@gmail.com on 17 Sep 2012 at 6:24

GoogleCodeExporter commented 9 years ago
No, it is not. At least not with the Closure compiler I have:

% java -jar tools/compiler.jar --version
Closure Compiler (http://code.google.com/closure/compiler)
Version: 1592
Built on: 2011/11/17 10:24
^C%                                                                             
                          % grep eval jQueryRotate.2.2.with.eval.js
// Bad eval to preven google closure to remove it from code o_O
var IE = eval('"v"=="\v"');
% java -jar tools/compiler.jar --js jQueryRotate.2.2.with.eval.js > 
jQueryRotate.2.2.with.eval.min.js
% grep eval jQueryRotate.2.2.with.eval.min.js
(function(j){for(var 
d,k=document.getElementsByTagName("head")[0].style,h="transformProperty 
WebkitTransform OTransform msTransform MozTransform".split(" 
"),g=0;g<h.length;g++)void 0!==k[h[g]]&&(d=h[g]);var 
i=eval('"v"=="\u000b"');jQuery.fn.extend({rotate:function(a){if(!(0===this.lengt
h||"undefined"==typeof a)){"number"==typeof a&&(a={angle:a});for(var 
b=[],c=0,f=this.length;c<f;c++){var 
e=this.get(c);if(!e.Wilq32||!e.Wilq32.PhotoEffect){var 
d=j.extend(!0,{},a),e=(new Wilq32.PhotoEffect(e,d))._rootObj;

Original comment by itk...@gmail.com on 18 Sep 2012 at 12:02

GoogleCodeExporter commented 9 years ago
U re using google closure, but there is a comment about google closure:

// Bad eval to preven google closure to remove it from code o_O
// After compresion replace it back to var IE = 'v' == '\v'

I also use google closure when making compressed version, unfortunately eval is 
needed there to make sure that closure will leave it in (otherwise it will be 
removed by Closure optimization methods)

Original comment by wil...@gmail.com on 18 Sep 2012 at 6:21

GoogleCodeExporter commented 9 years ago
Aren't there better ways to test for IE? Some restricted environments like 
Google Chrome's packaged apps will not execute evals at all, so the library is 
broken there. Whether or not some js compressors will remove or replace eval 
with something else is irrelevant, it's bad no matter how you look at it and 
it's not like eval is really needed here. 

Original comment by itk...@gmail.com on 18 Sep 2012 at 1:33

GoogleCodeExporter commented 9 years ago
I'm open for better IE detection methods :) This one I use is best, only 
problem is that google compiler remove it completly from code (  this   var IE 
= 'v' == '\v' )

Original comment by wil...@gmail.com on 18 Sep 2012 at 1:37

GoogleCodeExporter commented 9 years ago
Will try with a !!window.ActiveXObject detection

Original comment by wil...@gmail.com on 30 Jun 2013 at 8:24