@@ -391,8 +391,7 @@ Your `module.exports` statement should now look something like this:
391
391
if (typeof module !== ' undefined' && module .exports ) {
392
392
module .exports = {
393
393
empty: empty,
394
- mount: mount,
395
- init: init
394
+ mount: mount
396
395
}
397
396
} else { init (document ); }
398
397
```
@@ -455,10 +454,10 @@ _Don't worry, we will walk through building each feature in detail._
455
454
456
455
A todo list has only 2 _ basic_ functions:
457
456
458
- 1 . ** Add** a ` new ` item to the list when the ** ` [Enter] ` ** key is pressed
457
+ 1 . ** Add** a ` new ` item to the list ( when the ** ` [Enter] ` ** key is pressed)
459
458
2 . ** Check-off** an item as "** completed** " (_ done/finished_ )
460
459
461
- > ** Add** item and ** Check-off** is _ exactly_ the "functionality"
460
+ > ** Add** item and " ** Check-off** " is _ exactly_ the "functionality"
462
461
you would have in a _ paper_ -based Todo List.
463
462
464
463
#### TodoMVC "Advanced" Functionality
@@ -554,6 +553,8 @@ This is a "copy-paste" of the _generated_ code including the Todo items:
554
553
Let's split each one of these elements into it's own ` function `
555
554
(_ with any necessary "helpers"_ ) in the order they appear.
556
555
556
+ > For a "checklist" of these features see: https://github.com/dwyl/learn-elm-architecture-in-javascript/issues/44
557
+
557
558
When building a House we don't think "build house" as our _ first_ action. <br />
558
559
_ Instead_ we think: what are the "foundations" that need to be in place
559
560
*** before*** we lay the _ first_ "brick"?
@@ -665,7 +666,7 @@ take a moment to think of how _you_ would write
665
666
the ` add_attributes ` function to apply a CSS ` class ` to an element. <br />
666
667
667
668
If you can, make the test _ pass_
668
- by writing the ` add_attributes ` function.
669
+ by writing the ` add_attributes ` function. < br />
669
670
(_ don't forget to_ ` export ` _ the function at the bottom of the file_ ).
670
671
671
672
If you get "stuck", checkout the _ complete_ example:
@@ -681,7 +682,6 @@ the whole point of having a step-by-step tutorial
681
682
is that you can check if you get "stuck",
682
683
but you should only check _ after_ making
683
684
a good attempt to write the code _ yourself_ .
684
- <br />
685
685
686
686
> ** Note 2** : The ` add_attributes ` function is "impure" as it "mutates"
687
687
the target DOM ` node ` , this is more of a "fact of life" in JavaScript,
@@ -705,7 +705,7 @@ Once you make the test _pass_ you _should_ see the following in your Terminal:
705
705
706
706
The ` <input> ` form element (_ where we create new Todo List items_ )
707
707
has a helpful ` placeholder ` attribute _ prompting_ us with a question:
708
- "*** What needs to be done?*** "
708
+ "_ What needs to be done?_ "
709
709
710
710
Add the following test to the ` test/elmish.test.js ` file: <br />
711
711
@@ -798,7 +798,7 @@ we will _know_ that the `switch` is "_incomplete_". <br />
798
798
and not having to"debate" or "discuss" the "merits" of it means
799
799
we can have _ confidence_ in the code.
800
800
801
- #### Test ` null ` Attribute Value in ` add_attributes ` Function
801
+ #### Test ` null ` Attribute Argument ( ` attrlist ` ) in ` add_attributes ` Function
802
802
803
803
Since JavaScript is _ not_ statically/strictly typed we need to _ consider_
804
804
the situation where someone might _ accidentally_ pass a ` null ` value.
@@ -867,6 +867,9 @@ In your `package.json` file add:
867
867
Now whenever you ` commit ` your code, your tests will run
868
868
and ` istanbul ` will check the test coverage level for you.
869
869
870
+ Let's get back to our ` add_attributes ` function!
871
+
872
+ <br />
870
873
871
874
#### Input ` autofocus `
872
875
@@ -894,7 +897,8 @@ test.only('elmish.add_attributes add "autofocus" attribute', function (t) {
894
897
});
895
898
```
896
899
897
- Write the necessary code to make this test _ pass_ in ` elmish.js ` .
900
+ Write the necessary code to make this test _ pass_
901
+ as a ` case ` in ` add_attributes ` in ` elmish.js ` .
898
902
899
903
Relevant reading:
900
904
+ ` <input> ` attributes:
@@ -973,6 +977,7 @@ test.only('elmish.add_attributes set "for" attribute <label> element', function
973
977
Add the "` case ` " in the ` add_attributes ` function's ` switch ` statement
974
978
to make this test _ pass_ in ` elmish.js ` .
975
979
980
+ <br />
976
981
977
982
#### ` <input> ` attribute ` type `
978
983
@@ -993,11 +998,13 @@ test('elmish.add_attributes type="checkbox" on <input> element', function (t) {
993
998
});
994
999
```
995
1000
996
- Write the "case" in to make this test _ pass_ in ` elmish.js ` .
1001
+ Write the "case" in ` add_attributes ` to make this test _ pass_ in ` elmish.js ` .
997
1002
998
- ` <input> ` attribute ` type ` :
1003
+ Relevant reading
1004
+ + ` <input> ` attribute ` type ` :
999
1005
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes
1000
1006
1007
+ <br />
1001
1008
1002
1009
#### Add ` style ` attribute to HTML element?
1003
1010
@@ -1035,8 +1042,9 @@ test.only('elmish.add_attributes apply style="display: block;"', function (t) {
1035
1042
Write the "case" in to make this test _ pass_ in ` elmish.js ` .
1036
1043
1037
1044
If you get "stuck", checkout:
1038
- https://github.com/dwyl/learn-elm-architecture-in-javascript/tree/master/examples/todo-list/elmish.js < br />
1045
+ https://github.com/dwyl/learn-elm-architecture-in-javascript/tree/master/examples/todo-list/elmish.js
1039
1046
1047
+ <br />
1040
1048
1041
1049
#### ` checked=true ` attribute for "complete"/"done" items
1042
1050
@@ -1073,6 +1081,8 @@ and is **more intention revealing** to maintainers._"
1073
1081
For more detail on the ` <input type="checkbox"> `
1074
1082
see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox
1075
1083
1084
+ <br />
1085
+
1076
1086
#### Set ` href ` on ` <a> ` (anchor) element
1077
1087
1078
1088
The "filters" in the ` <footer> ` of TodoMVC contain 3 links ("anchors") ` <a> `
@@ -1111,6 +1121,7 @@ Useful knowledge:
1111
1121
+ Why: https://stackoverflow.com/questions/4855168/what-is-href-and-why-is-it-used
1112
1122
+ How: https://stackoverflow.com/questions/4689344/how-can-i-add-href-attribute-to-a-link-dynamically-using-javascript
1113
1123
1124
+ <br />
1114
1125
1115
1126
### ` append_childnodes `
1116
1127
@@ -1567,7 +1578,7 @@ Consider the following JSDOC for the `route` function:
1567
1578
1568
1579
#### ` route ` _ Test_ !
1569
1580
1570
- Add the following _ test_ to your ` test/elmish.test.js ` file: <br />:
1581
+ Add the following _ test_ to your ` test/elmish.test.js ` file: <br />
1571
1582
1572
1583
``` js
1573
1584
test .only (' elmish.route updates the url hash and sets history' , function (t ) {
@@ -1596,7 +1607,7 @@ test.only('elmish.route updates the url hash and sets history', function (t) {
1596
1607
#### ` route ` Implementation (_ to make test(s) pass_ )
1597
1608
1598
1609
The code to make these tests pass is only 3 or 4 lines.
1599
- (_ depending on your implementation ..._ )
1610
+ (_ depending on your implementation ..._ ) < br />
1600
1611
Provided the tests pass and you haven't "hard coded" the ` return ` ,
1601
1612
there is no "wrong answer".
1602
1613
Try and figure it out for yourself before checking a solution.
@@ -1781,8 +1792,14 @@ to make the test pass.
1781
1792
refer to the completed code:
1782
1793
[ /examples/todo-list/elmish.js] ( https://github.com/dwyl/learn-elm-architecture-in-javascript/tree/master/examples/todo-list/elmish.js )
1783
1794
1795
+ <br />
1796
+
1797
+ That's it for now! ` Elm ` (_ ish_ ) is "ready" to be _ used_
1798
+ for our TodoMVC App!
1799
+
1800
+ <br />
1784
1801
1785
- ### Why _ Not_ use HTML5 ` <template> `
1802
+ ### Why _ Not_ use HTML5 ` <template> ` ??
1786
1803
1787
1804
Templates are an _ awesome_ feature in HTML5 which
1788
1805
allow the creation of reusable markup!
0 commit comments