demos/Collage/fabric.js
function wrapElement(element, wrapper, attributes) {
    if (typeof wrapper === 'string') {
      wrapper = makeElement(wrapper, attributes);
    }
    if (element.parentNode) {
      element.parentNode.replaceChild(wrapper, element);
    }
    wrapper.appendChild(element);
    return wrapper;
  }
function wrapElement(element, wrapper, attributes) {
    if (typeof wrapper === 'string') {
      wrapper = makeElement(wrapper, attributes);
    }
    if (element.parentNode) {
      element.parentNode.replaceChild(wrapper, element);
    }
    wrapper.appendChild(element);
    return wrapper;
  }
function wrapElement ( element , wrapper , attributes ) { if ( typeof wrapper === 'string' ) { wrapper = makeElement ( wrapper , attributes ) ; } if ( element . parentNode ) { element . parentNode . replaceChild ( wrapper , element ) ; } wrapper . appendChild ( element ) ; return wrapper ; }
Wraps element with another element
@method wrapElement
@memberOf fabric.util
@param {HTMLElement} element Element to wrap
@param {HTMLElement|String} wrapper Element to wrap with
@param {Object} [attributes] Attributes to set on a wrapper
@return {HTMLElement} wrapper
Wraps element with another element