-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Class string of default iterator object seems to have been accidentally changed? #419
Comments
|
Maybe best to replace with concatenating X, U+0020 SPACE, and Y rather than X and " Y" for clarity. |
(Mis)read your message before morning coffee and thought I had introduced the whitespace. Sorry. Removing the whitespace was a deliberate fix, as no other class string contained whitespace (including the class string of the iterator prototype object), and I assumed it was a typo. I think we should leave it as such unless there's a good reason not to. (As an aside, this should probably have been in a PR of its own or at least be mentioned in the commit message.) |
Mmm. On further inspection, the whitespace seems to have been originally deliberate given the SessionManager example we (still) have in the spec. :-( Sounds like we need to figure out what browsers are doing, figure out what we want to do and if we add back the whitespace, do as Anne suggests above (plus ideally add a note to explain why we have a convention departure for that particular case). |
The plot thickens. Originally, It was subsequently changed to |
In ES there is a space, e.g. |
Guess I should have looked there before "fixing" this. :-/ |
So this is predictably messy. Given:
In contrast, given:
|
I'd like a resolution on this soon as Web compatibility concerns have not yet kicked in. I am of the opinion that adding the space back in is the way to go here, for consistency with ES. I remember @bzbarsky was of the opinion that prototype objects should always have different class strings as instances but I could well be misremembering (thus looping him in). I do have to say though that FWIW Node.js uses |
Agreed.
As far as WebIDL is concerned, this is only specified for interface prototype objects. So technically, the iterator object's prototype, which isn't an interface prototype object, shouldn't be suffixed with "Prototype".
Yeah. Overall, we should strive for more consistency with ES here, imho. This includes figuring out what to do with the "Prototype" suffix. |
Additionally, see #54 and https://www.w3.org/Bugs/Public/show_bug.cgi?id=28244. |
I think that even though in the general case @bzbarsky may not agree to the proposed solution to #54, i.e. #357, hopefully for iterator objects, which are explicitly designed to be compatible with ES, we can go the same way they do, and install a single symbol on the prototype with no "Prototype" suffix. |
The proposed resolution would be the following behavior, right? const it = new URLSearchParams().values();
it[Symbol.toStringTag];
// --> "URLSearchParams Iterator"
Object.prototype.toString.apply(it);
// --> "[object URLSearchParams Iterator]"
Object.getPrototypeOf(it)[Symbol.toStringTag];
// --> "URLSearchParams Iterator"
Object.prototype.toString.apply(Object.getPrototypeOf(it));
// --> "[object URLSearchParams Iterator]" |
Yep! |
I can live with that solution for iterators, yes. In practice, getting their prototypes is enough of a PITA that people won't be passing them around, I hope and hence won't run into the branding issues that somewhat worry me for interface prototype objects. Please make sure to file bugs on browsers when this lands? |
Did test/implementation bugs get filed? |
Commit d433e0a (#198) has a commit message of the following:
However, it contains the following normative change (white space differences ignored):
It seems to have been accidental, but there are already some implementations using the new changed spec (admittedly, most of which were written by me).
/cc @tobie
The text was updated successfully, but these errors were encountered: