Skip to content

Commit d27fcae

Browse files
marcoscaceresmartinthomson
authored andcommitted
Apply suggestions from code review
Co-authored-by: Martin Thomson <[email protected]>
1 parent 40aea01 commit d27fcae

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
@@ -1525,7 +1525,7 @@ the interaction with garbage collection.
15251525

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

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

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

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

1567-
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`).
1567+
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`).
15681568

1569-
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.
1569+
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.
15701570
This means that if a developer changing the value after it is passed into an API has no effect.
15711571

1572-
Again, taking the `ShareData` dictinary as an example:
1572+
Again, taking the `ShareData` dictionary as an example:
15731573

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

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

1588-
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".
1588+
Intefaces are roughly equivalent to classes in JavaScript.
1589+
Use an interface when a specification needs to bundle state--
1590+
both visible properties and internal "slots"--
1591+
with operations on that state (i.e., methods).
15891592

15901593
Unlike dictrionaries, interfaces:
15911594

0 commit comments

Comments
 (0)