I have an HTML page like:
<html> <head> <title>Test Page</title> <script type="text/javascript" src="http://svn.ckeditor.com/CKEditor/releases/latest/ckeditor_basic_source.js"></script> <script type="text/javascript"> //@x=y </script> </head> <body> Test Page </body> </html>
The comment //@x=y gets executed as code in IE 10 and the browser complains that 'y' is undefined:
The browser stops complaining if:
- I remove CKEditor script
- Remove the @ character
- Change the order of <script/> tags
What could be going wrong here?
UPDATE: I narrowed down the root cause to a conditional compilation statement in CKEditor'score/env.js file.
if ( !CKEDITOR.env ) { /** * @namespace Environment and browser information. */ CKEDITOR.env = (function() { var agent = navigator.userAgent.toLowerCase(); var opera = window.opera; var env = /** @lends CKEDITOR.env */ { /** * Indicates that CKEditor is running on Internet Explorer. * @type Boolean * @example * if ( CKEDITOR.env.ie ) * alert( "I'm on IE!" ); */ ie : /*@cc_on!@*/false, ...
If I remove that /*@cc_on!@*/ comment, everything works fine as one would expect.
Conditional compilation
I figured that this is caused by the conditional compilation statement included in CKEditor. If/*@cc_on@*/ is set, IE10 recognizes the part following the //@ as JavaScript code it should execute. The jQuery team encountered a variant of this bug here. Wrapping the //@ part in a block comment like /*//@x=y*/ gets around the problem.
Good find. The team will have
Good find. The team will have a look at it and decide whether to change this in our code or simply tell users to wrap such directives in comments. We need to do some research here, but thanks.
Customer and Community Manager, CKSource
Follow us on: Facebook, Twitter, LinkedIn
If you think you found a bug in CKEditor, read this!
I reported this bug here:
I reported this bug here: http://dev.ckeditor.com/ticket/10679
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+