opened
domenic
username_0
Although I appreciate the analogy to custom elements, I wasn't able to quite follow from the 3 or so sentences in this FAQ.

Maybe an easier way to show it would be, at what step would the UA get stuck if you didn't extend from a base class? I guess maybe the issues is that instances of the class would not be known to be instances of the registered-serializable class? Hmmmmm.
Expand on "Why require both extending and registering?"
issue
created
littledan
username_1
Extending is all about giving it the platform brand so that structured clone doesn't get any slower checking for these kinds of objects. Otherwise, given an object, what would structured clone even do to check whether it should use these fancy new methods, or ignore them and treat it like any other object?
comment
created
domenic
username_0
Well, at least on the serialization side, it could look for the presence of the serialize method, since it would have to grab all the own properties anyway in the fallback case. (Probably want to use a symbol then for back-compat.)
comment
created
littledan
username_1
Do you think we could add an additional property access each time we serialize an object, without a performance regression? I'm not sure; this feels like just asking for a repeat of the performance cliffs ES6 is full of.
comment
created
domenic
username_0
To be clear, we'd only do it after failing all the pre-existing brand checks. So we'd already be in the generic object case.

Then it'd be a difference between the current n property gets, and the n+1 property gets for this additional symbol. Compared with this proposal's n property gets + 1 internal slot get.

To me the two n+1s don't seem significantly different from each other, but you'd know better.
comment
created
littledan
username_1
Well, I haven't edited this code in any implementation, so I am guessing as well. I didn't think think that this would be adding an internal slot get, since it is accessing the same platform brand. But maybe it wouldn't be expensive to check for the symbol in practice. Something to investigate.
comment
created
jimmywarting
username_2
What if you want the class to extend something else like EventTarget?
```js
class Person extends EventTarget { }
```
How are you suppose to make this clonable? Multiple extends are not supported
comment