| 1390 | var onBeforeMorphElChildren = options.onBeforeMorphElChildren || noop; |
| 1391 | |
| 1392 | function removeNodeHelper(node, nestedInSavedEl) { |
| 1393 | var id = node.id; |
| 1394 | // If the node has an ID then save it off since we will want |
| 1395 | // to reuse it in case the target DOM tree has a DOM element |
| 1396 | // with the same ID |
| 1397 | if (id) { |
| 1398 | savedEls[id] = node; |
| 1399 | } else if (!nestedInSavedEl) { |
| 1400 | // If we are not nested in a saved element then we know that this node has been |
| 1401 | // completely discarded and will not exist in the final DOM. |
| 1402 | onNodeDiscarded(node); |
| 1403 | } |
| 1404 | |
| 1405 | if (node.nodeType === 1) { |
| 1406 | var curChild = node.firstChild; |
| 1407 | while(curChild) { |
| 1408 | removeNodeHelper(curChild, nestedInSavedEl || id); |
| 1409 | curChild = curChild.nextSibling; |
| 1410 | } |
| 1411 | } |
| 1412 | } |
| 1413 | |
| 1414 | function walkDiscardedChildNodes(node) { |
| 1415 | if (node.nodeType === 1) { |