3 ms·
At a glance, they do it so that at the end they can merge in any remaining props they didn't handle after all their work building `elem` is done. This can be
by hombre_fatal 6y ago
At a glance, they do it so that at the end they can merge in any remaining props they didn't handle after all their work building `elem` is done.
This can be accomplished non-destructively with destructuring.
const {
attributes,
classList,
style,
...rest
} = p
// elem = ...consume attributes, classList, style...
return Object.assign(elem, rest)
- enlyth 6y agoThis approach with destructuring is great but you will need to transpile the code if you're targeting IE11 which is still often the case in enterprise settings unfortunately.