Skip to content

Ignore undefined/falsey properties on components and elements #1434

Description

@TehShrike

Brought up in chat by @arxpoetica: when using spread to apply an object's properties to an element, it is desirable to be able to say "apply everything except these specific properties".

Say, for example, something like <svelte:component this={MyComponent} {...all} />, which would result in a MyComponent property being set on the component.

If the spread operator ignored falsey values (or more safely, just ignored undefined values) on the object, it would be relatively easy to use something like Object.assign to specifically exclude some properties, say with this computed property:

computed: {
  forSpread: all => Object.assign({}, all, { MyComponent: undefined })
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions