Bug 902363: factorize `setTextContent` to fix `localizeElement`

https://bugzilla.mozilla.org/show_bug.cgi?id=902363