Re: [heycam/webidl] Consider [LegacyStringClass] (#547)

Appreciate the exploratory thoughts!

>Allow use of String.prototype methods, like substring/startsWith/etc. For example, a.href.substring(1). This would be what requires inheriting from String. But, how would these work? E.g. would substring() return a SVGAnimatedString, or a String, or a string? Would they operate on animVal or baseVal?

This is indeed the tricky problem. Ideally, we'd want the `SVGAnimatedString` instance to have a [[StringData]] that the String.prototype methods would be able to operate on. We'd want all of the methods to return a (String or string) [not sure which]. The implementation of `animVal` and `baseVal` would simply read and write the [[StringData]].

However, it sounds like this path has been trod before, and there's not a great solution to subclass String objects (nor should we be encouraging this).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/547#issuecomment-380939953

Received on Thursday, 12 April 2018 20:49:54 UTC