dothtml 4.8.6 → 5.0.0
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.
- package/{jest.config.js → jest.config.ts} +19 -16
- package/lib/arg-callback-obj.d.ts +29 -0
- package/lib/built-in-components/nav-link.d.ts +8 -0
- package/lib/built-in-components/router.d.ts +57 -0
- package/lib/component.d.ts +73 -0
- package/lib/dot-component-legacy.d.ts +0 -0
- package/lib/dot-document.d.ts +0 -0
- package/lib/dot-util.d.ts +13 -0
- package/lib/dot.d.ts +5 -0
- package/lib/dothtml.d.ts +21 -0
- package/lib/dothtml.js +2 -0
- package/lib/dothtml.js.LICENSE.txt +1 -0
- package/lib/err.d.ts +2 -0
- package/lib/event-bus.d.ts +10 -0
- package/lib/i-dot.d.ts +674 -0
- package/lib/i-dotcss.d.ts +821 -0
- package/lib/node-polyfill.d.ts +2 -0
- package/lib/observable-array.d.ts +49 -0
- package/lib/style-builder.d.ts +3 -0
- package/package.json +11 -5
- package/readme.md +3 -2
- package/src/{arg-callback-obj.js → arg-callback-obj.ts} +18 -6
- package/src/built-in-components/nav-link.ts +21 -0
- package/src/built-in-components/router.ts +315 -0
- package/src/component.ts +369 -0
- package/src/dot-component-legacy.ts +79 -0
- package/src/dot-document.ts +0 -0
- package/src/dot-util.ts +33 -0
- package/src/dot.ts +1147 -0
- package/src/dothtml.ts +33 -0
- package/src/err.ts +22 -0
- package/src/event-bus.ts +39 -0
- package/src/i-dot.ts +787 -0
- package/src/i-dotcss.ts +911 -0
- package/src/node-polyfill.ts +11 -0
- package/src/{observable-array.js → observable-array.ts} +10 -5
- package/src/{style-builder.js → style-builder.ts} +219 -183
- package/tsconfig.json +99 -0
- package/unittests/advanced-bindings.test.ts +421 -0
- package/unittests/{array-evaluation.test.js → array-evaluation.test.ts} +1 -1
- package/unittests/{basic-functionality.test.js → basic-functionality.test.ts} +14 -10
- package/unittests/class-binding.test.ts +227 -0
- package/unittests/component-decorator.-.ts +14 -0
- package/unittests/components-data.test.ts +153 -0
- package/unittests/components.test.ts +257 -0
- package/unittests/computed.test.ts +35 -0
- package/unittests/{core.js → core.ts} +5 -2
- package/unittests/element-and-attribute-coverage.test.ts +472 -0
- package/unittests/hooks.test.ts +67 -0
- package/unittests/immutable-if.test.ts +19 -0
- package/unittests/input-bindings.test.ts +166 -0
- package/unittests/integration.test.ts +5 -0
- package/unittests/{iterations.test.js → iterations.test.ts} +5 -5
- package/unittests/logic.test.ts +18 -0
- package/unittests/refs.test.ts +36 -0
- package/unittests/routing.-.ts +56 -0
- package/unittests/{scopes.test.js → scopes.test.ts} +5 -5
- package/unittests/special-tags.test.ts +39 -0
- package/unittests/styles.test.ts +9 -0
- package/unittests/{testpage.js → testpage.ts} +2 -0
- package/unittests/{wait.test.js → wait.test.ts} +8 -5
- package/webpack.config.js +13 -1
- package/lib/dothtml.min.js +0 -1
- package/src/component.js +0 -305
- package/src/err.js +0 -20
- package/src/event-bus.js +0 -40
- package/src/index.js +0 -1453
- package/src/util.js +0 -13
- package/unittests/advanced-bindings.test.js +0 -386
- package/unittests/class-binding.test.js +0 -53
- package/unittests/components-data.test.js +0 -97
- package/unittests/components.test.js +0 -151
- package/unittests/computed.test.js +0 -36
- package/unittests/hooks.test.js +0 -57
- package/unittests/immutable-if.test.js +0 -15
- package/unittests/input-bindings.test.js +0 -155
- package/unittests/integration.test.js +0 -6
- package/unittests/logic.test.js +0 -18
- package/unittests/routing.-.js +0 -56
- package/unittests/special-tags.test.js +0 -32
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import addTest from "./core";
|
|
2
|
+
import dot from "../src/dothtml";
|
|
3
|
+
import Component from "../src/component";
|
|
4
|
+
|
|
5
|
+
// TODO: not sure if this is a valid test case.
|
|
6
|
+
// The change event is dispatched on the option element, not the select.
|
|
7
|
+
// Need to ensure this works with real elements and user interaction.
|
|
8
|
+
class CompBindingInputChangeOption extends Component{
|
|
9
|
+
props:{myValue:boolean} = {myValue: false}
|
|
10
|
+
builder(){
|
|
11
|
+
return dot.select(
|
|
12
|
+
dot.option("a").value("a").selected()
|
|
13
|
+
.option("b").value("b").bindTo(this.props.myValue)
|
|
14
|
+
.option("c").value("c"))}
|
|
15
|
+
ready(){
|
|
16
|
+
dot(this.$el).as(dot.select).setVal("b");
|
|
17
|
+
//this.myValue.setFrom(this.$el.childNodes[1]);
|
|
18
|
+
var v = dot(this.$el).as(dot.select).getVal();
|
|
19
|
+
this.$el.children[1].dispatchEvent(new Event("change"));
|
|
20
|
+
dot(this.$el.parentNode).empty()
|
|
21
|
+
.div("Var: " + this.props.myValue)
|
|
22
|
+
.div("Input: " + v);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class CompBindingWriteInput extends Component{builder(){return dot.div(new CompBindingWrite(dot.input(), "a", "b"))}}
|
|
27
|
+
class CompBindingVarChangeInput extends Component{builder(){return dot.div(new CompBindingVarChange(dot.input(), "a", "b"))}}
|
|
28
|
+
class CompBindingInputChangeInput extends Component{builder(){return dot.div(new CompBindingInputChange(dot.input(), "a", "b"))}}
|
|
29
|
+
class CompBindingWriteTextArea extends Component{builder(){return dot.div(new CompBindingWrite(dot.textArea("x"), "a", "b"))}}
|
|
30
|
+
class CompBindingVarChangeTextArea extends Component{builder(){return dot.div(new CompBindingVarChange(dot.textArea("x"), "a", "b"))}}
|
|
31
|
+
class CompBindingInputChangeTextArea extends Component{builder(){return dot.div(new CompBindingInputChange(dot.textArea("x"), "a", "b"))}}
|
|
32
|
+
class CompBindingWriteCheckboxOn extends Component{builder(){return dot.div(new CompBindingWrite(dot.input().type("checkbox"), false, true))}}
|
|
33
|
+
class CompBindingVarChangeCheckboxOn extends Component{builder(){return dot.div(new CompBindingVarChange(dot.input().type("checkbox"), false, true))}}
|
|
34
|
+
class CompBindingInputChangeCheckboxOn extends Component{builder(){return dot.div(new CompBindingInputChange(dot.input().type("checkbox"), false, true))}}
|
|
35
|
+
class CompBindingWriteCheckboxOff extends Component{builder(){return dot.div(new CompBindingWrite(dot.input().type("checkbox").checked(), true, false))}}
|
|
36
|
+
class CompBindingVarChangeCheckboxOff extends Component{builder(){return dot.div(new CompBindingVarChange(dot.input().type("checkbox").checked(), true, false))}}
|
|
37
|
+
class CompBindingInputChangeCheckboxOff extends Component{builder(){return dot.div(new CompBindingInputChange(dot.input().type("checkbox").checked(), true, false))}}
|
|
38
|
+
class CompBindingWriteRadioOn extends Component{builder(){return dot.div(new CompBindingWrite(dot.input().type("radio").name("radiotest1"), false, true))}}
|
|
39
|
+
class CompBindingVarChangeRadioOn extends Component{builder(){return dot.div(new CompBindingVarChange(dot.input().type("radio").name("radiotest2"), false, true))}}
|
|
40
|
+
class CompBindingInputChangeRadioOn extends Component{builder(){return dot.div(new CompBindingInputChange(dot.input().type("radio").name("radiotest3"), false, true))}}
|
|
41
|
+
class CompBindingWriteRadioOff extends Component{builder(){return dot.div(new CompBindingWrite(dot.input().type("radio").name("radiotest4"), true, false))}}
|
|
42
|
+
class CompBindingVarChangeRadioOff extends Component{builder(){return dot.div(new CompBindingVarChange(dot.input().type("radio").name("radiotest5"), true, false))}}
|
|
43
|
+
class CompBindingInputChangeRadioOff extends Component{builder(){return dot.div(new CompBindingInputChange(dot.input().type("radio").name("radiotest6"), true, false))}}
|
|
44
|
+
class CompBindingWriteSelect extends Component{builder(){return dot.div(new CompBindingWrite(new CompSelect(), "a", "b"))}}
|
|
45
|
+
class CompBindingVarChangeSelect extends Component{builder(){return dot.div(new CompBindingVarChange(new CompSelect(), "a", "b"))}}
|
|
46
|
+
class CompBindingInputChangeSelect extends Component{builder(){return dot.div(new CompBindingInputChange(new CompSelect(), "a", "b"))}}
|
|
47
|
+
|
|
48
|
+
class CompBindingWrite extends Component{
|
|
49
|
+
props:{v1:any, v2: any} = {v1: null, v2: null}
|
|
50
|
+
builder(input, v1, v2){
|
|
51
|
+
this.props.v1 = v1;
|
|
52
|
+
this.props.v2 = v2;
|
|
53
|
+
return dot.h(input).as(dot.input).bindTo(this.props.v2);
|
|
54
|
+
// if(input instanceof Component){
|
|
55
|
+
// }
|
|
56
|
+
// else
|
|
57
|
+
// return dot.h(input).as(dot.input).bindTo(this.props.v2);
|
|
58
|
+
}
|
|
59
|
+
ready(){
|
|
60
|
+
var v = dot(this.$el).as(dot.input).getVal();
|
|
61
|
+
dot(this.$el.parentNode).empty()
|
|
62
|
+
.div("Var: " + this.props.v2)
|
|
63
|
+
.div("Input: " + v);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
class CompBindingVarChange extends Component{
|
|
67
|
+
props:{v1:any, v2: any} = {v1: null, v2: null}
|
|
68
|
+
builder(input, v1, v2){
|
|
69
|
+
this.props.v1 = v1;
|
|
70
|
+
this.props.v2 = v2;
|
|
71
|
+
return dot.h(input).as(dot.input).bindTo(this.props.v1);
|
|
72
|
+
}
|
|
73
|
+
ready(){
|
|
74
|
+
this.props.v1 = this.props.v2;
|
|
75
|
+
var v = dot(this.$el).as(dot.input).getVal();
|
|
76
|
+
dot(this.$el.parentNode).empty()
|
|
77
|
+
.div("Var: " + this.props.v1)
|
|
78
|
+
.div("Input: " + v);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
class CompBindingInputChange extends Component{
|
|
83
|
+
props:{v1:any, v2: any} = {v1: null, v2: null}
|
|
84
|
+
builder(input, v1, v2){
|
|
85
|
+
this.props.v1 = v1;
|
|
86
|
+
this.props.v2 = v2;
|
|
87
|
+
//this.myValue = dot.binding(v1);
|
|
88
|
+
return dot.h(input).as(dot.input).bindTo(this.props.v1);
|
|
89
|
+
}
|
|
90
|
+
ready(){
|
|
91
|
+
dot(this.$el).as(dot.input).setVal(this.props.v2);
|
|
92
|
+
var v = dot(this.$el).as(dot.input).getVal();
|
|
93
|
+
this.$el.dispatchEvent(new Event("change"));
|
|
94
|
+
//this.v1 = v;
|
|
95
|
+
dot(this.$el.parentNode).empty()
|
|
96
|
+
.div("Var: " + this.props.v1)
|
|
97
|
+
.div("Input: " + v);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
// class CompBindingWriteoption extends Component{ builder(){return dot.CompBindingwrite(dot.input(), false, true)}});
|
|
103
|
+
// class CompBindingVarchangeOption extends Component{ builder(){return dot.CompBindingVarchange(dot.input(), false, true)}});
|
|
104
|
+
// class CompBindingInputChangeOption extends Component{ builder(){return dot.CompBindingInputChange(dot.input(), false, true)}});
|
|
105
|
+
class CompBindingWriteOption extends Component{
|
|
106
|
+
props:{myValue:boolean} = {myValue: false}
|
|
107
|
+
builder(){
|
|
108
|
+
this.props.myValue = true;
|
|
109
|
+
return dot.select(
|
|
110
|
+
dot.option("a").value("a").selected()
|
|
111
|
+
.option("b").value("b").bindTo(this.props.myValue)
|
|
112
|
+
.option("c").value("c"))
|
|
113
|
+
}
|
|
114
|
+
ready(){
|
|
115
|
+
var v = dot(this.$el).as(dot.select).getVal();
|
|
116
|
+
dot(this.$el.parentNode).empty()
|
|
117
|
+
.div("Var: " + this.props.myValue).div("Input: " + v)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
class CompBindingVarChangeOption extends Component{
|
|
121
|
+
props:{myValue:boolean} = {myValue: false}
|
|
122
|
+
builder(){
|
|
123
|
+
this.props.myValue = false;
|
|
124
|
+
return dot.select(
|
|
125
|
+
dot.option("a").value("a").selected()
|
|
126
|
+
.option("b").value("b").bindTo(this.props.myValue)
|
|
127
|
+
.option("c").value("c"))
|
|
128
|
+
}
|
|
129
|
+
ready(){
|
|
130
|
+
this.props.myValue = true;
|
|
131
|
+
var v = dot(this.$el).as(dot.select).getVal();
|
|
132
|
+
dot(this.$el.parentNode).empty()
|
|
133
|
+
.div("Var: " + this.props.myValue)
|
|
134
|
+
.div("Input: " + v)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
class CompSelect extends Component{ builder(){return dot.select(dot.option("a").value("a").option("b").value("b").option("c").value("c"));}}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
addTest("Var bound to input.", function(){return dot.h(new CompBindingWriteInput())}, "<div><div>Var: b</div><div>Input: b</div></div>");
|
|
143
|
+
addTest("Var change updating input.", function(){return dot.h(new CompBindingVarChangeInput())}, "<div><div>Var: b</div><div>Input: b</div></div>");
|
|
144
|
+
addTest("Input change updating var.", function(){return dot.h(new CompBindingInputChangeInput())}, "<div><div>Var: b</div><div>Input: b</div></div>");
|
|
145
|
+
addTest("Var bound to textarea.", function(){return dot.h(new CompBindingWriteTextArea())}, "<div><div>Var: b</div><div>Input: b</div></div>");
|
|
146
|
+
addTest("Var change updating textarea.", function(){return dot.h(new CompBindingVarChangeTextArea())}, "<div><div>Var: b</div><div>Input: b</div></div>");
|
|
147
|
+
addTest("Textarea change updating var.", function(){return dot.h(new CompBindingInputChangeTextArea())}, "<div><div>Var: b</div><div>Input: b</div></div>");
|
|
148
|
+
addTest("Var bound to checkbox on.", function(){return dot.h(new CompBindingWriteCheckboxOn())}, "<div><div>Var: true</div><div>Input: true</div></div>");
|
|
149
|
+
addTest("Var change updating checkbox on.", function(){return dot.h(new CompBindingVarChangeCheckboxOn())}, "<div><div>Var: true</div><div>Input: true</div></div>");
|
|
150
|
+
addTest("Checkbox change updating var on.", function(){return dot.h(new CompBindingInputChangeCheckboxOn())}, "<div><div>Var: true</div><div>Input: true</div></div>");
|
|
151
|
+
addTest("Var bound to checkbox off.", function(){return dot.h(new CompBindingWriteCheckboxOff())}, "<div><div>Var: false</div><div>Input: false</div></div>");
|
|
152
|
+
addTest("Var change updating checkbox off.", function(){return dot.h(new CompBindingVarChangeCheckboxOff())}, "<div><div>Var: false</div><div>Input: false</div></div>");
|
|
153
|
+
addTest("Checkbox change updating var.", function(){return dot.h(new CompBindingInputChangeCheckboxOff())}, "<div><div>Var: false</div><div>Input: false</div></div>");
|
|
154
|
+
addTest("Var bound to radio on.", function(){return dot.h(new CompBindingWriteRadioOn())}, "<div><div>Var: true</div><div>Input: true</div></div>");
|
|
155
|
+
addTest("Var change updating radio on.", function(){return dot.h(new CompBindingVarChangeRadioOn())}, "<div><div>Var: true</div><div>Input: true</div></div>");
|
|
156
|
+
addTest("Radio change updating var on.", function(){return dot.h(new CompBindingInputChangeRadioOn())}, "<div><div>Var: true</div><div>Input: true</div></div>");
|
|
157
|
+
addTest("Var bound to radio off.", function(){return dot.h(new CompBindingWriteRadioOff())}, "<div><div>Var: false</div><div>Input: false</div></div>");
|
|
158
|
+
addTest("Var change updating radio off.", function(){return dot.h(new CompBindingVarChangeRadioOff())}, "<div><div>Var: false</div><div>Input: false</div></div>");
|
|
159
|
+
addTest("Radio change updating var off.", function(){return dot.h(new CompBindingInputChangeRadioOff())}, "<div><div>Var: false</div><div>Input: false</div></div>");
|
|
160
|
+
addTest("Var bound to select.", function(){return dot.h(new CompBindingWriteSelect())}, "<div><div>Var: b</div><div>Input: b</div></div>");
|
|
161
|
+
addTest("Var change updating select.", function(){return dot.h(new CompBindingVarChangeSelect())}, "<div><div>Var: b</div><div>Input: b</div></div>");
|
|
162
|
+
addTest("Select change updating var.", function(){return dot.h(new CompBindingInputChangeSelect())}, "<div><div>Var: b</div><div>Input: b</div></div>");
|
|
163
|
+
addTest("Var bound to option.", function(){return dot.h(new CompBindingWriteOption())}, "<div>Var: true</div><div>Input: b</div>");
|
|
164
|
+
addTest("Var change updating option.", function(){return dot.h(new CompBindingVarChangeOption())}, "<div>Var: true</div><div>Input: b</div>");
|
|
165
|
+
addTest("Option change updating var.", function(){return dot.h(new CompBindingInputChangeOption())}, "<div>Var: true</div><div>Input: b</div>");
|
|
166
|
+
// expected output: Object { foo: "bar", baz: 42 }
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import addTest from "./core";
|
|
2
|
-
import dot from "../src/
|
|
2
|
+
import dot from "../src/dothtml";
|
|
3
3
|
|
|
4
4
|
addTest("Iterate.", function(){ return dot.iterate(3, function(i){return dot.h(i)}); }, "012");
|
|
5
5
|
addTest("Iterate w/ friends.", function(){ return dot.h("s").iterate(3, function(i){return dot.h(i)}).h("f"); }, "s012f");
|
|
6
|
-
addTest("Iterate no return.", function(){ return dot.h("s").iterate(3, function(i){dot.h(i)}).h("f"); }, "sf");
|
|
7
|
-
addTest("Iterate raw dot.", function(){ return dot.h("s").iterate(3, dot.h("-")).h("f"); }, "s---f");
|
|
8
|
-
addTest("Iterate raw dot HTML.", function(){ return dot.h("s").iterate(3, dot.div()).h("f"); }, "s<div></div><div></div><div></div>f");
|
|
9
|
-
addTest("Iterate text.", function(){ return dot.h("s").iterate(3, "-").h("f"); }, "s---f");
|
|
6
|
+
addTest("Iterate no return.", function(){ return dot.h("s").iterate(3, function(i){dot.h(i); return dot.t("")}).h("f"); }, "sf");
|
|
7
|
+
// addTest("Iterate raw dot.", function(){ return dot.h("s").iterate(3, dot.h("-")).h("f"); }, "s---f");
|
|
8
|
+
// addTest("Iterate raw dot HTML.", function(){ return dot.h("s").iterate(3, dot.div()).h("f"); }, "s<div></div><div></div><div></div>f");
|
|
9
|
+
// addTest("Iterate text.", function(){ return dot.h("s").iterate(3, "-").h("f"); }, "s---f");
|
|
10
10
|
addTest("Nested iterate.", function(){
|
|
11
11
|
return dot.h("s")
|
|
12
12
|
.iterate(2, function(i){
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import addTest from "./core";
|
|
2
|
+
import dot from "../src/dothtml";
|
|
3
|
+
|
|
4
|
+
addTest("If true else.", function(){ return dot.when(true, ()=>"if").otherwise(()=>"else"); }, "if");
|
|
5
|
+
addTest("If false else.", function(){ return dot.when(false, ()=>"if").otherwise(()=>"else"); }, "else");
|
|
6
|
+
addTest("If false else else.", function(){ return dot.when(false, ()=>"if").otherwise(()=>"else1").otherwise(()=>"else2"); }, "else1else2");
|
|
7
|
+
addTest("If true elseif true else.", function(){ return dot.when(true, ()=>"if").otherwiseWhen(true, ()=>"elseif").otherwise(()=>"else"); }, "if");
|
|
8
|
+
addTest("If true elseif false else.", function(){ return dot.when(true, ()=>"if").otherwiseWhen(false, ()=>"elseif").otherwise(()=>"else"); }, "if");
|
|
9
|
+
addTest("If false elseif true else.", function(){ return dot.when(false, ()=>"if").otherwiseWhen(true, ()=>"elseif").otherwise(()=>"else"); }, "elseif");
|
|
10
|
+
addTest("If false elseif false else.", function(){ return dot.when(false, ()=>"if").otherwiseWhen(false, ()=>"elseif").otherwise(()=>"else"); }, "else");
|
|
11
|
+
addTest("Nested ifs.", function(){
|
|
12
|
+
return dot.when(true,
|
|
13
|
+
dot.when(false, ()=>"if if")
|
|
14
|
+
.otherwiseWhen(true, ()=>"if elseif")
|
|
15
|
+
.otherwise(()=>"if else")
|
|
16
|
+
).otherwiseWhen(true, ()=>"elseif")
|
|
17
|
+
.otherwise(()=>"else");
|
|
18
|
+
}, "if elseif");
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import addTest from "./core";
|
|
2
|
+
import dot, { IDotElement } from "../src/dothtml";
|
|
3
|
+
|
|
4
|
+
class RefComponent1 extends dot.Component{
|
|
5
|
+
builder(): IDotElement {
|
|
6
|
+
return dot.div(
|
|
7
|
+
dot
|
|
8
|
+
.span().ref("a")
|
|
9
|
+
.span().ref("b")
|
|
10
|
+
.span().ref("c")
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
ready(){
|
|
14
|
+
dot(this.$refs.a).t("a");
|
|
15
|
+
dot(this.$refs.b).t("b");
|
|
16
|
+
dot(this.$refs.c).t("c");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
class RefComponent2 extends dot.Component{
|
|
20
|
+
builder(content): IDotElement {
|
|
21
|
+
return dot.div(
|
|
22
|
+
dot.span().ref("a")
|
|
23
|
+
.h(content)
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
ready(){
|
|
27
|
+
dot(this.$refs.a).t("1");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
addTest("Ref.", ()=>{
|
|
32
|
+
return dot.h(new RefComponent1())
|
|
33
|
+
}, "<div><span>a</span><span>b</span><span>c</span></div>");
|
|
34
|
+
addTest("Nested ref.", ()=>{
|
|
35
|
+
return dot.h(new RefComponent2(new RefComponent1()))
|
|
36
|
+
}, "<div><span>1</span><div><span>a</span><span>b</span><span>c</span></div></div>");
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// import addTest from "./core";
|
|
2
|
+
// import dot from "../src/dothtml";
|
|
3
|
+
// import Component from "../src/component";
|
|
4
|
+
|
|
5
|
+
// class defaultpage extends Component{builder(){return dot.h1("Default")}}
|
|
6
|
+
// class page1 extends Component{builder(){return dot.h1("Page 1.")}}
|
|
7
|
+
// class page2 extends Component{builder(){return dot.h1("Page 2.")}}
|
|
8
|
+
// class page3 extends Component{builder(){return dot.h1("Page 3.").router()}}
|
|
9
|
+
// class page4 extends Component{builder(){return dot.h1("Good.")}}
|
|
10
|
+
// class page5 extends Component{builder(){return dot.h1("Bad.")}}
|
|
11
|
+
// class page6_7 extends Component{builder(){return dot.h1("Page 6/7.")}}
|
|
12
|
+
// class page6 extends Component{builder(){return dot.h1("Page 6.")}}
|
|
13
|
+
// class page7 extends Component{builder(){return dot.h1("Page 7.")}}
|
|
14
|
+
// class awesomepage extends Component{builder(){return dot.h1(params.params.title).p(params.params.body)}}
|
|
15
|
+
// class notfound extends Component{builder(){return dot.h1("Not Found.")}}
|
|
16
|
+
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import addTest from "./core";
|
|
2
|
-
import dot from "../src/
|
|
2
|
+
import dot from "../src/dothtml";
|
|
3
3
|
|
|
4
4
|
dot.resetScopeClass();
|
|
5
5
|
|
|
@@ -15,8 +15,8 @@ addTest("Nested element new document.", function(){ return dot.scopeClass("MYSCO
|
|
|
15
15
|
// I really don't care about this behavior. We can leave it as undefined, or accept the current behavior.
|
|
16
16
|
//addTest("Scoped h.", function(){ return dot.scopeClass("MYSCOPE2", dot.h(dot.div().class("test"))); }, "<div class=\"dot-MYSCOPE2-test\"></div>");
|
|
17
17
|
addTest("Nested scope.", function(){ return dot.scopeClass("MYSCOPE3", dot.div(dot.div().class("test-inner-before").scopeClass("MYSCOPE4", dot.div().class("test-inner"))).class("test-outer")); }, "<div class=\"dot-MYSCOPE3-test-outer\"><div class=\"dot-MYSCOPE3-test-inner-before\"></div><div class=\"dot-MYSCOPE4-test-inner\"></div></div>");
|
|
18
|
-
addTest("Autoscope 1.", function(){ return dot.scopeClass(dot.div().class("test")); }, "<div class=\"dot-10000-test\"></div>");
|
|
19
|
-
addTest("Autoscope 2.", function(){ return dot.scopeClass(dot.div().class("test")); }, "<div class=\"dot-10001-test\"></div>");
|
|
20
|
-
addTest("Autoscope 2 with nest.", function(){ return dot.scopeClass(dot.div(dot.div().class("test2")).class("test")); }, "<div class=\"dot-10002-test\"><div class=\"dot-10002-test2\"></div></div>");
|
|
18
|
+
addTest("Autoscope 1.", function(){ return dot.scopeClass(null, dot.div().class("test")); }, "<div class=\"dot-10000-test\"></div>");
|
|
19
|
+
addTest("Autoscope 2.", function(){ return dot.scopeClass(null, dot.div().class("test")); }, "<div class=\"dot-10001-test\"></div>");
|
|
20
|
+
addTest("Autoscope 2 with nest.", function(){ return dot.scopeClass(null, dot.div(dot.div().class("test2")).class("test")); }, "<div class=\"dot-10002-test\"><div class=\"dot-10002-test2\"></div></div>");
|
|
21
21
|
|
|
22
|
-
addTest("Reset scope.", function(){ dot.resetScopeClass(); return dot.scopeClass(dot.div().class("test")); }, "<div class=\"dot-10000-test\"></div>");
|
|
22
|
+
addTest("Reset scope.", function(){ dot.resetScopeClass(); return dot.scopeClass(null, dot.div().class("test")); }, "<div class=\"dot-10000-test\"></div>");
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import addTest from "./core";
|
|
2
|
+
import dot from "../src/dothtml";
|
|
3
|
+
|
|
4
|
+
addTest("citeE.", function(){ return dot.cite(); }, "<cite></cite>");
|
|
5
|
+
addTest("dataE.", function(){ return dot.data(); }, "<data></data>"); //Element not supported by most browsers.
|
|
6
|
+
addTest("formE.", function(){ return dot.form(); }, "<form></form>");
|
|
7
|
+
addTest("labelE.", function(){ return dot.label(); }, "<label></label>");
|
|
8
|
+
addTest("spanE.", function(){ return dot.span(); }, "<span></span>");
|
|
9
|
+
addTest("summaryE.", function(){ return dot.summary(); }, "<summary></summary>");
|
|
10
|
+
|
|
11
|
+
addTest("citeA.", function(){ return dot.del().quoteCite(1); }, "<del cite=\"1\"></del>");
|
|
12
|
+
addTest("dataA.", function(){ return dot.object().objectData(1); }, "<object data=\"1\"></object>");
|
|
13
|
+
addTest("formA.", function(){ return dot.input().whichForm(1); }, "<input form=\"1\">");
|
|
14
|
+
addTest("labelA.", function(){ return dot.track().trackLabel(1); }, ["<track label=\"1\">", "<track label=\"1\"></track>"]);
|
|
15
|
+
addTest("spanA.", function(){ return dot.col().colSpan(1); }, "<col span=\"1\">");
|
|
16
|
+
addTest("summaryA.", function(){ return dot.table().tableSummary(1); }, "<table summary=\"1\"></table>");
|
|
17
|
+
addTest("optionLabelA.", function(){ return dot.option().optionLabel(1); }, "<option label=\"1\"></option>");
|
|
18
|
+
addTest("acceptCharsetA.", function(){ return dot.form().acceptCharset("utf-8"); }, "<form accept-charset=\"utf-8\"></form>");
|
|
19
|
+
|
|
20
|
+
// These aren't required anymore because all the overlapping names have been resolved.
|
|
21
|
+
// addTest("Smart cite - attribute.", function(){ return dot.del().cite(1); }, "<del cite=\"1\"></del>");
|
|
22
|
+
// addTest("Smart form - attribute.", function(){ return dot.input().form(1); }, "<input form=\"1\">");
|
|
23
|
+
// addTest("Smart label - attribute.", function(){ return dot.track().label(1); }, ["<track label=\"1\">", "<track label=\"1\"></track>"]);
|
|
24
|
+
// addTest("Smart span - attribute.", function(){ return dot.col().span(1); }, "<col span=\"1\">");
|
|
25
|
+
// addTest("Smart summary - attribute.", function(){ return dot.table().summary(1); }, "<table summary=\"1\"></table>");
|
|
26
|
+
// addTest("Smart cite - element.", function(){ return dot.div().cite(); }, "<div></div><cite></cite>");
|
|
27
|
+
// addTest("Smart form - element.", function(){ return dot.div().form(); }, "<div></div><form></form>");
|
|
28
|
+
// addTest("Smart label - element.", function(){ return dot.div().label(); }, "<div></div><label></label>");
|
|
29
|
+
// addTest("Smart span - element.", function(){ return dot.div().span(); }, "<div></div><span></span>");
|
|
30
|
+
// addTest("Smart summary - element.", function(){ return dot.div().summary(); }, "<div></div><summary></summary>");
|
|
31
|
+
// addTest("Smart cite - append to blank.", function(){ return dot.citeE(); }, "<cite></cite>");
|
|
32
|
+
// addTest("Smart form - append to blank.", function(){ return dot.formE(); }, "<form></form>");
|
|
33
|
+
// addTest("Smart label - append to blank.", function(){ return dot.labelE(); }, "<label></label>");
|
|
34
|
+
// addTest("Smart span - append to blank.", function(){ return dot.spanE(); }, "<span></span>");
|
|
35
|
+
// addTest("Smart summary - append to blank.", function(){ return dot.summaryE(); }, "<summary></summary>");
|
|
36
|
+
// addTest("Smart data - basic attribute.", function(){ return dot.object().data(1); }, "<object data=\"1\"></object>");
|
|
37
|
+
|
|
38
|
+
addTest("Smart data - custom attribute.", function(){ return dot.div().customData("a", 1); }, "<div data-a=\"1\"></div>");
|
|
39
|
+
addTest("Span after an image.", function(){ return dot.span("1").img().src("").span("2"); }, "<span>1</span><img src=\"\"><span>2</span>");
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import addTest from "./core";
|
|
2
|
+
import dot from "../src/dothtml";
|
|
3
|
+
|
|
4
|
+
addTest("Styles as a string.", function(){ return dot.t(dot.css.width(400).height(300)); }, "width:400px;height:300px;");
|
|
5
|
+
addTest("String styles a div.", function(){ return dot.div().style(dot.css.width(400).height(300)); }, "<div style=\"width:400px;height:300px;\"></div>");
|
|
6
|
+
|
|
7
|
+
// addTest("Builder styles a div.", function(){ return dot.div().style(css => {
|
|
8
|
+
// css.width(400).height(300);
|
|
9
|
+
// }); }, "<div style=\"width:400px;height:300px;\"></div>");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import addTest from "./core";
|
|
2
|
-
import dot from "../src/
|
|
2
|
+
import dot from "../src/dothtml";
|
|
3
3
|
|
|
4
4
|
addTest("Deferred.", function(){ return dot.div(dot.defer(function(v){v.h(1)}))}, "<div>1</div>");
|
|
5
5
|
// TODO: running
|
|
@@ -10,15 +10,18 @@ addTest("Wait, for nothing.", function(){ return dot.div(1).wait(1, function(){}
|
|
|
10
10
|
addTest("Wait, for a string.", function(){ return dot.div(1).wait(1, "3").div(2); }, "<div>1</div>3<div>2</div>", 25);
|
|
11
11
|
addTest("Wait, for a div.", function(){ return dot.div(1).wait(1, dot.div(3)).div(2); }, "<div>1</div><div>3</div><div>2</div>", 25);
|
|
12
12
|
addTest("Wait, inside a div.", function(){ return dot.div(1).div(dot.wait(1, dot.div(3))).div(2); }, "<div>1</div><div><div>3</div></div><div>2</div>", 25);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
addTest("Wait, for class
|
|
13
|
+
|
|
14
|
+
// Not supported anymore. If required, do something custom in Component.ready.
|
|
15
|
+
// addTest("Wait, for class.", function(){ return dot.div(1).wait(1, dot["class"](3)).div(2); }, "<div class=\"3\">1</div><div>2</div>", 25);
|
|
16
|
+
// addTest("Wait, for class 2.", function(){ return dot.div(dot.div(1).wait(1, dot["class"](3)).div(2)); }, "<div><div class=\"3\">1</div><div>2</div></div>", 25);
|
|
17
|
+
// addTest("Wait, for class, internal.", function(){ return dot.div(dot.wait(1, dot["class"](3))).div(2); }, "<div class=\"3\"></div><div>2</div>", 25);
|
|
18
|
+
|
|
16
19
|
addTest("Wait, for a function.", function(){ return dot.div(1).wait(1, function(){return dot.div(3)}).div(2); }, "<div>1</div><div>3</div><div>2</div>", 25);
|
|
17
20
|
addTest("Wait, append to nothing.", function(){ return dot.wait(1, dot.div(3)); }, "<div>3</div>", 25);
|
|
18
21
|
addTest("Wait, append to nothing, concat 2.", function(){ return dot.wait(1, dot.div(3)).h(2); }, "<div>3</div>2", 25);
|
|
19
22
|
addTest("Wait, append between text nodes.", function(){ return dot.h(1).wait(1, dot.div(3)).h(2); }, "1<div>3</div>2", 25);
|
|
20
23
|
addTest("Wait, out of order.", function(){ return dot.wait(15, dot.div(1)).wait(10, dot.div(2)).wait(5, dot.div(3)); }, "<div>1</div><div>2</div><div>3</div>", 25);
|
|
21
|
-
addTest("Wait, iterate.", function(){ return dot.div(1).wait(1, dot.h("s").iterate(3, "-").h("f")).div(2); }, "<div>1</div>s---f<div>2</div>", 25);
|
|
24
|
+
addTest("Wait, iterate.", function(){ return dot.div(1).wait(1, dot.h("s").iterate(3, ()=>"-").h("f")).div(2); }, "<div>1</div>s---f<div>2</div>", 25);
|
|
22
25
|
addTest("Waitception, early.", function(){ return dot.wait(10, dot.div(dot.wait(50, dot.div(1)))); }, "<div><dothtml-defer></dothtml-defer></div>", 25);
|
|
23
26
|
addTest("Waitception, late, times shouldn't stack.", function(){ return dot.wait(5, dot.div(dot.wait(5, dot.div(1)))); }, "<div><div>1</div></div>", 25);
|
|
24
27
|
// addTest("Waitception, late, times stack for functions 1/2.", function(){ return dot.wait(50, function(){return dot.div(dot.wait(100, dot.div(1)))}); }, "<div><dothtml-defer></dothtml-defer></div>", 75);
|
package/webpack.config.js
CHANGED
|
@@ -4,8 +4,11 @@ module.exports = {
|
|
|
4
4
|
entry: path.resolve(__dirname, "src/index.js"),
|
|
5
5
|
mode: "production",
|
|
6
6
|
target: "web",
|
|
7
|
+
entry: {
|
|
8
|
+
main: "./src/dothtml.ts"
|
|
9
|
+
},
|
|
7
10
|
output: {
|
|
8
|
-
filename: "dothtml.
|
|
11
|
+
filename: "dothtml.js",
|
|
9
12
|
library: {
|
|
10
13
|
//name: "dothtml",
|
|
11
14
|
type: "commonjs2"
|
|
@@ -13,4 +16,13 @@ module.exports = {
|
|
|
13
16
|
path: path.resolve(__dirname, "lib"),
|
|
14
17
|
clean: true,
|
|
15
18
|
},
|
|
19
|
+
resolve: {
|
|
20
|
+
extensions: [".ts"]
|
|
21
|
+
},
|
|
22
|
+
module:{
|
|
23
|
+
rules: [{
|
|
24
|
+
test: /\.ts$/,
|
|
25
|
+
loader: "ts-loader"
|
|
26
|
+
}]
|
|
27
|
+
},
|
|
16
28
|
};
|