Skip to content
This repository was archived by the owner on Jun 22, 2025. It is now read-only.
This repository was archived by the owner on Jun 22, 2025. It is now read-only.

Commented lines of code changing eel behavior (actually) #706

Open

Description

@panthuncia

Eel version
0.16.0
Describe the bug
Commented lines of code changes how Eel executes under very specific circumstances involving functions generated at runtime. These functions seem to require two eel.expose calls to be exposed properly, but only the first needs to execute. The second can be commented.

I'm not sure if the code I'm writing should work or not, but it definitely shouldn't do this.

To Reproduce
Steps to reproduce the behavior:

create a div like this:

<div class="div_class" id="SomeDiv">
    <p>SomeDiv</p>
</div>

and as many more of that class as you would like

Define functions in a loop like this:

for (const div of document.getElementsByClassName("div_class")){
    funcName = div.id+"Func"
    window[funcName] = () => {
        console.log("In function")
    }
    eel.expose(window[funcName], funcName)
}
//eel.expose(SomeDivFunc)

and call the function from Python.
This should work (it does for me).

Now, remove the commented line.

for (const div of document.getElementsByClassName("div_class")){
    funcName = div.id+"Func"
    window[funcName] = () => {
        console.log("In function")
    }
    eel.expose(window[funcName], funcName)
}

Now, eel fails to load the function, and we get "module 'eel' has no attribute '<name>'".

Now, if we uncomment that line, and comment or remove the first eel.expose:

for (const div of document.getElementsByClassName("div_class")){
    funcName = div.id+"Func"
    window[funcName] = () => {
        console.log("In function")
    }
    //eel.expose(window[funcName], funcName)
}
eel.expose(SomeDivFunc)

The app will execute, and the python call will not generate an error, but the function will not be executed.

Expected behavior
The commented line should have no impact on code execution, as it is commented.

Additionally, it is strange that this functionality requires both of these eel.expose calls for the function to be exposed successfully. Neither expose alone works, but the second one can be commented and it will still work.

Is this even supposed to work? It is a somewhat strange use-case.

System Information

  • OS: Windows 11 x64
  • Browser: Chrome
  • Python Distribution: Python 3.11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions