Skip to content

Commit 37a77f2

Browse files
authored
Merge pull request #77 from WICG/marker-start-end
Add option for marker nodes with start/end attributes
2 parents cf3b548 + 3d95f16 commit 37a77f2

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

patching-explainer.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,60 @@ The patches uses a single marker node:
204204

205205
</details>
206206

207+
##### Markers with start/end attributes
208+
209+
This alternative adds `start` and `end` boolean attributes to the marker nodes, so that the start/end of a range are defined by the markers, not attributes on `<template>`.
210+
211+
This makes it possible to replace a `<title>` element.
212+
213+
<details>
214+
<summary>Example</summary>
215+
216+
```html
217+
<head>
218+
<?marker name="metadata" start?>
219+
<title>Page 1</title>
220+
<?marker name="metadata" end?>
221+
</head>
222+
223+
<template contentname="metadata">
224+
<title>Page 2</title>
225+
</template>
226+
```
227+
228+
</details>
229+
230+
Details around `<title>` and the RCDATA tokenizer state are the main reason that the tag name needs to be repeated in other alterantives, but this isn't needed in this option, the children of `<template>` elements are just the new content. The `contentname` attribute can refer to either marker node(s) or an element.
231+
232+
When `start` and `end` aren't used, the marker node is replaced. The interleaved patching example then becomes:
233+
234+
<details>
235+
<summary>Example</summary>
236+
237+
```html
238+
<template contentname=search-results>
239+
<p>first result</p>
240+
<!-- add markers to allow for "append" -->
241+
<?marker name=search-results-more?>
242+
</template>
243+
244+
<template contentname=product-carousel>
245+
Actual carousel content
246+
</template>
247+
248+
<template contentname=search-results-more>
249+
<p>second result</p>
250+
<!-- new markers are needed for the next "append". -->
251+
<?marker name=search-results-more?>
252+
</template>
253+
254+
<template contentname=search-results-more>
255+
<p>third result</p>
256+
</template>
257+
```
258+
259+
</details>
260+
207261
## Script-initiated patching
208262

209263
`streamHTMLUnsafe()` is being pursued as a [separate proposal](https://github.com/whatwg/html/issues/2142), but will also work with patching. When `<template contentmethod>` appears in the streamed HTML, those patches can apply to descendants of element on which `streamHTMLUnsafe()` was called.

0 commit comments

Comments
 (0)