-
Notifications
You must be signed in to change notification settings - Fork 20
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
document.createElement is converted to JSX #113
Comments
Rule const d = document;
d.createElement(...) I would like to introduce another rule to inline temp variables which were assigned to common global variables. For example: - const w = window;
- w.setTimeout(...);
+ window.setTimeout(...); I hope this can improve the readability and avoid misunderstanding the intention of the code. |
aah, i was looking for https://github.com/pionxzh/wakaru/blob/main/packages/unminify/README.md#un-jsx ... but i dont see a way to disable rules |
You can disable it on the playground. CLI has not supported configuring the rules yet. If you are running this repo in local environment, simply disable it in file |
This is a supported use case in JSX. But your proposal is an improvement that we can make. I'm not sure if it's a common case that bundler/minifier will generate. |
Fixed |
I have created another feature request for the tag name in #115 |
similar case wrong transformation from wakaru assumes that to get this right, wakaru would have to check the actual implementation of the h function input let h = (w, x, z) => w.split(x).join(z);
let b = (w) => {
w = w.toLowerCase();
w = h(w, " ", "");
w = h(w, "-", "");
let x = "400";
if ((w = h(w, "_", "")).includes("thin") || w.includes("hairline")) {
x = "100"; output let h = (w, x, z) => w.split(x).join(z);
let b = (W) => {
W = W.toLowerCase();
W = <W {..." "}>{""}</W>;
W = <W {..."-"}>{""}</W>;
let x = "400";
if ((W = <W {..."_"}>{""}</W>).includes("thin") || W.includes("hairline")) {
x = "100"; |
hmm ye, |
We also have the plan to do the module detection. Ideally, we should be able to detect which module is react/preact and convert the call to JSX precisely. |
preact's |
released |
- const w = window;
- w.setTimeout(...);
+ window.setTimeout(...); This has been added in 1a91aa4 |
Describe the bug
jsx is not javascript
with
input.js
i expect javascript inoutput.js
with
input.jsx
jsx output can be acceptable inoutput.jsx
Input code
Reproduction
No response
Steps to reproduce
No response
Expected behavior
keep
document.createElement
Actual behavior
also the JSX is wrong, JSX has no dynamic tag names (?)
so it should be
<div {...attrs} />
The text was updated successfully, but these errors were encountered: