W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2014

RE: Fetch API

From: Domenic Denicola <domenic@domenicdenicola.com>
Date: Sun, 1 Jun 2014 21:19:00 +0000
To: Tab Atkins Jr. <jackalmage@gmail.com>
CC: Anne van Kesteren <annevk@annevk.nl>, public-script-coord <public-script-coord@w3.org>, Joshua Bell <jsbell@chromium.org>, Jungkee Song <jungkee.song@samsung.com>, Yehuda Katz <wycats@gmail.com>, Alex Russell <slightlyoff@google.com>, Jonas Sicking <jonas@sicking.cc>, Jake Archibald <jaffathecake@gmail.com>, Tobie Langel <tobie.langel@gmail.com>, WebApps WG <public-webapps@w3.org>
Message-ID: <b5fb786f36564e21a25517c346c09097@BN1PR05MB325.namprd05.prod.outlook.com>
From: Tab Atkins Jr. [mailto:jackalmage@gmail.com] 

> Using NamedConstructor is identical to doing:
>
> ```js
> class Foo { ... }
> let Bar = Foo;
> // now I can do "new Foo()" or "new Bar()", to the same effect.
> ```

Not true, since the constructors take different arguments. Instead it is equivalent to

```js
class Response {
  constructor(body, init) { ... }
  ...
}

function RedirectResponse(url, status = 302) {
  return new Response(???, ???);
}
RedirectResponse.prototype = Response.prototype;
```

> What invariants are you concerned about?

In particular, we have that

```js
RedirectResponse.prototype.constructor !== RedirectResponse
(new RedirectResponse(...)).constructor !== RedirectResponse
// Also, omitting the `new` does not throw a `TypeError`, like it does for real constructors.
```

and possibly a few others I am forgetting.
Received on Sunday, 1 June 2014 21:19:41 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:21 UTC