Skip to content

Uncaught TypeError: Illegal invocation #36

@himynameisdave

Description

@himynameisdave

Describe the bug

When using withPreventDefault in a standard/template Rollup + Svelte project, I get the following error: Uncaught TypeError: Illegal invocation

It seems to be pointing to this line in callIfExists, which the compiler spits out as this:

return (_a = event === null || event === void 0 ? void 0 : event[method]) === null || _a === void 0 ? void 0 : _a();

Where invoking _a() seems to be causing the bug.

To Reproduce
Steps to reproduce the behavior:

  1. Clone the svelte template repo.
  2. yarn add browser-event-utils@next
  3. Wrap an event handler with withPreventDefault:
<script>
  import { withPreventDefault } from 'browser-event-utils';

  const handleDrop = withPreventDefault(() => { //... });
</script>

<div on:drop={handleDrop}>
  Drop here!
</div>
  1. Invoke the event, you should see the error.

Expected behavior

It should just call the expected method, no errors.

Versions (please complete the following information):

  • browser-event-utils Version: [eg: v3.0.0-beta.5]
  • Browser & Version: Google Chrome 83.0.4103.106
  • Framework version (if applicable) [eg: svelte@3.23.2]
  • (Optionally) NodeJS Version: v12.16.3

Additional context or comments
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions