A lightweight helper which wraps and unwraps nested chars with spans in vanilla javascript