-
Notifications
You must be signed in to change notification settings - Fork 54
Add 'Choose the Appropriate WebIDL Construct for Data and Behavior' #567
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to use <div class=example
more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots more typos to fix throughout, but concentrating on high-level stuff.
@@ -1524,6 +1524,132 @@ the interaction with garbage collection. | |||
|
|||
<h2 id="api-surface">JavaScript API Surface Concerns</h2> | |||
|
|||
<h3>Choose the Appropriate WebIDL Construct for Data and Behavior (Dictionaries, Interfaces, and Namespaces)</h3> | |||
|
|||
Web APIs commonly pass around data and functionality using WebIDL. As a specification author, decide carefully whether |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally go with something more direct for this first paragraph/sentence of each principle.
} | ||
``` | ||
|
||
If the interface can holds data that is useful when serialized (e.g., `GeolocationPosition`), consider adding a `toJSON()` default method. Alternatively, if it holds binary data, one can add .toBlob() an so on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this toJSON() thing something that belongs here? Or is it a distraction?
If warrented by the use cases, give the interface a constructor. Be mindful to not just add a constructor if a class has no state. Doing so is considered by practice by effectively creaeting a fake class. | ||
(see `DOMParser` or `DOMImplementation` as bad examples). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a different principle again?
|
||
Each construct has its own pros and cons, discussed below. | ||
|
||
<h4>Use Dictionaries for “Configuration” or “Input-Only” Data</h4> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later sections use something like this:
<h4 id="static-objects" class="no-num no-toc">Static objects</h4>
Consider following that example.
Is this meant to close #11? |
Co-authored-by: Martin Thomson <[email protected]>
f982070
to
d27fcae
Compare
Initial text to picking the right thing...
Preview | Diff