You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.bs
+9-6Lines changed: 9 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1524,7 +1524,7 @@ the interaction with garbage collection.
1524
1524
1525
1525
<h2 id="api-surface">JavaScript API Surface Concerns</h2>
1526
1526
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>
1528
1528
1529
1529
Web APIs commonly pass around data and functionality using WebIDL. As a specification author, decide carefully whether
1530
1530
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
1563
1563
1564
1564
Dictionaries, because of how they are treated by user agents, are also relatively future-proof; accommodating new members gracefully, without breaking older code.
1565
1565
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`).
1567
1567
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.
1569
1569
This means that if a developer changing the value after it is passed into an API has no effect.
1570
1570
1571
-
Again, taking the `ShareData` dictinary as an example:
1571
+
Again, taking the `ShareData` dictionary as an example:
1572
1572
1573
1573
```JS
1574
1574
const data = {
1575
1575
"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.
1577
1577
"whatever": 123,
1578
1578
};
1579
1579
navigator.share(data);
@@ -1584,7 +1584,10 @@ data.text = "New text";
1584
1584
1585
1585
<h4>Choose an Interface for Functionality, State, and Identity</h4>
1586
1586
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--
0 commit comments