c-smile / sciter-sdk

Sciter is an embeddable HTML/CSS/scripting engine
http://sciter.com
Other
2.11k stars 224 forks source link

Using Element.addClass() using aspect function has unpredictable behavior #124

Closed SonnyX closed 5 years ago

SonnyX commented 5 years ago
function bool_setting() {
  stdout.println("Attached!");
  this.attributes.addClass("true");
}

Usingaspect: "bool_setting"; in the css of a button makes the button (and surrounding elements) dissapear whereas clicking the button in the following scenario does not:

function bool_setting() {
  this << event click (evt) {
    stdout.println("Clicked button");
    this.attributes.addClass("true");
  }
}

Sciter version: 4.3.0.6

c-smile commented 5 years ago

I do not see any problems with this:

<html>
    <head>
        <title>Test</title>
        <style>
           button {
             aspect: bool_setting;
           }

           button.true {
            color: red;
           }

        </style>
        <script type="text/tiscript">

        function bool_setting() {
          this.attributes.addClass("true");
        }

        </script>
    </head>
    <body>
      <button>Test</button>
    </body>
</html>
SonnyX commented 5 years ago

https://github.com/SonnyX/RenegadeX-Windows-Launcher/releases/download/0.0/specific.zip

Made a little showcase for you where this bug occurs. Just usciter the frontpage.htm and click news. in frontpage.htm the function bool_setting() exists

c-smile commented 5 years ago

I am able to reproduce the issue. thanks. Looking.

For a while replace this.attributes.addClass("true"); by this.post(::this.attributes.addClass("true"));

Problem is that aspect execution happens at the momemt of style assignment and your code is changing the class of element at the same time.

SonnyX commented 5 years ago

Cool thanks, I figured it was something like that. Thanks for the (temp) solution though!

SonnyX commented 5 years ago

Fixed as of 4.3.0.7, as stated in logfile.htm