* 1. Deal with Safari cloning nested bug by * manually cloning all template instances. * 2. Deal with IE10/11 textarea placeholder bug by setting * the correct value after cloning. * * @param {Element|DocumentFragment} node * @return {Element|DocumentFragment}
(node)
| 3601 | */ |
| 3602 | |
| 3603 | function cloneNode(node) { |
| 3604 | /* istanbul ignore if */ |
| 3605 | if (!node.querySelectorAll) { |
| 3606 | return node.cloneNode(); |
| 3607 | } |
| 3608 | var res = node.cloneNode(true); |
| 3609 | var i, original, cloned; |
| 3610 | /* istanbul ignore if */ |
| 3611 | if (hasBrokenTemplate) { |
| 3612 | var tempClone = res; |
| 3613 | if (isRealTemplate(node)) { |
| 3614 | node = node.content; |
| 3615 | tempClone = res.content; |
| 3616 | } |
| 3617 | original = node.querySelectorAll('template'); |
| 3618 | if (original.length) { |
| 3619 | cloned = tempClone.querySelectorAll('template'); |
| 3620 | i = cloned.length; |
| 3621 | while (i--) { |
| 3622 | cloned[i].parentNode.replaceChild(cloneNode(original[i]), cloned[i]); |
| 3623 | } |
| 3624 | } |
| 3625 | } |
| 3626 | /* istanbul ignore if */ |
| 3627 | if (hasTextareaCloneBug) { |
| 3628 | if (node.tagName === 'TEXTAREA') { |
| 3629 | res.value = node.value; |
| 3630 | } else { |
| 3631 | original = node.querySelectorAll('textarea'); |
| 3632 | if (original.length) { |
| 3633 | cloned = res.querySelectorAll('textarea'); |
| 3634 | i = cloned.length; |
| 3635 | while (i--) { |
| 3636 | cloned[i].value = original[i].value; |
| 3637 | } |
| 3638 | } |
| 3639 | } |
| 3640 | } |
| 3641 | return res; |
| 3642 | } |
| 3643 | |
| 3644 | /** |
| 3645 | * Process the template option and normalizes it into a |
no test coverage detected