Skip to content
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

feat(core/webidl): handle multi-type generics #1298

Merged
merged 1 commit into from Jun 23, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/core/webidl.js
Expand Up @@ -263,9 +263,8 @@ function idlType2Text(idlType) {
);
}
if (idlType.generic) {
return (
idlType.generic + "<" + idlType2Text(idlType.idlType) + ">" + nullable
);
const types = [].concat(idlType.idlType).map(idlType2Text).join(", ");
return `${idlType.generic}<${types}>${nullable}`;
}
return idlType2Text(idlType.idlType) + nullable;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/spec/core/webidl-spec.js
Expand Up @@ -16,6 +16,16 @@ describe("Core - WebIDL", function() {
).then(done);
});

it("handles record types", done => {
const idl = doc.querySelector("#records pre");
expect(idl).toBeTruthy(idl);
expect(idl.querySelector(".idlMemberType:first-child").textContent).toEqual(
"record<DOMString, USVString>"
);
expect(idl.querySelector(".idlMemberName").textContent).toEqual("pass");
done();
});

it("links standardized IDL types to WebIDL spec", done => {
const idl = doc.querySelector("#linkToIDLSpec>div>pre");
// [Constructor(sequence<DOMString> methodData), SecureContext]
Expand Down
16 changes: 12 additions & 4 deletions tests/spec/core/webidl.html
Expand Up @@ -21,7 +21,7 @@
<body>
<section data-dfn-for="ExampleInterface" data-link-for="ExampleInterface">
<h2><dfn>ExampleInterface</dfn> interface</h2>
<pre class="idl">
<pre class="idl no-link-warnings">
interface ExampleInterface {
void exampleMethod();
readonly attribute USVString url;
Expand Down Expand Up @@ -50,9 +50,17 @@ <h2>Here is how you link!</h2>
CUSTOM PARAGRAPH
</p>
</section>
<section id="records">
<h2>Testing records</h2>
<pre class="idl no-link-warnings">
dictionary Foo {
record&lt;DOMString, USVString> pass;
};
</pre>
</section>
<section id="linkToIDLSpec">
<h2>Linking to WebIDL spec</h2>
<pre class="idl">
<pre class="idl no-link-warnings">
[Constructor(sequence&lt;DOMString> methodData), SecureContext]
interface LinkingTest {
readonly attribute DOMString? aBoolAttribute;
Expand All @@ -62,7 +70,7 @@ <h2>Linking to WebIDL spec</h2>
</section>
<section id="sec-parenthesis-method" data-dfn-for="ParenthesisTest" data-link-for="ParenthesisTest">
<h2>More linking</h2>
<pre class="idl">
<pre class="idl no-link-warnings">
interface ParenthesisTest {
void basic();
void noParens();
Expand Down Expand Up @@ -441,7 +449,7 @@ <h2>Enumerations</h2>
<p link-for="EnumBasic"><a>one</a> is referenced with a <code>[link-for]</code> attribute.</p>
<p id="enum-ref-without-link-for"><a>EnumBasic.one</a> may also be referenced with fully-qualified name.</p>
<section id="enum-empty-sec" data-dfn-for="EmptyEnum">
<pre class="idl">
<pre class="idl no-link-warnings">
enum EmptyEnum {
"",
"not empty"
Expand Down