Skip to content

Commit 3ac42bb

Browse files
committed
Rewrite Chapter 19
New example (pixel editor rather than big-picture drawing), new architectue (as much componentization and linear data flow as workable).
1 parent 7b28406 commit 3ac42bb

14 files changed

+1129
-989
lines changed

04_data.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,9 @@ expression will produce, with equal chance, any number from 0 through
11431143
{{index "Math.ceil function", "Math.round function"}}
11441144

11451145
There are also the functions `Math.ceil` (for "ceiling", which rounds
1146-
up to a whole number) and `Math.round` (to the nearest whole number).
1146+
up to a whole number), `Math.round` (to the nearest whole number), and
1147+
`Math.abs`, which takes the absolute value of a number, meaning it
1148+
negates negative values but leaves positive ones as they are.
11471149

11481150
## Destructuring
11491151

14_dom.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ quote}}
88

99
# The Document Object Model
1010

11-
// FIXME custom elements, better transitions, maybe `children`, templates, problems with obvious usage
11+
// FIXME better transitions, maybe `children`, fragments, problems with obvious usage
1212

1313
{{index drawing, parsing}}
1414

@@ -161,10 +161,10 @@ numbers to access the child nodes. But it is an instance of the
161161

162162
Then there are issues that are simply poor design. For example, there
163163
is no way to create a new node and immediately add children or
164-
attributes to it. Instead, you have to first create it, then add the
165-
children one by one, and finally set the attributes one by one, using
166-
side effects. Code that interacts heavily with the DOM tends to get
167-
long, repetitive, and ugly.
164+
((attribute))s to it. Instead, you have to first create it, then add
165+
the children one by one, and finally set the attributes one by one,
166+
using side effects. Code that interacts heavily with the DOM tends to
167+
get long, repetitive, and ugly.
168168

169169
{{index library}}
170170

@@ -454,7 +454,7 @@ through a ((property)) of the same name on the element's ((DOM))
454454
object. This is the case for a limited set of commonly used standard
455455
attributes.
456456

457-
{{index "data attribute", "getAttribute method", "setAttribute method"}}
457+
{{index "data attribute", "getAttribute method", "setAttribute method", attribute}}
458458

459459
But HTML allows you to set any attribute you want on nodes. This can
460460
be useful because it allows you to store extra information in a

15_event.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ quote}}
99

1010
{{index stoicism, "Marcus Aurelius", input, timeline, "control flow"}}
1111

12+
// FIXME mention touch event handling
13+
1214
Some programs work with direct user input, such as mouse and keyboard.
1315
That kind of input isn't available as a whole at the start of your
1416
program—it comes in piece by piece, and the program is expected to
@@ -94,6 +96,9 @@ per node that way. The `addEventListener` method allows you to add any
9496
number of handlers, so you won't accidentally replace a handler that
9597
has already been registered.
9698

99+
Handlers for most event types can be attached through attributes like
100+
this, the event name with `on` prefixed.
101+
97102
{{index "removeEventListener method"}}
98103

99104
The `removeEventListener` method, called with arguments similar to as

18_http.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ is replaced by a strange code. Some characters in query strings must
199199
be escaped. The question mark, represented as `%3F`, is one of those.
200200
There seems to be an unwritten rule that every format needs its own
201201
way of escaping characters. This one, called _((URL encoding))_, uses
202-
a ((percent sign)) followed by two hexadecimal digits that encode the
203-
character code. In this case, 3F, which is 63 in decimal notation, is
204-
the code of a question mark character. JavaScript provides the
205-
`encodeURIComponent` and `decodeURIComponent` functions to encode and
206-
decode this format.
202+
a ((percent sign)) followed by two hexadecimal (base 16) digits that
203+
encode the character code. In this case, 3F, which is 63 in decimal
204+
notation, is the code of a question mark character. JavaScript
205+
provides the `encodeURIComponent` and `decodeURIComponent` functions
206+
to encode and decode this format.
207207

208208
```
209209
console.log(encodeURIComponent("Yes?"));

0 commit comments

Comments
 (0)