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

Custom element missing methods #1369

Closed
willtj opened this issue Apr 25, 2018 · 1 comment · Fixed by #1375
Closed

Custom element missing methods #1369

willtj opened this issue Apr 25, 2018 · 1 comment · Fixed by #1375
Labels

Comments

@willtj
Copy link

willtj commented Apr 25, 2018

I've created a basic custom element based on template-custom-element but the component's methods don't seem to being added to the compiled JS.

My component

<h1>Hello {{name}}!</h1>

<button on:click="saySomething()">Click me</button>

<script>
  export default {
    tag: 'my-app',

    data() {
      return {
        'name': 'World'
      }
    },

    methods: {
      saySomething() {
        alert('Again, please don\'t do this');
      }
    }
  };
</script>

Clicking on the button throws an error:

Uncaught TypeError: component.saySomething is not a function
    at HTMLButtonElement.click_handler (App.html:3)

Full example is here: https://github.com/willtj/template-custom-element

@Rich-Harris
Copy link
Member

Thanks — fixed in 2.3.0

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

Successfully merging a pull request may close this issue.

2 participants