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

Inside of getCrossReferenceHeader script, getting error Uncaught SyntaxError: Unexpected identifier '_$HY' #28

Closed
patdx opened this issue Oct 18, 2023 · 0 comments · Fixed by #26

Comments

@patdx
Copy link

patdx commented Oct 18, 2023

I am trying Solid-js 1.8.3 and renderToStringAsync, and I got a hydration script injected with an error like below:

                               | Uncaught SyntaxError: Unexpected identifier '_$HY'
                               V
(self.$R=self.$R||{})["s2-"]=[]_$HY.r["s2-0-0-0-0-0-0"]=($R=>($R[0]=_$.P()))($R["s2-"]);($R=>(_$.Ps($R[0],!0)))($R["s2-"]);

After I added the semicolon here, the hydration script could be parsed by the browser:

(self.$R = self.$R || {})["s2-"] = [];
_$HY.r["s2-0-0-0-0-0-0"] = (($R) => ($R[0] = _$.P()))($R["s2-"]);
(($R) => _$.Ps($R[0], !0))($R["s2-"]);

Maybe there is a missing semicolon here? I noticed that the id == null has a semicolon included but the id != null case does not have a semicolon at the end.

export function getCrossReferenceHeader(id?: string): string {
  if (id == null) {
    return `self.${GLOBAL_CONTEXT_REFERENCES}=self.${GLOBAL_CONTEXT_REFERENCES}||[];`;
  }
- return `(self.${GLOBAL_CONTEXT_REFERENCES}=self.${GLOBAL_CONTEXT_REFERENCES}||{})["${serializeString(id)}"]=[]`;
+ return `(self.${GLOBAL_CONTEXT_REFERENCES}=self.${GLOBAL_CONTEXT_REFERENCES}||{})["${serializeString(id)}"]=[];`;
}
@patdx patdx changed the title Small bug Inside of getCrossReferenceHeader script, getting error Uncaught SyntaxError: Unexpected identifier '_$HY' Oct 18, 2023
lxsmnsyc added a commit that referenced this issue Oct 19, 2023
@lxsmnsyc lxsmnsyc mentioned this issue Oct 19, 2023
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

Successfully merging a pull request may close this issue.

1 participant