- From: Timothy Gu <notifications@github.com>
- Date: Sun, 15 Jan 2017 11:38:00 -0800
- To: heycam/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Sunday, 15 January 2017 19:38:31 UTC
As discussed in whatwg/url#204, there is some confusion about the distinguishability between string types and sequences. Although currently, the spec maintains that they are [distinguishable](https://heycam.github.io/webidl/#dfn-distinguishable), @domenic and @annevk have express doubts over that.
What I have found is that:
1. ES string primitives are **NOT** valid sequences, and are therefore distinguishable. Even though string primitives have a `@@iterator`, they fail the [`typeof === 'object'` check](https://heycam.github.io/webidl/#es-to-sequence) in conversion to a sequence.
2. ES string wrapper objects **ARE** valid sequences. They pass the aforementioned test, and they likewise have a valid iterator interface.
This is exemplified in Firefox, which implements iterable-to-sequence conversion:
```js
>> new Headers([ 'ab' ]).get('a')
x "TypeError: Element of member of HeadersOrByteStringSequenceSequenceOrByteStringMozMap can't be converted to a sequence."
>> new Headers([ new String('ab') ]).get('a')
<- "b"
```
How can we resolve this situation?
--
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/266
Received on Sunday, 15 January 2017 19:38:31 UTC