Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Segfault when a "modern" event handler is declared inside a function #163

Open
kovaxis opened this issue Apr 22, 2020 · 1 comment
Open

Comments

@kovaxis
Copy link

kovaxis commented Apr 22, 2020

Modern event handlers seem pretty broken when declared inside a function.

As a minimal example, this code:

<html>
    <script type="text/tiscript">
        function foo() {
            event mousedown {
                stdout.println("M")
            }
            stdout.println("R")
        }
        foo()
    </script>
</html>

Results in a segfault in my machine.

For some reason, commenting out the "R" print statement prevents the segfault, but the "M" message isn't printed.

I'm using the Rust bindings to 64-bit Sciter 4.4.2.4, on a Windows 10 machine.

By the way, really cool library.

@c-smile
Copy link
Owner

c-smile commented Apr 22, 2020

Confirmed here, thanks, looking.

But the code makes no sense anyway.
Event handlers should always have a "principal" - DOM element they are attached to.

So either one of these

// global handler, set on document (a.k.a. `self`)
event mousedown {
   stdout.println("M")
}
foo();

Or

        function foo() {
            // mousedown on <body> element
            $(body) << event mousedown { 
                stdout.println("M")
            }
            stdout.println("R")
        }
        foo()

Or

class Some : Element {
    event mousedown { 
        stdout.println("M"); 
    }
}

The last one assumes that you have in CSS something like this:

   div.some {
      prototype: Some url(some.tis); // subclassing 
   }

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

No branches or pull requests

2 participants