Skip to content

Commit f982070

Browse files
Apply suggestions from code review
Co-authored-by: Martin Thomson <[email protected]>
1 parent a0b55df commit f982070

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

index.bs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,7 +1524,7 @@ the interaction with garbage collection.
15241524

15251525
<h2 id="api-surface">JavaScript API Surface Concerns</h2>
15261526

1527-
<h3>Choose the Appropriate WebIDL Construct for Data and Behavior (Dictionaries, Interfaces, and Namespaces)</h3>
1527+
<h3>Use WebIDL dictionaries, interfaces, and namespaces appropriately</h3>
15281528

15291529
Web APIs commonly pass around data and functionality using WebIDL. As a specification author, decide carefully whether
15301530
to use a dictionary, an interface, or in rare cases, a namespace.
@@ -1563,17 +1563,17 @@ Dictionaries are also highly idiomatic (i.e., natural to use in JavaScript). Pas
15631563

15641564
Dictionaries, because of how they are treated by user agents, are also relatively future-proof; accommodating new members gracefully, without breaking older code.
15651565

1566-
Dictionaries are best used for objects that don't need to be distigusied by type in their lifecycle (i.e., `instanceof` checks are mostly meaningless because it's always `Object`).
1566+
Dictionaries are best used for objects that don't need to be distinguished by type in their lifecycle (i.e., `instanceof` checks are mostly meaningless because it's always `Object`).
15671567

1568-
A key thing to know about dictionries is that they are "passed by value" to methods (i.e., they are copied) and that browsers engines strip unknown members when converting from JavaScript objects to a WebIDL reprensentation.
1568+
A key thing to know about dictionaries is that they are "passed by value" to methods (i.e., they are copied) and that browsers engines strip unknown members when converting from JavaScript objects to a WebIDL representation.
15691569
This means that if a developer changing the value after it is passed into an API has no effect.
15701570

1571-
Again, taking the `ShareData` dictinary as an example:
1571+
Again, taking the `ShareData` dictionary as an example:
15721572

15731573
```JS
15741574
const data = {
15751575
"text": "Text being shared",
1576-
// Not in the dictionary, so removed by the browser
1576+
// Ignored by a browser that does not include a "whatever" parameter.
15771577
"whatever": 123,
15781578
};
15791579
navigator.share(data);
@@ -1584,7 +1584,10 @@ data.text = "New text";
15841584

15851585
<h4>Choose an Interface for Functionality, State, and Identity</h4>
15861586

1587-
Intefaces are roughly equivalent to classes in JavaScript. Choose and an interface when a specificaiton need object with data that might also have — or eventually gain — methods, computed or readonly properties, or internal state or "slots".
1587+
Intefaces are roughly equivalent to classes in JavaScript.
1588+
Use an interface when a specification needs to bundle state--
1589+
both visible properties and internal "slots"--
1590+
with operations on that state (i.e., methods).
15881591

15891592
Unlike dictrionaries, interfaces:
15901593

0 commit comments

Comments
 (0)