* Unwraps the root element. If root has a single element child, * returns the child. Otherwise, returns root. * @param {!Element} root * @return {!Element} * @protected @final
(root)
| 88 | * @protected @final |
| 89 | */ |
| 90 | tryUnwrap(root) { |
| 91 | let onlyChild; |
| 92 | this.visitChildren_(root, (c) => { |
| 93 | if (onlyChild === undefined && c.nodeType) { |
| 94 | onlyChild = c; |
| 95 | } else { |
| 96 | onlyChild = null; |
| 97 | } |
| 98 | }); |
| 99 | return onlyChild || root; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Unwraps the root element and returns any children in an array. |
no test coverage detected