@@ -124370,11 +124370,12 @@ partial interface <span>ShadowRoot</span> {
124370
124370
};
124371
124371
124372
124372
dictionary <dfn dictionary>PatchUnsafeOptions</dfn> {
124373
- TrustedTransformStream <dfn dict-member for="PatchUnsafeOptions" data-x="dom-PatchUnsafeOptions-trustedTransformStream">trustedTransformStream </dfn>;
124373
+ boolean <dfn dict-member for="PatchUnsafeOptions" data-x="dom-PatchUnsafeOptions-runScripts">runScripts </dfn> = false ;
124374
124374
};</code></pre>
124375
124375
124376
124376
<div w-nodev>
124377
124377
124378
+ <div algorithm>
124378
124379
<p><code>Element</code>'s <dfn method for="Element"><code
124379
124380
data-x="dom-Element-patchUnsafe">patchUnsafe(<var>options</var>)</code></dfn> method steps
124380
124381
are:</p>
@@ -124383,25 +124384,58 @@ dictionary <dfn dictionary>PatchUnsafeOptions</dfn> {
124383
124384
<li><p>Let <var>writable</var> be a new WritableStream.</p></li>
124384
124385
124385
124386
<li>
124386
- <p>If <var>options</var>["<code data-x="dom-PatchUnsafeOptions-trustedTransformStream">trustedTransformStream</code>"] <span data-x="map exists">exists</span> :</p>
124387
+ <p>👋 Sketch of the streams setup :</p>
124387
124388
124388
124389
<ol>
124389
- <li><p>Set <var>writable</var> to the result of piping <var>writable</var> through <var>options</var>["trustedTransformStream"].</p></li>
124390
+ <li><p>Incoming chunks must all be of the same type, either strings, bytes, or a trusted types
124391
+ wrapper.</p></li>
124392
+
124393
+ <li>
124394
+ <p>Some decisions are made based on the first chunk:</p>
124395
+
124396
+ <ol>
124397
+ <li><p>If it's not a trusted types wrapper and there is a default TT policy, create a
124398
+ transform stream using <code data-x="">createTransformStream</code> from the default policy.
124399
+ Then pipe chunks through that transform stream.</p></li>
124400
+
124401
+ <li><p>If it's bytes, create an UTF-8 TextDecoderStream and pipe chunks through that.</p></li>
124402
+
124403
+ <li><p>TODO: which should happen first? should we allow the TT transform stream to take bytes
124404
+ as input, or guarantee that it's strings by then?</p></li>
124405
+ </ol>
124406
+ </li>
124407
+
124408
+ <li><p>As chunks are coming through, before handing them to the parser, check that they're all
124409
+ of the same type. For trusted types, also check that the chunks are in the same order and not
124410
+ duplicated/filtered/reordered.</p></li>
124390
124411
</ol>
124391
124412
</li>
124392
124413
124393
124414
<li>
124394
- <p>Otherwise :</p>
124415
+ <p>👋 Sketch of the parser setup :</p>
124395
124416
124396
124417
<ol>
124397
- <li><p>If there's a default TT policy, use that and wrap <var>writable</var> 👋</p></li>
124418
+ <li><p>Let <var>parser</var> be a new fragment parser.</p></li>
124419
+
124420
+ <li><p>Add <span>this</span> to the <span>stack of open elements</span>.</p></li>
124421
+
124422
+ <li><p>If <var>options</var>["<code data-x="dom-PatchUnsafeOptions-runScripts">runScripts</code>"],
124423
+ don't mark scripts as already executed.</p></li>
124424
+
124425
+ <li><p>Write chunks into the parser as they are written to <var>writable</var>.</p></li>
124426
+
124427
+ <li><p>When a <code>template</code> element with a <code data-x="">patchfor</code> attribute
124428
+ comes out of the parser, find the target node by ID and set that as the parser's insertion
124429
+ point.</p></li>
124430
+
124431
+ <li><p>The first time an element is patched, replace all children. Subsequent patches to the
124432
+ same target append children.</p></li>
124398
124433
</ol>
124399
124434
</li>
124400
124435
124401
- <li><p>Create a new parser and do all the actual work 👋</p></li>
124402
-
124403
124436
<li><p>Return <var>writable</var>.</p></li>
124404
124437
</ol>
124438
+ </div>
124405
124439
124406
124440
<div class="example">
124407
124441
<p>Do a thing like this:</p>
@@ -124416,19 +124450,21 @@ dictionary <dfn dictionary>PatchUnsafeOptions</dfn> {
124416
124450
}
124417
124451
});
124418
124452
124419
- const trustedTransformStream = policy.createTransformStream(input);
124420
- const writable = element.patchUnsafe({ trustedTransformStream });
124421
124453
const response = await fetch('/fragments/something');
124422
- response.body.pipeTo(writable);</code></pre>
124454
+ const transform = policy.createTransformStream();
124455
+ const writable = element.patchUnsafe();
124456
+ await response.body.pipeThrough(transform).pipeTo(writable);</code></pre>
124423
124457
</div>
124424
124458
124459
+ <div algorithm>
124425
124460
<p><code>ShadowRoot</code>'s <dfn method for="ShadowRoot"><code
124426
124461
data-x="dom-ShadowRoot-patchUnsafe">patchUnsafe(<var>options</var>)</code></dfn> method steps
124427
124462
are:</p>
124428
124463
124429
124464
<ol>
124430
124465
<li>TODO</li>
124431
124466
</ol>
124467
+ </div>
124432
124468
124433
124469
</div>
124434
124470
0 commit comments