function cloneAndIsolate()

in src/components/draggable.js [116:133]


function cloneAndIsolate(el) {
  const rect = el.getBoundingClientRect()
  const owner = getOwner(el)

  const topLeft = globalToLocal({x: rect.left, y: rect.top}, el)
  const bottomRight = globalToLocal({x: rect.right, y: rect.bottom}, el)

  const viewBox = [topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y]

  // cloning without (true) does a shallow clone: node + attributes,
  // no children
  const outer = owner.cloneNode()
  outer.removeAttribute('class')
  outer.setAttribute('width', rect.width)
  outer.setAttribute('viewBox', viewBox.join(' '))
  outer.appendChild(el.cloneNode(true))
  return outer
}