One thing had always puzzled me about Nokia (and then Microsoft) smartphones - almost every example with a replaceable battery (and that's most of them) had a foam pad stuck to the inside of the back cover. It's true that this is partly to stop the battery rattling a little when the phone is shaken, but the foam also serves another purpose, I contend.
For starters, it allows for a little variation in battery thickness. No two cells are ever exactly the same thickness, and the last thing you want is a frame so tightly space controlled that a small percentage of batteries end up under physical pressure from any direction. Such pressure deforms the internal electrolyte layers and, in the worst case, can cause the battery to catch fire or explode - as we saw recently in the Android world.
Now, I'd argue that the first design aim for any smartphone should be to have a replaceable battery in the first place, but the likes of the Apple iPhone and fashion have meant that many manufacturers have opted for a sealed design because it's prettier, lighter and... thinner. And yes, that latter constraint works against the danger here.
The second design aim should then be to have some margin of error in the size of the battery - in checking the various smartphones around All About Towers, I noticed that quite a few had empty space around the bulk of the battery, up to a millimetre (in total) in some cases. This doesn't impact performance, since the battery contacts are 'pin and sleeve' and work at a variety of relative distances. But it does mean that if a battery is very slightly over-size (by a fraction of a millimetre) then it's not going to be a problem inserting it and there won't be any external pressure around the sides.
The same applies, only more so, on the battery's exterior face, with at least a millimetre (and sometimes more) of empty space above it and under the removeable back cover. Ample room for tolerance errors in batteries, and yes, the foam pad is then needed to avoid mechanical rattles.
The foam pad becomes even more important when the battery gets old, too. You see, when a Li-Ion battery gets old or has been misused (e.g. allowed to run down to zero charge and left there for a while), gases build up inside and the battery starts to swell - I'm sure most of us have seen examples of this. Eventually the battery dies, of course, and has to be disposed of responsibly. However, in the meantime, while it is swelling up (and in old phones this can happen while the phone is in daily use) the foam pad takes up all the initial swelling without stressing the battery layers too much. If the phone body was fixed and the battery wasn't replaceable then the swelling would apply serious pressure to the phone's structure, to its surrounding electronics and - most dangerously - to the battery's own structural integrity.
I've argued many times (e.g. here) that the pros of replaceable batteries outweigh the cons but I never thought it would take a $17 billion industry loss to prove the potential dangers of going 'sealed'.
Note that I'm not saying that all 'sealed' smartphones are inherently dangerous - just that unless the manufacturer leaves a little 'wiggle room' inside then the pressures on the cell when everything it screwed together can cause serious problems. I've taken iPhones apart, for example, and the batteries aren't pressured from all sides in the same way as in (presumably) the Note 7. (From the Bloomberg report into the affair: "a production fault had caused some of the batteries to be slightly larger than intended, which had put pressure on them when they were fitted inside phones".)
In the case of the modern Lumias with Qi charging, by the way, the foam is replaced by the Qi coils themselves - these are mounted inside thick plastic sleeves and are also inherently slightly compressible, serving much the same effect. Plus with the removeable backs only held in place by relatively weak plastic clips there's room for expansion there too.
Comments welcome - the whole Note 7 fiasco has certainly caused me to be thankful (yet again) that almost every phone I use on a regular basis has a replaceable battery and room to breathe...