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

Why cant hyperscript find the function attached as a property? #498

Open
shirecoding opened this issue Dec 3, 2023 · 1 comment
Open

Comments

@shirecoding
Copy link

I have the following inside a web component, it seems quite hard to get hyperscript to find the functions defined on the element. i only seem to be able to get it to find global functions

class WalletProvider extends HTMLElement {
...
...
this.innerHTML = `
        <button id="connect-wallet-button" script="
          on click
            call connectWallet() <------------------- hyperscript cant find this
            set my innerHTML to 'Connected'
          catch err
            set my innerHTML to 'Connect Wallet'
          end
        ">Connect Wallet</button>
      `;

      this.querySelector("#connect-wallet-button").connectWallet =
        this.connectWallet.bind(this);<------------------ i've also made sure to add the function to the button

...
...

async connectWallet() {
      const resp = await this.wallet.connect();
      const publicKey = resp.publicKey.toString();
      console.log(`Connected phantom wallet, your public key is ${publicKey}`);
    }
@svenberkvens
Copy link

Perhaps you need to tell hyperscript that it needs to find the function on the element. Maybe call me.connectWallet() will work?

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