Skip to content

Triggered Events don't receive arguments #143

@cloudratha

Description

@cloudratha

When triggering native SW events, they do not receive the event type.

function createEvent(event, args) {
switch (event) {
case 'fetch':
return new FetchEvent('fetch', getFetchArguments(args));
case 'notificationclick':
return new NotificationEvent(args);
case 'push':
return new PushEvent(args);
case 'message':
return new MessageEvent('message', args);
default:
return new ExtendableEvent();
}
}

This is breaking pre-caching from Workbox, which specifically asserts the install event's type.

function createEvent(event, args) {
  switch (event) {
    case 'fetch':
      return new FetchEvent('fetch', getFetchArguments(args));
    case 'notificationclick':
      return new NotificationEvent(args);
    case 'push':
      return new PushEvent(args);
    case 'message':
      return new MessageEvent('message', args);
    default:
      return new ExtendableEvent(event, args);
  }
}

The above seems to produce the expected behaviour.

I attempted to fork and do a PR, however I cannot get the tests to pass on a clean install. Any advice?

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