I think the implementation is close to the expected behavior, but needs some improvements:
ellipsis handling: The text-overflow: ellipsis; replace with white-space: nowrap; and overflow: hidden;.