dothtml 4.8.5 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/{jest.config.js → jest.config.ts} +19 -16
  2. package/lib/arg-callback-obj.d.ts +29 -0
  3. package/lib/built-in-components/nav-link.d.ts +8 -0
  4. package/lib/built-in-components/router.d.ts +57 -0
  5. package/lib/component.d.ts +73 -0
  6. package/lib/dot-component-legacy.d.ts +0 -0
  7. package/lib/dot-document.d.ts +0 -0
  8. package/lib/dot-util.d.ts +13 -0
  9. package/lib/dot.d.ts +5 -0
  10. package/lib/dothtml.d.ts +21 -0
  11. package/lib/dothtml.js +2 -0
  12. package/lib/dothtml.js.LICENSE.txt +1 -0
  13. package/lib/err.d.ts +2 -0
  14. package/lib/event-bus.d.ts +10 -0
  15. package/lib/i-dot.d.ts +674 -0
  16. package/lib/i-dotcss.d.ts +827 -0
  17. package/lib/node-polyfill.d.ts +2 -0
  18. package/lib/observable-array.d.ts +49 -0
  19. package/lib/style-builder.d.ts +3 -0
  20. package/package.json +11 -5
  21. package/readme.md +3 -2
  22. package/src/{arg-callback-obj.js → arg-callback-obj.ts} +18 -6
  23. package/src/built-in-components/nav-link.ts +21 -0
  24. package/src/built-in-components/router.ts +315 -0
  25. package/src/component.ts +369 -0
  26. package/src/dot-component-legacy.ts +79 -0
  27. package/src/dot-document.ts +0 -0
  28. package/src/dot-util.ts +33 -0
  29. package/src/dot.ts +1147 -0
  30. package/src/dothtml.ts +33 -0
  31. package/src/err.ts +22 -0
  32. package/src/event-bus.ts +39 -0
  33. package/src/i-dot.ts +787 -0
  34. package/src/i-dotcss.ts +918 -0
  35. package/src/node-polyfill.ts +11 -0
  36. package/src/{observable-array.js → observable-array.ts} +10 -5
  37. package/src/{style-builder.js → style-builder.ts} +219 -183
  38. package/tsconfig.json +99 -0
  39. package/unittests/advanced-bindings.test.ts +421 -0
  40. package/unittests/{array-evaluation.test.js → array-evaluation.test.ts} +1 -1
  41. package/unittests/{basic-functionality.test.js → basic-functionality.test.ts} +14 -10
  42. package/unittests/class-binding.test.ts +227 -0
  43. package/unittests/component-decorator.-.ts +14 -0
  44. package/unittests/components-data.test.ts +153 -0
  45. package/unittests/components.test.ts +257 -0
  46. package/unittests/computed.test.ts +35 -0
  47. package/unittests/{core.js → core.ts} +5 -2
  48. package/unittests/element-and-attribute-coverage.test.ts +472 -0
  49. package/unittests/hooks.test.ts +67 -0
  50. package/unittests/immutable-if.test.ts +19 -0
  51. package/unittests/input-bindings.test.ts +166 -0
  52. package/unittests/integration.test.ts +5 -0
  53. package/unittests/{iterations.test.js → iterations.test.ts} +5 -5
  54. package/unittests/logic.test.ts +18 -0
  55. package/unittests/refs.test.ts +36 -0
  56. package/unittests/routing.-.ts +56 -0
  57. package/unittests/{scopes.test.js → scopes.test.ts} +5 -5
  58. package/unittests/special-tags.test.ts +39 -0
  59. package/unittests/styles.test.ts +9 -0
  60. package/unittests/{testpage.js → testpage.ts} +2 -0
  61. package/unittests/{wait.test.js → wait.test.ts} +8 -5
  62. package/webpack.config.js +13 -1
  63. package/lib/dothtml.min.js +0 -1
  64. package/src/component.js +0 -305
  65. package/src/err.js +0 -20
  66. package/src/event-bus.js +0 -40
  67. package/src/index.js +0 -1453
  68. package/src/util.js +0 -13
  69. package/unittests/advanced-bindings.test.js +0 -386
  70. package/unittests/class-binding.test.js +0 -53
  71. package/unittests/components-data.test.js +0 -97
  72. package/unittests/components.test.js +0 -151
  73. package/unittests/computed.test.js +0 -36
  74. package/unittests/hooks.test.js +0 -57
  75. package/unittests/immutable-if.test.js +0 -15
  76. package/unittests/input-bindings.test.js +0 -155
  77. package/unittests/integration.test.js +0 -6
  78. package/unittests/logic.test.js +0 -18
  79. package/unittests/routing.-.js +0 -56
  80. package/unittests/special-tags.test.js +0 -32
@@ -1,151 +0,0 @@
1
- import addTest from "./core";
2
- import dot from "../src/index";
3
-
4
- try{
5
-
6
- dot.component({name: "comp_legacy", builder: function(){return dot.div(dot.div(1))}});
7
- dot.component({name: "comp_std", builder: function(){return dot.div(dot.div(1))}});
8
- dot.component({name: "comp_ready", builder: function(){return dot.div(dot.div(1))}, ready: function(){this.$el.innerHTML = "OKAY"}});
9
- dot.component({name: "comp_text", builder: function(){return "1"}});
10
- dot.component({name: "comp_textreplace", builder: function(){return "1"}, ready: function(){this.$el.parentNode.insertBefore(document.createTextNode("2"), this.$el.nextSibling);this.$el.parentNode.removeChild(this.$el);}});
11
-
12
- // Testing $el
13
- dot.component({name: "comp_el_undefined_el", builder: function(){}});
14
- dot.component({name: "comp_el_zero_el", builder: function(){return dot}});
15
- dot.component({name: "comp_el_one_el", builder: function(){return dot.div("abc")}});
16
- dot.component({name: "comp_el_two_el", builder: function(){return dot.div("abc").div("abc")}});
17
- dot.component({name: "comp_el_deferred_el", builder: function(){return dot.div("abc").wait(function(){}, 1000)}});
18
- dot.component({name: "comp_el_text_zero_el", builder: function(){return "abc"}});
19
- dot.component({name: "comp_el_text_one_el", builder: function(){return "<div>abc</div>"}});
20
- dot.component({name: "comp_el_text_two_el", builder: function(){return "<div>abc</div><div>123</div>"}});
21
-
22
- // Testing methods:
23
- // TODO: passing callMethod in like this will soon be deprecated.
24
- dot.component({
25
- name: "comp_methods_basic",
26
- builder: function(callMethod){ this.callMethod = callMethod; return dot.div("123");},
27
- ready: function(){if(this.callMethod) this.setVal("abc");},
28
- methods: { setVal: function(val){ dot(this.$el).empty().t(val); } }
29
- });
30
-
31
- // Scoped classes
32
- dot.resetScopeClass();
33
- dot.component({
34
- name: "comp_scoped_class",
35
- builder: function(){ return dot.div(dot.div().class("test2")).class("test1") }
36
- });
37
- dot.component({
38
- name: "comp_scoped_class_2",
39
- builder: function(){ return dot.div(dot.div().class("test2")).class("test1") }
40
- });
41
-
42
- }catch(e){ console.error(e);}
43
-
44
- // Nameless components (exports):
45
- addTest("Nameless component.", function(){ var comp = dot.component({builder: function(c){return dot.p(c)} }); return dot.div(comp(":)")) }, "<div><p>:)</p></div>");
46
- // This behavior was deprecated.
47
- //addTest("Nameless component as a dot function.", function(){ var comp = dot.component({builder: function(c){return dot.p(c)} }); return comp(":)") }, "<p>:)</p>" );
48
-
49
- // Named components (extend dot):
50
- addTest("Std params component.", function(){return dot.comp_std()}, "<div><div>1</div></div>");
51
- addTest("Std params component, nested.", function(){return dot.div(2).comp_std().div(3)}, "<div>2</div><div><div>1</div></div><div>3</div>");
52
- addTest("Std prams component beside markup.", function(){return dot.h(2).comp_std().h(3)}, "2<div><div>1</div></div>3");
53
- addTest("Legacy params component.", function(){return dot.comp_legacy()}, "<div><div>1</div></div>");
54
- addTest("Component w/ ready method.", function(){return dot.comp_ready()}, "<div>OKAY</div>");
55
- addTest("Text component.", function(){return dot.h("a").comp_text().h("b")}, "a1b");
56
- addTest("Text component w/ ready method.", function(){return dot.h("a").comp_textreplace().h("b")}, "a2b");
57
-
58
- // $el
59
- addTest("Undefined $el.", function(){try{return dot.comp_el_undefined_el()}catch(e){return dot.span(e)}}, "<span>Component 'comp_el_undefined_el' must return exactly one child node.</span>");
60
- addTest("Zero $el.", function(){try{return dot.comp_el_zero_el()}catch(e){return dot.span(e)}}, "<span>Component 'comp_el_zero_el' must return exactly one child node.</span>");
61
- addTest("One $el.", function(){return dot.comp_el_one_el()}, "<div>abc</div>");
62
- addTest("Two $el.", function(){try{return dot.comp_el_two_el()}catch(e){return dot.span(e)}}, "<span>Component 'comp_el_two_el' must return exactly one child node.</span>");
63
- addTest("Deferred $el.", function(){try{return dot.comp_el_deferred_el()}catch(e){return dot.span(e)}}, "<span>Component 'comp_el_deferred_el' must return exactly one child node.</span>");
64
- addTest("One $el.", function(){return dot.comp_el_text_zero_el()}, "abc");
65
- addTest("One $el.", function(){return dot.comp_el_text_one_el()}, "<div>abc</div>");
66
- addTest("Undefined $el.", function(){try{return dot.comp_el_text_two_el()}catch(e){return dot.span(e)}}, "<span>Component 'comp_el_text_two_el' must return exactly one child node.</span>");
67
-
68
- // methods
69
- addTest("Instantiate comp w/ method.", function(){return dot.comp_methods_basic()}, "<div>123</div>");
70
- addTest("Method gets called in ready function.", function(){return dot.comp_methods_basic(true)}, "<div>abc</div>"); // TODO: this functionality will soon be removed in favor of params.
71
-
72
-
73
- // TODO: setup this test and get it working.
74
- // addTest("Computed property w/ updated dependency.", function(){
75
- // let comp = dot.component({
76
- // builder: function(firstName,lastName){this.firstName = firstName; this.lastName = lastName; return dot.p(this.fullName.toUpperCase())},
77
- // computed: {
78
- // fullName: function(){
79
- // console.log("GETTING COMPUTED PROP!");
80
- // return this.firstName + " " + this.lastName;
81
- // }
82
- // }
83
- // });
84
- // return dot.h(comp("J","S"));
85
- // },"<p>J S</p>");
86
-
87
-
88
- // Events // TODO: get these working.
89
- // addTest(
90
- // "Named events work.",
91
- // function(){
92
- // let comp = dot.component({
93
- // builder: function(a,b){this.a = a; this.b = b; return dot.p(a+b)},
94
- // events: ["sumReady"],
95
- // methods: {trigger: function(){this.sumReady(this.a+this.b);}},
96
- // });
97
- // let sumResult = 0;
98
- // let c = comp(1,2).sumReady(function(v){ console.log("CALLING EVENT!!");sumResult = v});
99
- // c.trigger();
100
- // return dot.p(sumResult);
101
- // },
102
- // "<p>3</p>"
103
- // );
104
-
105
- // Scoped classes
106
- // TODO: the tests work in browser, but seem to happen out of order in jest...
107
- // addTest("Component class scope.", function(){return dot.comp_scoped_class()}, "<div class=\"dot-10000-test1\"><div class=\"dot-10000-test2\"></div></div>");
108
- // addTest("Component class scope reuse.", function(){return dot.comp_scoped_class()}, "<div class=\"dot-10000-test1\"><div class=\"dot-10000-test2\"></div></div>");
109
- // addTest("Component class scope alt.", function(){return dot.comp_scoped_class_2()}, "<div class=\"dot-10001-test1\"><div class=\"dot-10001-test2\"></div></div>");
110
-
111
- // Styles
112
- addTest("Set style directly", function(){var ret = dot.p(":)").style("width:100px;"); return ret;}, "<p style=\"width:100px;\">:)</p>");
113
- addTest("Set style via dotcss", function(){var ret = dot.p(":)").style(dot.css.width(100)); return ret;}, "<p style=\"width:100px;\">:)</p>");
114
- addTest("Styled component.", function(){ var comp = dot.component({builder: function(c){return dot.p(c)}, style: function(css){css("p").width(100);} }); return dot.h(comp(":)")) }, "<p style=\"width: 100px;\">:)</p>" );
115
- addTest("Advanced styled component.", function(){ var comp = dot.component({builder: function(c){return dot.p(c)}, style: function(css){css("p").width(100);} }); return dot.h(comp(":)")).h(comp(":)")) }, "<p style=\"width: 100px;\">:)</p><p style=\"width: 100px;\">:)</p>" );
116
- addTest("Component with multiple styles.", function(){ var comp = dot.component({builder: function(c, w){ this.w = w; return dot.p(c)}, style: function(css){css("p").width(this.w);} }); return dot.h(comp(":)", 200)).h(comp(":)", 300)) }, "<p style=\"width: 200px;\">:)</p><p style=\"width: 300px;\">:)</p>" );
117
- addTest("Component with class styles.", function(){ var comp = dot.component({builder: function(c, w,h){ this.w = w; this.h = h; return dot.div(dot.div(c).div("w").class("w").div("ok").class("h")).class("w")}, style: function(css){css(".w").width(this.w);css(".h").width(this.h);} }); return dot.h(comp(":)", 200, 400)).h(comp(":)", 300, 500)).div().class("h") }, "<div class=\"w\" style=\"width: 200px;\"><div>:)</div><div class=\"w\" style=\"width: 200px;\">w</div><div class=\"h\" style=\"width: 400px;\">ok</div></div><div class=\"w\" style=\"width: 300px;\"><div>:)</div><div class=\"w\" style=\"width: 300px;\">w</div><div class=\"h\" style=\"width: 500px;\">ok</div></div><div class=h></div>" );
118
-
119
- addTest("Styles should not apply to nested elements.", function(){
120
- var CompOuter = dot.component({
121
- builder(inner){return dot.div(inner);},
122
- style(css){
123
- css("div").backgroundColor("#FF0000");
124
- }
125
- });
126
-
127
- var CompInner = dot.component({
128
- builder(){return dot.div("FOOBAR");}
129
- });
130
-
131
- return dot.h(new CompOuter(new CompInner()))
132
- }, "<div style=\"background-color: rgb(255, 0, 0);\"><div>FOOBAR</div></div>");
133
-
134
- addTest("Styles should not apply to nested elements 2.", function(){
135
- var CompOuter = dot.component({
136
- builder(inner){return dot.div(inner);},
137
- style(css){
138
- css("div").backgroundColor("#FF0000");
139
- }
140
- });
141
-
142
- var CompInner = dot.component({
143
- builder(){return dot.div(dot.div("FOOBAR"));}
144
- });
145
-
146
- return dot.h(new CompOuter(new CompInner()))
147
- }, "<div style=\"background-color: rgb(255, 0, 0);\"><div><div>FOOBAR</div></div></div>");
148
-
149
- // Event Bus
150
-
151
- addTest("Event bus basic usage.", function(){var comp1 = dot.component({builder: function(){var t = this; dot.bus.on("change", function(v){t.$el.innerHTML = v}); return dot.p()} }); var ret = dot.h(comp1()); dot.bus.emit("change", "hello"); return ret; }, "<p>hello</p>");
@@ -1,36 +0,0 @@
1
- import addTest from "./core";
2
- import dot from "../src/index";
3
-
4
- addTest("Computed property.", function(){
5
- let comp = dot.component({
6
- builder: function(firstName,lastName){
7
- this.firstName = firstName;
8
- this.lastName = lastName;
9
- return dot.p(this.fullName.toUpperCase())},
10
- computed: {
11
- fullName(){
12
- return (this.firstName||"notset") + " " + (this.lastName||"notset");
13
- }
14
- }
15
- });
16
- return dot.h(comp("J","S")).h(comp("1","2"));
17
- },"<p>J S</p><p>1 2</p>");
18
-
19
- addTest("Computed property w/ prop dependency.", function(){
20
- var comp = dot.component({
21
- builder: function(){
22
- return dot.p(()=>this.fullName.toUpperCase())
23
- },
24
- props: ["firstName", "lastName"],
25
- computed: {
26
- fullName(){
27
- return (this.firstName||"notset") + " " + (this.lastName||"notset");
28
- }
29
- }
30
- });
31
- var instance = comp();
32
- var ret = dot.h(instance);
33
- instance.firstName = "j";
34
- instance.lastName = "s";
35
- return ret;
36
- },"<p>J S</p>");
@@ -1,57 +0,0 @@
1
- import addTest from "./core";
2
- import dot from "../src/index";
3
-
4
- try{
5
- // Testing hooks:
6
- dot.component({
7
- name: "comp_hooks_register",
8
- register: function(){ this.x = (this.x || 0); this.add1(); },
9
- builder: function(add1){ if(add1)this.add1(); return dot.div(this.x) },
10
- methods: { add1: function(){ this.x++ } }
11
- });
12
-
13
- dot.component({
14
- name: "comp_hooks_create",
15
- created: function(val){ this.myEl = this.$el; this.testVal = val },
16
- builder: function(){ return dot.div("val: " + this.testVal + ", hadEl: " + (this.myEl ? "yes" : "no")) }
17
- });
18
-
19
- dot.component({
20
- name: "comp_hooks_delete",
21
- created: function(deleteMe, addEarlyMessage, addLateMessage, messageInSibling){
22
- this.deleteMe = deleteMe;
23
- this.addEarlyMessage = addEarlyMessage;
24
- this.addLateMessage = addLateMessage;
25
- this.messageInSibling = messageInSibling;
26
- },
27
- builder: function(){ return dot.span("not deleted"); },
28
- ready: function(){ this.parent = this.messageInSibling ? this.$el.parentNode.nextSibling : this.$el.parentNode; if(this.deleteMe) dot(this.parent).empty(); },
29
- deleting: function(){ if(this.addEarlyMessage) dot(this.messageInSibling ? this.$el.parentNode.nextSibling : this.$el.parentNode ).p("deleted"); },
30
- deleted: function(){ if(this.addLateMessage) dot(this.parent).b(this.$el ? "failure" : "success"); },
31
- });
32
- }
33
- catch(e){console.error(e);}
34
- // register
35
- addTest("Register hook gets called once.", function(){return dot.comp_hooks_register()}, "<div>1</div>");
36
- addTest("Register hook gets called only once.", function(){return dot.comp_hooks_register()}, "<div>1</div>");
37
- addTest("Prototype vars set by register cook can be updated.", function(){return dot.comp_hooks_register(true)}, "<div>2</div>");
38
- addTest("Prototype vars are cloned from prototype.", function(){return dot.comp_hooks_register()}, "<div>1</div>"); // Kind of a weird javascript behavior. Cool though.
39
-
40
- // create
41
- addTest("Created hook.", function(){return dot.comp_hooks_create("abc");}, "<div>val: abc, hadEl: no</div>");
42
-
43
- // delete
44
- addTest("Delete hook doesn't get called right away.", function(){return dot.div(dot.comp_hooks_delete());}, "<div><span>not deleted</span></div>");
45
- addTest("Deleting hook.", function(){return dot.div(dot.comp_hooks_delete(true, true));}, "<div><p>deleted</p></div>");
46
- addTest("Deleted hook.", function(){return dot.div(dot.comp_hooks_delete(true, false, true));}, "<div><b>success</b></div>");
47
-
48
- //Ensure deletion happens for inner components when using remove.
49
- addTest("Nested deleting via remove().", function(){ return dot.h(function(){ var ret = dot.i().div(
50
- dot.comp_hooks_delete(false, true, false, true)
51
- ); var del = ret.getLast();
52
- ret = ret.b(); setTimeout(function(){dot(del).remove() }, 0); return ret; }) }, "<i></i><b><p>deleted</p></b>");
53
-
54
- addTest("Nested deleted via remove().", function(){ return dot.h(function(){ var ret = dot.i().div(
55
- dot.comp_hooks_delete(false, false, true, true)
56
- ); var del = ret.getLast();
57
- ret = ret.b(); setTimeout(function(){dot(del).remove() }, 0); return ret; }) }, "<i></i><b><b>success</b></b>");
@@ -1,15 +0,0 @@
1
- import addTest from "./core";
2
- import dot from "../src/index";
3
-
4
- addTest("Conditional true.", function(){ return dot.h(1).IF(true, dot.h("true")).h(2); }, "1true2");
5
- addTest("Conditional false.", function(){ return dot.h(1).IF(false, dot.h("false")).h(2); }, "12");
6
- addTest("Conditional true true.", function(){ return dot.h(1).IF(true, dot.h(2)).IF(true, dot.h(3)).h(4); }, "1234");
7
- addTest("Conditional class.", function(){ return dot.div(1).IF(true, dot["class"](2)); }, "<div class=\"2\">1</div>");
8
- //Not sure if the following two cases should be supported. They are broken as of 1.3.0, but I don't know if that matters.
9
- //addTest("Conditional deep class.", function(){ return dot.div(1).IF(true, dot.IF(true, dot["class"](2))); }, "<div class=\"2\">1</div>");
10
- //addTest("Conditional deep class with more confusion.", function(){ return dot.div(1).IF(true, dot.IF(true, dot["class"](2)).div(3)); }, "<div class=\"2\">1</div><div>3</div>");
11
-
12
- // Truthiness.
13
-
14
- addTest("If null.", function(){ return dot.IF(null, "if").ELSE("else"); }, "else");
15
- addTest("If {}.", function(){ return dot.IF({}, "if").ELSE("else"); }, "if");
@@ -1,155 +0,0 @@
1
- import addTest from "./core";
2
- import dot from "../src/index";
3
-
4
- // TODO: not sure if this is a valid test case.
5
- // The change event is dispatched on the option element, not the select.
6
- // Need to ensure this works with real elements and user interaction.
7
- dot.component({name: "comp_binding_input_change_option",
8
- builder: function(){
9
- this.myValue = false;
10
- return dot.select(
11
- dot.option("a").value("a").selected()
12
- .option("b").value("b").bindTo(this, "myValue")
13
- .option("c").value("c"))},
14
- ready: function(){
15
- dot(this.$el).setVal("b");
16
- //this.myValue.setFrom(this.$el.childNodes[1]);
17
- var v = dot(this.$el).getVal();
18
- this.$el.children[1].dispatchEvent(new Event("change"));
19
- dot(this.$el.parentNode).empty()
20
- .div("Var: " + this.myValue)
21
- .div("Input: " + v);
22
- }
23
- });
24
-
25
- dot.component({name: "comp_binding_write_input", builder: function(){return dot.comp_binding_write(dot.input(), "a", "b")}});
26
- dot.component({name: "comp_binding_var_change_input", builder: function(){return dot.comp_binding_var_change(dot.input(), "a", "b")}});
27
- dot.component({name: "comp_binding_input_change_input", builder: function(){return dot.comp_binding_input_change(dot.input(), "a", "b")}});
28
- dot.component({name: "comp_binding_write_textarea", builder: function(){return dot.comp_binding_write(dot.textarea("x"), "a", "b")}});
29
- dot.component({name: "comp_binding_var_change_textarea", builder: function(){return dot.comp_binding_var_change(dot.textarea("x"), "a", "b")}});
30
- dot.component({name: "comp_binding_input_change_textarea", builder: function(){return dot.comp_binding_input_change(dot.textarea("x"), "a", "b")}});
31
- dot.component({name: "comp_binding_write_checkbox_on", builder: function(){return dot.comp_binding_write(dot.input().type("checkbox"), false, true)}});
32
- dot.component({name: "comp_binding_var_change_checkbox_on", builder: function(){return dot.comp_binding_var_change(dot.input().type("checkbox"), false, true)}});
33
- dot.component({name: "comp_binding_input_change_checkbox_on", builder: function(){return dot.comp_binding_input_change(dot.input().type("checkbox"), false, true)}});
34
- dot.component({name: "comp_binding_write_checkbox_off", builder: function(){return dot.comp_binding_write(dot.input().type("checkbox").checked(), true, false)}});
35
- dot.component({name: "comp_binding_var_change_checkbox_off", builder: function(){return dot.comp_binding_var_change(dot.input().type("checkbox").checked(), true, false)}});
36
- dot.component({name: "comp_binding_input_change_checkbox_off", builder: function(){return dot.comp_binding_input_change(dot.input().type("checkbox").checked(), true, false)}});
37
- dot.component({name: "comp_binding_write_radio_on", builder: function(){return dot.comp_binding_write(dot.input().type("radio").name("radiotest1"), false, true)}});
38
- dot.component({name: "comp_binding_var_change_radio_on", builder: function(){return dot.comp_binding_var_change(dot.input().type("radio").name("radiotest2"), false, true)}});
39
- dot.component({name: "comp_binding_input_change_radio_on", builder: function(){return dot.comp_binding_input_change(dot.input().type("radio").name("radiotest3"), false, true)}});
40
- dot.component({name: "comp_binding_write_radio_off", builder: function(){return dot.comp_binding_write(dot.input().type("radio").name("radiotest4"), true, false)}});
41
- dot.component({name: "comp_binding_var_change_radio_off", builder: function(){return dot.comp_binding_var_change(dot.input().type("radio").name("radiotest5"), true, false)}});
42
- dot.component({name: "comp_binding_input_change_radio_off", builder: function(){return dot.comp_binding_input_change(dot.input().type("radio").name("radiotest6"), true, false)}});
43
- dot.component({name: "comp_binding_write_select", builder: function(){return dot.comp_binding_write(dot.component_select(), "a", "b")}});
44
- dot.component({name: "comp_binding_var_change_select", builder: function(){return dot.comp_binding_var_change(dot.component_select(), "a", "b")}});
45
- dot.component({name: "comp_binding_input_change_select", builder: function(){return dot.comp_binding_input_change(dot.component_select(), "a", "b")}});
46
-
47
- dot.component({name: "comp_binding_write",
48
- builder: function(input, v1, v2){
49
- this.v1 = v1;
50
- this.v2 = v2;
51
- return input.bindTo(this, "v2");
52
- },
53
- ready: function(){
54
- var v = dot(this.$el).getVal();
55
- dot(this.$el.parentNode).empty()
56
- .div("Var: " + this.v2)
57
- .div("Input: " + v);
58
- }
59
- });
60
- dot.component({name: "comp_binding_var_change",
61
- builder: function(input, v1, v2){
62
- this.v1 = v1;
63
- this.v2 = v2;
64
- return input.bindTo(this, "v1");
65
- },
66
- ready: function(){
67
- this.v1 = this.v2;
68
- var v = dot(this.$el).getVal();
69
- dot(this.$el.parentNode).empty()
70
- .div("Var: " + this.v1)
71
- .div("Input: " + v);
72
- }
73
- });
74
-
75
- dot.component({name: "comp_binding_input_change",
76
- builder: function(input, v1, v2){
77
- this.v1 = v1;
78
- this.v2 = v2;
79
- //this.myValue = dot.binding(v1);
80
- return input.bindTo(this, "v1");
81
- },
82
- ready: function(){
83
- dot(this.$el).setVal(this.v2);
84
- var v = dot(this.$el).getVal();
85
- this.$el.dispatchEvent(new Event("change"));
86
- //this.v1 = v;
87
- dot(this.$el.parentNode).empty()
88
- .div("Var: " + this.v1)
89
- .div("Input: " + v);
90
- }
91
- });
92
-
93
-
94
- // dot.component({name: "comp_binding_write_option", builder: function(){return dot.comp_binding_write(dot.input(), false, true)}});
95
- // dot.component({name: "comp_binding_var_change_option", builder: function(){return dot.comp_binding_var_change(dot.input(), false, true)}});
96
- // dot.component({name: "comp_binding_input_change_option", builder: function(){return dot.comp_binding_input_change(dot.input(), false, true)}});
97
- dot.component({name: "comp_binding_write_option",
98
- builder: function(){
99
- this.myValue = true;
100
- return dot.select(
101
- dot.option("a").value("a").selected()
102
- .option("b").value("b").bindTo(this, "myValue")
103
- .option("c").value("c"))
104
- },
105
- ready: function(){
106
- var v = dot(this.$el).getVal();
107
- dot(this.$el.parentNode).empty()
108
- .div("Var: " + this.myValue).div("Input: " + v)
109
- }
110
- });
111
- dot.component({name: "comp_binding_var_change_option",
112
- builder: function(){
113
- this.myValue = false;
114
- return dot.select(
115
- dot.option("a").value("a").selected()
116
- .option("b").value("b").bindTo(this, "myValue")
117
- .option("c").value("c"))
118
- },
119
- ready: function(){
120
- this.myValue = true;
121
- var v = dot(this.$el).getVal();
122
- dot(this.$el.parentNode).empty()
123
- .div("Var: " + this.myValue)
124
- .div("Input: " + v)
125
- }
126
- });
127
-
128
- dot.component({name: "component_select", builder: function(){return dot.select(dot.option("a").value("a").option("b").value("b").option("c").value("c"));}});
129
-
130
-
131
-
132
- addTest("Var bound to input.", function(){return dot.comp_binding_write_input()}, "<div>Var: b</div><div>Input: b</div>");
133
- addTest("Var change updating input.", function(){return dot.comp_binding_var_change_input()}, "<div>Var: b</div><div>Input: b</div>");
134
- addTest("Input change updating var.", function(){return dot.comp_binding_input_change_input()}, "<div>Var: b</div><div>Input: b</div>");
135
- addTest("Var bound to textarea.", function(){return dot.comp_binding_write_textarea()}, "<div>Var: b</div><div>Input: b</div>");
136
- addTest("Var change updating textarea.", function(){return dot.comp_binding_var_change_textarea()}, "<div>Var: b</div><div>Input: b</div>");
137
- addTest("Textarea change updating var.", function(){return dot.comp_binding_input_change_textarea()}, "<div>Var: b</div><div>Input: b</div>");
138
- addTest("Var bound to checkbox on.", function(){return dot.comp_binding_write_checkbox_on()}, "<div>Var: true</div><div>Input: true</div>");
139
- addTest("Var change updating checkbox on.", function(){return dot.comp_binding_var_change_checkbox_on()}, "<div>Var: true</div><div>Input: true</div>");
140
- addTest("Checkbox change updating var on.", function(){return dot.comp_binding_input_change_checkbox_on()}, "<div>Var: true</div><div>Input: true</div>");
141
- addTest("Var bound to checkbox off.", function(){return dot.comp_binding_write_checkbox_off()}, "<div>Var: false</div><div>Input: false</div>");
142
- addTest("Var change updating checkbox off.", function(){return dot.comp_binding_var_change_checkbox_off()}, "<div>Var: false</div><div>Input: false</div>");
143
- addTest("Checkbox change updating var.", function(){return dot.comp_binding_input_change_checkbox_off()}, "<div>Var: false</div><div>Input: false</div>");
144
- addTest("Var bound to radio on.", function(){return dot.comp_binding_write_radio_on()}, "<div>Var: true</div><div>Input: true</div>");
145
- addTest("Var change updating radio on.", function(){return dot.comp_binding_var_change_radio_on()}, "<div>Var: true</div><div>Input: true</div>");
146
- addTest("Radio change updating var on.", function(){return dot.comp_binding_input_change_radio_on()}, "<div>Var: true</div><div>Input: true</div>");
147
- addTest("Var bound to radio off.", function(){return dot.comp_binding_write_radio_off()}, "<div>Var: false</div><div>Input: false</div>");
148
- addTest("Var change updating radio off.", function(){return dot.comp_binding_var_change_radio_off()}, "<div>Var: false</div><div>Input: false</div>");
149
- addTest("Radio change updating var off.", function(){return dot.comp_binding_input_change_radio_off()}, "<div>Var: false</div><div>Input: false</div>");
150
- addTest("Var bound to select.", function(){return dot.comp_binding_write_select()}, "<div>Var: b</div><div>Input: b</div>");
151
- addTest("Var change updating select.", function(){return dot.comp_binding_var_change_select()}, "<div>Var: b</div><div>Input: b</div>");
152
- addTest("Select change updating var.", function(){return dot.comp_binding_input_change_select()}, "<div>Var: b</div><div>Input: b</div>");
153
- addTest("Var bound to option.", function(){return dot.comp_binding_write_option()}, "<div>Var: true</div><div>Input: b</div>");
154
- addTest("Var change updating option.", function(){return dot.comp_binding_var_change_option()}, "<div>Var: true</div><div>Input: b</div>");
155
- addTest("Option change updating var.", function(){return dot.comp_binding_input_change_option()}, "<div>Var: true</div><div>Input: b</div>");
@@ -1,6 +0,0 @@
1
- import addTest from "./core";
2
- import dot from "../lib/dothtml.min.js";
3
-
4
- test("Integration test.", ()=>{
5
- dot.div();
6
- });
@@ -1,18 +0,0 @@
1
- import addTest from "./core";
2
- import dot from "../src/index";
3
-
4
- addTest("If true else.", function(){ return dot.IF(true, "if").ELSE("else"); }, "if");
5
- addTest("If false else.", function(){ return dot.IF(false, "if").ELSE("else"); }, "else");
6
- addTest("If false else else.", function(){ return dot.IF(false, "if").ELSE("else1").ELSE("else2"); }, "else1else2");
7
- addTest("If true elseif true else.", function(){ return dot.IF(true, "if").ELSEIF(true, "elseif").ELSE("else"); }, "if");
8
- addTest("If true elseif false else.", function(){ return dot.IF(true, "if").ELSEIF(false, "elseif").ELSE("else"); }, "if");
9
- addTest("If false elseif true else.", function(){ return dot.IF(false, "if").ELSEIF(true, "elseif").ELSE("else"); }, "elseif");
10
- addTest("If false elseif false else.", function(){ return dot.IF(false, "if").ELSEIF(false, "elseif").ELSE("else"); }, "else");
11
- addTest("Nested ifs.", function(){
12
- return dot.IF(true,
13
- dot.IF(false, "if if")
14
- .ELSEIF(true, "if elseif")
15
- .ELSE("if else")
16
- ).ELSEIF(true, "elseif")
17
- .ELSE("else");
18
- }, "if elseif");
@@ -1,56 +0,0 @@
1
- import addTest from "./core";
2
- import dot from "../src/index";
3
-
4
- try{
5
- dot.component({name: "defaultpage", builder: function(){return dot.h1("Default")}});
6
- dot.component({name: "page1", builder: function(){return dot.h1("Page 1.")}});
7
- dot.component({name: "page2", builder: function(){return dot.h1("Page 2.")}});
8
- dot.component({name: "page3", builder: function(){return dot.h1("Page 3.").router()}});
9
- dot.component({name: "page4", builder: function(){return dot.h1("Good.")}});
10
- dot.component({name: "page5", builder: function(){return dot.h1("Bad.")}});
11
- dot.component({name: "page6_7", builder: function(){return dot.h1("Page 6/7.")}});
12
- dot.component({name: "page6", builder: function(){return dot.h1("Page 6.")}});
13
- dot.component({name: "page7", builder: function(){return dot.h1("Page 7.")}});
14
- dot.component({name: "awesomepage", function(params){return dot.h1(params.params.title).p(params.params.body)}});
15
- dot.component({name: "notfound", builder: function(){return dot.h1("Not Found.")}});
16
- }catch(e){console.error(e);}
17
- var routes = [
18
- {title: "DOT Tests", path: "/", component: dot.defaultpage},
19
- {title: "Page 1", path: "1", component: dot.page1},
20
- {title: "Page 2", path: "2", component: dot.page2},
21
- {title: "Page 3", path: "3", component: dot.page3},
22
- {title: "Greedy Page 4", path: "greed", component: dot.page4},
23
- {title: "Greedy Page 5", path: "greed", component: dot.page5},
24
- {title: "Page 6/7", path: "6/7", component: dot.page6_7},
25
- {title: "Awesome", path: "awesome/{title}/{body}", component: dot.awesomepage},
26
- {title: "Ajax", path: "ajax", component: "testpage.js"},
27
- {title: "Not Found", path: "*", component: dot.notfound},
28
- ];
29
- // addTest("Navigate with no router.", function(){return dot.div("abc").navigate("1")}, "<div>abc</div>");
30
- // addTest("Chainability of navigate.", function(){return dot.div("abc").navigate("1").div("def")}, "<div>abc</div><div>def</div>");
31
- // addTest("Default content.", function(){return dot.router(routes, true)}, "<dothtml-router></dothtml-router>");
32
- // addTest("Default content, undefined navigate.", function(){return dot.router(routes, true).navigate()}, "<dothtml-router><h1>Default</h1></dothtml-router>");
33
- // addTest("Default content, / navigate.", function(){return dot.router(routes, true).navigate("/")}, "<dothtml-router><h1>Default</h1></dothtml-router>");
34
- // addTest("Unknown route.", function(){return dot.router(routes, true).navigate("unknown")}, "<dothtml-router><h1>Not Found.</h1></dothtml-router>");
35
- // addTest("Navigate to 1.", function(){return dot.router(routes, true).navigate("1")}, "<dothtml-router><h1>Page 1.</h1></dothtml-router>");
36
- // addTest("Navigate to 1/.", function(){return dot.router(routes, true).navigate("1/")}, "<dothtml-router><h1>Page 1.</h1></dothtml-router>");
37
- // addTest("Navigate to 1 then 2.", function(){return dot.router(routes, true).navigate("1").navigate("2")}, "<dothtml-router><h1>Page 2.</h1></dothtml-router>");
38
- // addTest("Navigate to the same page.", function(){return dot.router(routes, true).navigate("1").navigate("1")}, "<dothtml-router><h1>Page 1.</h1></dothtml-router>");
39
- // addTest("Navigate from 1 to undefined.", function(){return dot.router(routes, true).navigate("1").navigate()}, "<dothtml-router><h1>Default</h1></dothtml-router>");
40
- // addTest("Navigate from 1 to /.", function(){return dot.router(routes, true).navigate("1").navigate("/")}, "<dothtml-router><h1>Default</h1></dothtml-router>");
41
- // addTest("Navigate to 6/7.", function(){return dot.router(routes, true).navigate("6/7")}, "<dothtml-router><h1>Page 6/7.</h1></dothtml-router>");
42
- // addTest("Navigate to 6/8.", function(){return dot.router(routes, true).navigate("6/8")}, "<dothtml-router><h1>Not Found.</h1></dothtml-router>");
43
- // addTest("Params.", function(){return dot.router(routes, true).navigate("awesome/Hello/Hello_World")}, "<dothtml-router><h1>Hello</h1><p>Hello_World</p></dothtml-router>");
44
- // addTest("Greedy route.", function(){return dot.router(routes, true).navigate("greed")}, "<dothtml-router><h1>Good.</h1></dothtml-router>");
45
- // addTest("Load page file.", function(){return dot.router(routes, true).navigate("ajax")}, "<dothtml-router><h1>Loaded Page</h1><p>This page was loaded from a file!</p></dothtml-router>");
46
- // NESTED ROUTING (NOT SUPPORTED YET)
47
- // addTest("Route not found child.", function(){return dot.router(routes, true).navigate("3/notfound")}, "<dothtml-router><h1>Page 3.</h1><dothtml-router>Route \"notfound\" not found.</dothtml-router></dothtml-router>");
48
- // addTest("Router in router / default.", function(){return dot.router(routes, true).navigate("3")}, "<dothtml-router><h1>Page 3.</h1><dothtml-router><h1>Default</h1></dothtml-router></dothtml-router>");
49
- // addTest("Router in router / page 3/1.", function(){return dot.router(routes, true).navigate("3/1")}, "<dothtml-router><h1>Page 3.</h1><dothtml-router><h1>Page 1.</h1></dothtml-router></dothtml-router>");
50
- // addTest("Router in router / page 3/2 => 3/1.", function(){return dot.router(routes, true).navigate("3/2").navigate("3/1")}, "<dothtml-router><h1>Page 3.</h1><dothtml-router><h1>Page 1.</h1></dothtml-router></dothtml-router>");
51
- // addTest("Router in router / page 3/2 => 2.", function(){return dot.router(routes, true).navigate("3/1").navigate("2")}, "<dothtml-router><h1>Page 2.</h1></dothtml-router>");
52
- // addTest("Router in router / page 2 => 3/1.", function(){return dot.router(routes, true).navigate("2").navigate("3/1")}, "<dothtml-router><h1>Page 3.</h1><dothtml-router><h1>Page 1.</h1></dothtml-router></dothtml-router>");
53
- // addTest("Router in router / page 3/3/1.", function(){return dot.router(routes, true).navigate("3/3/1")}, "<dothtml-router><h1>Page 3.</h1><dothtml-router><h1>Page 3.</h1><dothtml-router><h1>Page 1.</h1></dothtml-router></dothtml-router></dothtml-router>");
54
- // CURRENTLY UNDEFINED:
55
- //addTest("Two routers.", function(){return dot.router(routes, true).router(routes, true).navigate("1")}, "<dothtml-router></dothtml-router><dothtml-router><h1>Page 1.</h1></dothtml-router>");
56
- // - Add test case for ensuring routers are removed from the allRouters object after calling empty().
@@ -1,32 +0,0 @@
1
- import addTest from "./core";
2
- import dot from "../src/index";
3
-
4
- addTest("citeE.", function(){ return dot.citeE(); }, "<cite></cite>");
5
- addTest("dataE.", function(){ return dot.dataE(); }, "<data></data>"); //Element not supported by most browsers.
6
- addTest("formE.", function(){ return dot.formE(); }, "<form></form>");
7
- addTest("labelE.", function(){ return dot.labelE(); }, "<label></label>");
8
- addTest("spanE.", function(){ return dot.spanE(); }, "<span></span>");
9
- addTest("summaryE.", function(){ return dot.summaryE(); }, "<summary></summary>");
10
- addTest("citeA.", function(){ return dot.del().citeA(1); }, "<del cite=\"1\"></del>");
11
- addTest("dataA.", function(){ return dot.object().dataA(1); }, "<object data=\"1\"></object>");
12
- addTest("formA.", function(){ return dot.input().formA(1); }, "<input form=\"1\">");
13
- addTest("labelA.", function(){ return dot.track().labelA(1); }, ["<track label=\"1\">", "<track label=\"1\"></track>"]);
14
- addTest("spanA.", function(){ return dot.col().spanA(1); }, "<col span=\"1\">");
15
- addTest("summaryA.", function(){ return dot.table().summaryA(1); }, "<table summary=\"1\"></table>");
16
- addTest("Smart cite - attribute.", function(){ return dot.del().cite(1); }, "<del cite=\"1\"></del>");
17
- addTest("Smart form - attribute.", function(){ return dot.input().form(1); }, "<input form=\"1\">");
18
- addTest("Smart label - attribute.", function(){ return dot.track().label(1); }, ["<track label=\"1\">", "<track label=\"1\"></track>"]);
19
- addTest("Smart span - attribute.", function(){ return dot.col().span(1); }, "<col span=\"1\">");
20
- addTest("Smart summary - attribute.", function(){ return dot.table().summary(1); }, "<table summary=\"1\"></table>");
21
- addTest("Smart cite - element.", function(){ return dot.div().cite(); }, "<div></div><cite></cite>");
22
- addTest("Smart form - element.", function(){ return dot.div().form(); }, "<div></div><form></form>");
23
- addTest("Smart label - element.", function(){ return dot.div().label(); }, "<div></div><label></label>");
24
- addTest("Smart span - element.", function(){ return dot.div().span(); }, "<div></div><span></span>");
25
- addTest("Smart summary - element.", function(){ return dot.div().summary(); }, "<div></div><summary></summary>");
26
- addTest("Smart cite - append to blank.", function(){ return dot.citeE(); }, "<cite></cite>");
27
- addTest("Smart form - append to blank.", function(){ return dot.formE(); }, "<form></form>");
28
- addTest("Smart label - append to blank.", function(){ return dot.labelE(); }, "<label></label>");
29
- addTest("Smart span - append to blank.", function(){ return dot.spanE(); }, "<span></span>");
30
- addTest("Smart summary - append to blank.", function(){ return dot.summaryE(); }, "<summary></summary>");
31
- addTest("Smart data - basic attribute.", function(){ return dot.object().data(1); }, "<object data=\"1\"></object>");
32
- addTest("Smart data - custom attribute.", function(){ return dot.div().data("a", 1); }, "<div data-a=\"1\"></div>");