# A question about the \`liftTarget\` function

**URL:** <https://discuss.prosemirror.net/t/a-question-about-the-lifttarget-function/3732>\
**Category:** Uncategorized\
**Created:** [April 29, 2021, 10:04am UTC](https://discuss.prosemirror.net/t/a-question-about-the-lifttarget-function/3732 "2021-04-29T10:04:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jack](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/j/cc9497/32.png) [@jack](https://discuss.prosemirror.net/u/jack)\
**Post date:** [April 29, 2021, 10:04am UTC](https://discuss.prosemirror.net/t/a-question-about-the-lifttarget-function/3732/1 "2021-04-29T10:04:02Z")

</div>

I’m puzzled about the underlying reasoning behind choosing the depth that a NodeRange could be lifted to.

Assume we need to lift the second paragraph “cd” out of the block quote:

```html
<doc>
  <blockquote>
    <p>ab</p>
    <p>cd</p>
  </blockquote>
</doc>

```

We need to call `liftTarget(range)` where `range` covers the `<p>cd</p>` node.

> <https://github.com/ProseMirror/prosemirror-transform/blob/1.3.1/src/structure.js#L21>

```js
export function liftTarget(range) {
  let parent = range.parent
  let content = parent.content.cutByIndex(range.startIndex, range.endIndex)
  for (let depth = range.depth;; --depth) {
    let node = range.$from.node(depth)
    let index = range.$from.index(depth), endIndex = range.$to.indexAfter(depth)
    // line 21
    if (depth < range.depth && node.canReplace(index, endIndex, content))  
      return depth
    if (depth == 0 || node.type.spec.isolating || !canCut(node, index, endIndex)) break
  }
}

```

When the execution reaches line #21, the local variables are:

range.depth = 1

depth = 0

content = `<p>cd</p>`

node = the root “doc”

index = 0, endIndex = 1

Ofc, `node.canReplace(index, endIndex, content) ` would return `true`, but I wonder how could that alone indicate we can lift the `<p>cd</p>` to be a child of the root node?
