* Start the body transfer process. Should only be called once. * @param {!Element} targetBody body element to be appended to. * @return {!Promise} resolves when doc has been fully transferred.
(targetBody)
| 104 | * @return {!Promise} resolves when doc has been fully transferred. |
| 105 | */ |
| 106 | transferBody(targetBody) { |
| 107 | devAssertElement( |
| 108 | targetBody, |
| 109 | 'No target body given to DomTransformStream.transferBody' |
| 110 | ); |
| 111 | |
| 112 | devAssert( |
| 113 | !this.shouldTransfer_, |
| 114 | 'DomTransformStream.transferBody should only be called once' |
| 115 | ); |
| 116 | |
| 117 | this.shouldTransfer_ = true; |
| 118 | this.targetBodyResolver_(targetBody); |
| 119 | |
| 120 | this.headPromise_.then(() => { |
| 121 | const attrs = this.detachedBody_.attributes; |
| 122 | for (let i = 0; i < attrs.length; i++) { |
| 123 | const {name, value} = attrs[i]; |
| 124 | targetBody.setAttribute(name, value); |
| 125 | } |
| 126 | }); |
| 127 | |
| 128 | this.transferBodyChunk_(); |
| 129 | |
| 130 | return this.bodyTransferPromise_; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Transfers available body elements in vsync cycle. |
no test coverage detected