MCPcopy
hub / github.com/ampproject/amphtml / transferBody

Method transferBody

src/utils/dom-transform-stream.js:106–131  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers 1

Calls 5

transferBodyChunk_Method · 0.95
devAssertElementFunction · 0.90
devAssertFunction · 0.90
thenMethod · 0.45
setAttributeMethod · 0.45

Tested by

no test coverage detected