preact icon indicating copy to clipboard operation
preact copied to clipboard

[WIP] Bugfix: Component's default render() should render nothing

Open developit opened this issue 5 years ago • 7 comments
trafficstars

Currently it uses Fragment as its implementation to reduce size, but Fragment renders props.children. This means that components inheriting from Component without providing their own render() method render their children by default.

developit avatar Dec 19 '19 14:12 developit

Can we add a test for that so we don‘t regress when golfing? I might find an hour or two today to add one

sventschui avatar Dec 20 '19 07:12 sventschui

Coverage Status

Coverage increased (+0.07%) to 97.749% when pulling 603e7daf2fe7c52366505fdbadd218161d2f24fe on bugfix-component-default-render into cf635d5eb274c2fba4fc23c34ef9157b90d17e81 on master.

coveralls avatar Dec 21 '19 21:12 coveralls

Tests are failing, and I think it's because Suspense assumed Component.prototype.render would render children.

developit avatar Dec 21 '19 21:12 developit

@developit Is this still WIP? Maybe we can merge it in

JoviDeCroock avatar Dec 30 '19 17:12 JoviDeCroock

I think we can merge. Only thing I was wondering is whether we wanted to hoist the function up as a constant (EMPTY_FUNC). Potentially useful for null callbacks?

developit avatar Dec 30 '19 17:12 developit

I think we can merge. Only thing I was wondering is whether we wanted to hoist the function up as a constant (EMPTY_FUNC). Potentially useful for null callbacks?

Feels good to me

JoviDeCroock avatar Dec 30 '19 17:12 JoviDeCroock

@developit do you still wanna add the EMPTY_FUNC in this PR? Or is it ready? Can be added later as well.

cristianbote avatar Jan 16 '20 21:01 cristianbote