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

HTMX 2.0.3 fails with a syntax error on htmx.js line 1467 #891

Open
mzeijen opened this issue Oct 29, 2024 · 1 comment
Open

HTMX 2.0.3 fails with a syntax error on htmx.js line 1467 #891

mzeijen opened this issue Oct 29, 2024 · 1 comment

Comments

@mzeijen
Copy link

mzeijen commented Oct 29, 2024

I tried upgrading to HTMX 2.0.3, using HTMLUnit 4.5.0 and I hit the following error:

Exception class=[org.htmlunit.corejs.javascript.EvaluatorException]
org.htmlunit.ScriptException: syntax error (http://localhost:59068/internal/assets/webjars/htmx.org/2.0.3/dist/htmx.js#1467)
	at org.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:903)
	at org.htmlunit.corejs.javascript.Context.call(Context.java:590)
	at org.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:487)
	at org.htmlunit.javascript.HtmlUnitContextFactory.callSecured(HtmlUnitContextFactory.java:316)
	at org.htmlunit.javascript.JavaScriptEngine.compile(JavaScriptEngine.java:734)
	at org.htmlunit.javascript.JavaScriptEngine.compile(JavaScriptEngine.java:109)
	at org.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1124)
        ...

It seems to have an issue with the following line:

for (const preservedElt of [...pantry.children]) {

I can confirm that HTMX 2.0.2 does not have this issue and HTMLUnit 4.5.0 works fine with it.

@rbri
Copy link
Member

rbri commented Nov 11, 2024

Yes that is a new problem because 2.0.3 uses the spread syntax at one place

line 1464

function restorePreservedElements() {
    const pantry = find('#--htmx-preserve-pantry--')
    if (pantry) {
        for (const preservedElt of [...pantry.children]) {
            const existingElement = find('#' + preservedElt.id)
            // @ts-ignore - use proposed moveBefore feature
            existingElement.parentNode.moveBefore(preservedElt, existingElement)
            existingElement.remove()
        }
        pantry.remove()
    }
}

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

2 participants