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
@@ -1525,7 +1525,7 @@ the interaction with garbage collection.
1525
1525
1526
1526
<h2 id="api-surface">JavaScript API Surface Concerns</h2>
1527
1527
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>
1529
1529
1530
1530
Web APIs commonly pass around data and functionality using WebIDL. As a specification author, decide carefully whether
1531
1531
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
1564
1564
1565
1565
Dictionaries, because of how they are treated by user agents, are also relatively future-proof; accommodating new members gracefully, without breaking older code.
1566
1566
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`).
1568
1568
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.
1570
1570
This means that if a developer changing the value after it is passed into an API has no effect.
1571
1571
1572
-
Again, taking the `ShareData` dictinary as an example:
1572
+
Again, taking the `ShareData` dictionary as an example:
1573
1573
1574
1574
```JS
1575
1575
const data = {
1576
1576
"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.
1578
1578
"whatever": 123,
1579
1579
};
1580
1580
navigator.share(data);
@@ -1585,7 +1585,10 @@ data.text = "New text";
1585
1585
1586
1586
<h4>Choose an Interface for Functionality, State, and Identity</h4>
1587
1587
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--
0 commit comments