Before a slime splits into its smaller variants after it has been slain, it’s hit box still deals the same amount of damage as its death animation plays. Both the large slime and medium slime does this, however the medium slime is more obvious due to small slimes being unable to deal damage to the player, yet it still deals damage after the player believes its safe to travel through.
This issue is being tracked at MCPE-166394.