diff --git a/src/pyj/range_utils.pyj b/src/pyj/range_utils.pyj index 55cc7603fd..18ff4c2e6a 100644 --- a/src/pyj/range_utils.pyj +++ b/src/pyj/range_utils.pyj @@ -94,7 +94,11 @@ def select_crw(crw): def wrap_range(r, wrapper): - r.surroundContents(wrapper) + try: + r.surroundContents(wrapper) + except: + wrapper.appendChild(r.extractContents()) + r.insertNode(wrapper) # remove any empty text nodes created by surroundContents() on either # side of the wrapper. This happens for instance on Chrome when # wrapping all text inside some text