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 events not working on <:Window> #1268

Closed
jacwright opened this issue Mar 22, 2018 · 1 comment · Fixed by #1315
Closed

Custom events not working on <:Window> #1268

jacwright opened this issue Mar 22, 2018 · 1 comment · Fixed by #1315

Comments

@jacwright
Copy link
Contributor

Custom events are not being respected (used) when listening to them on <:Window>. The repl wasn't saving for me just now so you can copy-paste this into it to see. It gives an error about the escKey custom event being unused and in the source you can see it has window.addEventListener('escKey', onwindowescKey).

<:Window on:escKey="handleEsc(event)"/>

<script>
  export default {
    events: {
      escKey(node, callback) {
        function onKeyDown(event) {
          if (event.keyCode === 27) callback(event);
        }
        node.addEventListener('keydown', onKeyDown);
        return {
          teardown() {
            node.removeEventListener('keydown', onKeyDown);
          }
        }
      }
    },
    methods: {
      handleEsc(event) {
        console.log(event)
      },
    }
  }
</script>
Rich-Harris added a commit that referenced this issue Apr 4, 2018
support custom events on <:Window>
@Rich-Harris
Copy link
Member

Thanks — fixed in 1.60.2

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

Successfully merging a pull request may close this issue.

2 participants