Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript evaluation: x is not a function, a.split is not a function in klipse_plugin.min.js #334

Open
lechten opened this issue Jan 6, 2019 · 9 comments

Comments

@lechten
Copy link
Contributor

lechten commented Jan 6, 2019

When using klipse_plugin.min.js instead of klipse_plugin.js, the console shows the following two errors with Firefox (62.0 and 60.1.0esr on GNU/Linux):

  • TypeError: x is not a function[Learn More] klipse_plugin.min.js:1799:43
  • TypeError: a.split is not a function[Learn More] klipse_plugin.min.js:306:123

Minimal example:

<!DOCTYPE html>
<html>
    <head>
	<meta charset="utf-8"/>
	<link rel= "stylesheet" type= "text/css" href="https://storage.googleapis.com/app.klipse.tech/css/codemirror.css">
	<script>
	 window.klipse_settings = { selector_eval_js: ".klipse" };
	</script>
    </head>
    <body>
	<pre><code class="klipse" >
var x = "Hello World!";
x
	</code></pre>
	<!-- <script src="https://storage.googleapis.com/app.klipse.tech/plugin/js/klipse_plugin.js"></script> -->
	<script src="https://storage.googleapis.com/app.klipse.tech/plugin_prod/js/klipse_plugin.min.js"></script>
    </body>
</html>

The output "Hello World!" appears, but further edits do not have effects.

@polytypic
Copy link
Contributor

polytypic commented Jan 7, 2019

The root cause of this is described in #330.

Specifically, the minified klipse_plugin.min.js exposes its global variables (including functions) to the window object. In the snippet var x refers to the global window.x. So, window.x is overwritten to become the "Hello World!" string instead of the (apparently) function that Klipse expects it to be. To fix this, the minified Klipse bundle should be built so that it properly scopes its globals and does not expose them via the window object.

@codeR49
Copy link

codeR49 commented Dec 13, 2020

I want to contribute

@viebel
Copy link
Owner

viebel commented Dec 17, 2020

@codeR49 Please do!

@irynadunets
Copy link

<script> window.klipse_settings = { selector_eval_js: ".klipse" }; </script>

let x = "Hello World!";
x
	
<script src="https://storage.googleapis.com/app.klipse.tech/plugin_prod/js/klipse_plugin.min.js"></script>

Screenshot from 2021-01-31 20:37:52

@workshub
Copy link

workshub bot commented Jan 31, 2021

@irynadunets started working on this issue via WorksHub.

@workshub
Copy link

workshub bot commented Feb 5, 2021

@Jacsonrai started working on this issue via WorksHub.

@workshub
Copy link

workshub bot commented Feb 23, 2021

@murtaza63 started working on this issue via WorksHub.

@workshub
Copy link

workshub bot commented Nov 10, 2021

@nbittich started working on this issue via WorksHub.

@workshub
Copy link

workshub bot commented Jul 14, 2022

@curest0x1021 started working on this issue via WorksHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants