Re: [w3ctag/design-reviews] Incubation: patching (interleaved out-of-order streaming) (Issue #1134)

noamr left a comment (w3ctag/design-reviews#1134)


> Thanks for letting us know about this change! We have some questions about it.

Thanks for the thought out questions!

> 
> Mainly we'd like to better understand the reason for the switch away from using an element combined with `contentmethod` as the target for the patch. Introducing a new node type to HTML that can represent an arbitrary range of the document seems more [complex](https://www.w3.org/TR/design-principles/#simplicity), so we'd expect to see this switch satisfy a clear user or developer need.
> 
> The explainer's [outline of the weaknesses of the element approach](https://github.com/WICG/declarative-partial-updates/blob/main/patching-explainer.md#contentmethod-attribute) is helpful but still leaves questions.
> 
> > Doesn't support replacing arbitrary ranges of nodes, only an element or all of its children.

It was brought on by several developers, some major potential adopters, and framework authors. See some discussion on https://github.com/WICG/declarative-partial-updates/issues/. I see this as the biggest design weakness of the `contentmethod` API.

Essentially, when incorportating this feature into a framework workflow, the "partials" don't always relate to their parent element, nor do they necessarily appear at the beginning or end of it.
Some simple examples include replacing a list of `meta` tags in the head or a range of rows in a table. This simply cannot be done with `contentmethod`.

At some point in the discussions at WHATWG we were thinking of having contentmethods in addition to those arbitrary ranges, but then we found that this doesn't add much and that using ranges covers all of the use cases.

> Unclear why repeating the tag is needed -- why doesn't this "just work"?
> 
> <title contentname="title">To be patched...</title>
> <template for="title" contentmethod="replace-children">
>   Title content from the patch
> </template>
> It does seem that patching only a substring of the `<title>` would be tough with this approach. But have you confirmed that there's a real developer need to patch substrings of `<title>`, or patch `<title>` at all?

This is a problem because of how the tokenizer works. The `title` element changes the tokenizer to `RCDATA` - meaning that it parses everything as raw text until it sees the corresponding closing tag (the string `</title>`). That means, for example, that you can't nest titles - `<title>This is a <title>inner</title>, tail</title>` would resolve to `This is a <title>inner` as it would cut off RCDATA at the first `</title>`.

We can't change the tokenization to RCDATA inside `<template>` for this, because that would mean that the following would be parsed differently based on whether the feature is supported or not:

```html
<template for=title contentmethod="replace-children">
  Title
  <template id=internal>Nested content</template>
  After
</templalte>
```

In supported browsers the template would stop parsing before the "After" text because it sees a `</template>`.
An alternative would be to parse the template children normally and then re-serialize and escape the template content but this is a slippery slope of changing parser behavior in an intrusive way.
The same problem applies to `textarea`, and in some other but similar way to `script` and `style`.

With `contentmethod` you'd have to `replace` a script/style/title/textarea and you'd essentiallyl need a separate `<template for contentmethod=replace>` for each of them. With ranges you can replace a whole range of them once.
 
> 
> Other miscellaneous bits of feedback:
> 
> * The explainer shows the `marker` attribute set on the parent node of ranges to be patched, but it's not clear why this is needed. Could the reason be stated more explicitly? Could this work without the attribute, only the patch ranges?
> * The [script-initiated-patching](https://github.com/WICG/declarative-partial-updates/blob/main/patching-explainer.md#script-initiated-patching) section mentions `<template contentmethod>`, should this say `<template for>` in the ProcessingInstructions version of the proposal?

the `marker` attribute has just today been removed from the explainer.
It was there for mXSS prevention reasons that we've later determined are a non-issue.
See also examples for overlaps and nesting.



-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/1134#issuecomment-4084717733
You are receiving this because you are subscribed to this thread.

Message ID: <w3ctag/design-reviews/issues/1134/4084717733@github.com>

Received on Wednesday, 18 March 2026 18:25:14 UTC