Issue
The problem was related to the environment (i.e. an extension). I was in a XUL context so using createElement()
create a XUL element which don't have a lang
attribute.
So to fix problem and other (no way to select inserted text), I had to force the XHTML namespace with createElementNS(ns, elt)
.
Code
var nsXHTML = "http://www.w3.org/1999/xhtml";
var wrapper = document.createElementNS(nsXHTML, "span");
var zh = document.createElementNS(nsXHTML, "i");
zh.lang= "zh-cmn";