Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,13 @@ These appear as members of interfaces that look like this:
{
"type": "maplike", // or "legacyiterable" / "iterable" / "setlike"
"idlType": /* One or two types */ ,
"readonly": false, // only for maplike and setlike
"readonly": null, // only for maplike and setlike
"trivia": {
"base": " ",
"open": "",
"close": "",
"termination": ""
},
"extAttrs": []
}
```
Expand All @@ -650,7 +656,8 @@ The fields are as follows:

* `type`: Always one of "iterable", "legacyiterable", "maplike" or "setlike".
* `idlType`: An array with one or more [IDL Types](#idl-type) representing the declared type arguments.
* `readonly`: Whether the maplike or setlike is declared as read only.
* `readonly`: An object with a string type field `trivia` if the maplike or setlike is declared as read only.
* `trivia`: A trivia object.
* `extAttrs`: A list of [extended attributes](#extended-attributes).


Expand Down
2 changes: 1 addition & 1 deletion lib/webidl2.js
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@
unconsume(start_position);
return;
}
ret.trivia.type = ittype.trivia;
ret.trivia.base = ittype.trivia;

const secondTypeRequired = ittype.value === "maplike";
const secondTypeAllowed = secondTypeRequired || ittype.value === "iterable";
Expand Down
2 changes: 1 addition & 1 deletion lib/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
function iterable_like(it) {
const readonly = it.readonly ? `${it.readonly.trivia}readonly` : "";
const bracket = `${it.trivia.open}<${it.idlType.map(type).join("")}${it.trivia.close}>`;
return `${readonly}${it.trivia.type}${it.type}${bracket}${it.trivia.termination};`;
return `${readonly}${it.trivia.base}${it.type}${bracket}${it.trivia.termination};`;
}
function callbackInterface(it) {
return `${it.trivia.callback}callback${interface_(it)}`;
Expand Down
6 changes: 3 additions & 3 deletions test/syntax/json/iterable.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
],
"trivia": {
"type": "\n ",
"base": "\n ",
"open": "",
"close": "",
"termination": ""
Expand Down Expand Up @@ -87,7 +87,7 @@
}
],
"trivia": {
"type": "\n ",
"base": "\n ",
"open": "",
"close": "",
"termination": ""
Expand Down Expand Up @@ -147,7 +147,7 @@
}
],
"trivia": {
"type": "\n ",
"base": "\n ",
"open": "",
"close": "",
"termination": ""
Expand Down
2 changes: 1 addition & 1 deletion test/syntax/json/legacyiterable.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
],
"trivia": {
"type": "\n ",
"base": "\n ",
"open": "",
"close": "",
"termination": ""
Expand Down
6 changes: 3 additions & 3 deletions test/syntax/json/maplike.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
],
"readonly": null,
"trivia": {
"type": "\n ",
"base": "\n ",
"open": "",
"close": "",
"termination": ""
Expand Down Expand Up @@ -107,7 +107,7 @@
"trivia": "\n "
},
"trivia": {
"type": " ",
"base": " ",
"open": "",
"close": "",
"termination": ""
Expand Down Expand Up @@ -203,7 +203,7 @@
],
"readonly": null,
"trivia": {
"type": "\n ",
"base": "\n ",
"open": "",
"close": "",
"termination": ""
Expand Down
6 changes: 3 additions & 3 deletions test/syntax/json/setlike.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
"readonly": null,
"trivia": {
"type": "\n ",
"base": "\n ",
"open": "",
"close": "",
"termination": ""
Expand Down Expand Up @@ -71,7 +71,7 @@
"trivia": "\n "
},
"trivia": {
"type": " ",
"base": " ",
"open": "",
"close": "",
"termination": ""
Expand Down Expand Up @@ -132,7 +132,7 @@
],
"readonly": null,
"trivia": {
"type": "\n ",
"base": "\n ",
"open": "",
"close": "",
"termination": ""
Expand Down