I haven't been able to track down which part of the specs say that textareas and input elements have to overflow instead of expanding.
All my expectations so far suggest textareas really should expand with their contents.
I wouldn't even start thinking about more complex rules like "height of content, with half a line wide of padding at end of input" until it's clear why a
textarea don't behave like a
div, with respect to automatic sizing.
This is definitely not something we should need scripting to accomplish.