Re: [fetch] OpenEndedDictionary clarification (#164)

> @annevk Oh, and the other slightly open question is what the behavior should actually be. As in, Domenic's semantics involve calling the actual "append" method

This would be preferable, for the same reason as `Map` and `Set` call the actual append method. It makes these classes have a reasonable subclassing protocol, that allows you to override a single method (append) and have that behavior propagated to all places that append. Example:

```js
class HeadersPrefixed extends Headers {
  append(name, value) {
    if (!someWhitelist.has(name)) {
      super.append("myapp-" + name, value);
    } else {
      super.append(name, value);
    }
  }
}

// fill a HeadersPrefixed instance, and then pass it to `new Request(...)` or something.
```

However, looking throug the spec I'm not sure this is sufficient to give reasonable subclassing. For example you would probably need to make `.set()` delegate to `.delete()` + `.append()` public APIs. And there might be other places in the spec that append to a `Headers` instance that fail to go through the public API. (But, maybe those only act on internal "header list"s, not on `Headers` instances? I can't quite tell.)

So maybe we should just give up on this principle of `Headers` having a reasonable subclassing protocol. Most DOM APIs don't, after all. And this might not be the right place to start taking a stand. In that case calling the internal append algorithm would be OK.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/164#issuecomment-160667566

Received on Monday, 30 November 2015 15:49:07 UTC