dothtml 5.2.2 → 5.2.4

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 (67) hide show
  1. package/lib/dothtml.js +1 -1
  2. package/package.json +2 -1
  3. package/.vscode/launch.json +0 -34
  4. package/.vscode/settings.json +0 -6
  5. package/azure-pipelines.yml +0 -14
  6. package/babel.config.js +0 -1
  7. package/jest.config.ts +0 -207
  8. package/out.md +0 -1340
  9. package/src/arg-callback-obj.ts +0 -76
  10. package/src/built-in-components/nav-link.ts +0 -21
  11. package/src/built-in-components/router.ts +0 -315
  12. package/src/component.ts +0 -415
  13. package/src/dot-util.ts +0 -69
  14. package/src/dot.ts +0 -1147
  15. package/src/dothtml.ts +0 -39
  16. package/src/err.ts +0 -22
  17. package/src/event-bus.ts +0 -39
  18. package/src/i-dot.ts +0 -787
  19. package/src/node-polyfill.ts +0 -11
  20. package/src/observable-array.ts +0 -289
  21. package/src/styling/css-types.ts/css-angle.ts +0 -18
  22. package/src/styling/css-types.ts/css-color.ts +0 -233
  23. package/src/styling/css-types.ts/css-complex.ts +0 -20
  24. package/src/styling/css-types.ts/css-data-type.ts +0 -9
  25. package/src/styling/css-types.ts/css-filter.ts +0 -134
  26. package/src/styling/css-types.ts/css-length.ts +0 -20
  27. package/src/styling/css-types.ts/css-number.ts +0 -12
  28. package/src/styling/css-types.ts/css-percentage.ts +0 -10
  29. package/src/styling/css-types.ts/css-transform.ts +0 -220
  30. package/src/styling/css-types.ts/css-unknown.ts +0 -13
  31. package/src/styling/css-types.ts/css-url.ts +0 -41
  32. package/src/styling/i-dotcss.ts +0 -1198
  33. package/src/styling/style-builder.ts +0 -967
  34. package/src/styling/unit-function-tables.ts +0 -24
  35. package/tsconfig.json +0 -99
  36. package/unittests/advanced-bindings.test.ts +0 -421
  37. package/unittests/array-evaluation.test.ts +0 -7
  38. package/unittests/basic-functionality.test.ts +0 -88
  39. package/unittests/calc.test.ts +0 -6
  40. package/unittests/class-binding.test.ts +0 -227
  41. package/unittests/components/component-decorator.-.ts +0 -14
  42. package/unittests/components/components-data.test.ts +0 -153
  43. package/unittests/components/components.test.ts +0 -258
  44. package/unittests/computed.test.ts +0 -35
  45. package/unittests/core.ts +0 -66
  46. package/unittests/element-and-attribute-coverage.test.ts +0 -472
  47. package/unittests/hooks.test.ts +0 -67
  48. package/unittests/immutable-if.test.ts +0 -19
  49. package/unittests/input-bindings.test.ts +0 -166
  50. package/unittests/integration.test.ts +0 -5
  51. package/unittests/iterations.test.ts +0 -18
  52. package/unittests/logic.test.ts +0 -18
  53. package/unittests/non-function-props-rerender.test.ts +0 -86
  54. package/unittests/refs.test.ts +0 -36
  55. package/unittests/routing.-.ts +0 -56
  56. package/unittests/scopes.test.ts +0 -22
  57. package/unittests/special-tags.test.ts +0 -39
  58. package/unittests/styles.test.ts +0 -9
  59. package/unittests/styling/animations.test.ts +0 -14
  60. package/unittests/styling/filters.test.ts +0 -23
  61. package/unittests/styling/inline-styling.test.ts +0 -18
  62. package/unittests/styling/pseudo-selectors.test.ts +0 -33
  63. package/unittests/styling/transformations.test.ts +0 -234
  64. package/unittests/styling/value-interpretation.test.ts +0 -3
  65. package/unittests/testpage.ts +0 -5
  66. package/unittests/wait.test.ts +0 -31
  67. package/webpack.config.js +0 -28
@@ -1,227 +0,0 @@
1
- import addTest from "./core";
2
- import dot from "../src/dothtml";
3
- import Component from "../src/component";
4
-
5
- addTest("Basic immutable class binding.", function(){
6
- return dot.div().class({
7
- "foo": true,
8
- "bar": false,
9
- "xyz": true
10
- })
11
- }, "<div class=\"foo xyz\"></div>");
12
-
13
- addTest("Class binding to a component property.", function(){
14
- class C extends Component{
15
- constructor(v){
16
- super();
17
- this.props.prop = v;
18
- }
19
- props = {
20
- prop: false
21
- };
22
- builder(){
23
- return dot.div().class({
24
- "foo": ()=>this.props.prop,
25
- "bar": ()=>!this.props.prop,
26
- })
27
- }
28
- ready(){
29
- this.props.prop = !this.props.prop;
30
- }
31
- }
32
-
33
- return dot.h(new C(false)).h(new C(true));
34
-
35
- }, "<div class=\"foo\"></div><div class=\"bar\"></div>");
36
-
37
- addTest("Class binding to a component property with a style.", function(){
38
- class C extends Component{
39
- constructor(v){
40
- super();
41
- this.props.prop = v;
42
- }
43
- props = {
44
- prop: false
45
- };
46
- builder(){
47
- return dot.div().class({
48
- "foo": ()=>this.props.prop,
49
- "bar": ()=>!this.props.prop,
50
- })
51
- }
52
- ready(){
53
- this.props.prop = !this.props.prop;
54
- }
55
- style(css){
56
- css("div").backgroundColor("white");
57
- css(".foo").color("red");
58
- css(".bar").color("blue");
59
- }
60
- }
61
-
62
- return dot.h(new C(false)).h(new C(true));
63
-
64
- }, "<div class=\"foo\" style=\"background-color: rgb(255, 255, 255); color: rgb(255, 0, 0);\"></div><div class=\"bar\" style=\"background-color: rgb(255, 255, 255); color: rgb(0, 0, 255);\"></div>");
65
-
66
- addTest("Remove styles applied by a class.", function(){
67
- class C extends Component{
68
- constructor(v){
69
- super();
70
- this.props.prop = v;
71
- }
72
- props = {
73
- prop: false
74
- };
75
- builder(){
76
- return dot.div().class({
77
- "foo": ()=>this.props.prop,
78
- })
79
- }
80
- ready(){
81
- this.props.prop = !this.props.prop;
82
- }
83
- style(css){
84
- css(".foo").color("red");
85
- }
86
- }
87
-
88
- return dot.h(new C(true));
89
-
90
- }, "<div class=\"\"></div>");
91
- addTest("Remove styles applied by a nested class.", function(){
92
- class C extends Component{
93
- constructor(v){
94
- super();
95
- this.props.prop = v;
96
- }
97
- props = {
98
- prop: false
99
- };
100
- builder(){
101
- return dot.div(
102
- dot.div().class({
103
- "foo": ()=>this.props.prop,
104
- })
105
- )
106
- }
107
- ready(){
108
- this.props.prop = !this.props.prop;
109
- }
110
- style(css){
111
- css(".foo").color("red");
112
- }
113
- }
114
-
115
- return dot.h(new C(true));
116
-
117
- }, "<div><div class=\"\"></div></div>");
118
-
119
- addTest("Remove only dynamic styles applied by a class.", function(){
120
- class C extends Component{
121
- constructor(v){
122
- super();
123
- this.props.prop = v;
124
- }
125
- props = {
126
- prop: false
127
- };
128
- builder(){
129
- return dot.div().class({
130
- "foo": ()=>this.props.prop,
131
- }).style(dot.css.backgroundColor("blue"))
132
- }
133
- ready(){
134
- this.props.prop = !this.props.prop;
135
- }
136
- style(css){
137
- css(".foo").color("red");
138
- }
139
- }
140
-
141
- return dot.h(new C(true));
142
-
143
- }, "<div class=\"\" data-dot-static-styles=\"background-color:rgb(0, 0, 255);\" style=\"background-color:rgb(0, 0, 255);\"></div>");
144
-
145
- addTest("Remove only dynamic styles applied by a nested class.", function(){
146
- class C extends Component{
147
- constructor(v){
148
- super();
149
- this.props.prop = v;
150
- }
151
- props = {
152
- prop: false
153
- };
154
- builder(){
155
- return dot.div(
156
- dot.div().class({
157
- "foo": ()=>this.props.prop,
158
- }).style(dot.css.backgroundColor("blue"))
159
- )
160
- }
161
- ready(){
162
- this.props.prop = !this.props.prop;
163
- }
164
- style(css){
165
- css(".foo").color("red");
166
- }
167
- }
168
-
169
- return dot.h(new C(true));
170
-
171
- }, "<div><div class=\"\" data-dot-static-styles=\"background-color:rgb(0, 0, 255);\" style=\"background-color:rgb(0, 0, 255);\"></div></div>");
172
-
173
- addTest("Dynamic styles contribute to static styles.", function(){
174
- class C extends Component{
175
- constructor(v){
176
- super();
177
- this.props.prop = v;
178
- }
179
- props = {
180
- prop: false
181
- };
182
- builder(){
183
- return dot.div().class({
184
- "foo": ()=>this.props.prop,
185
- }).style(dot.css.backgroundColor("blue"))
186
- }
187
- ready(){
188
- this.props.prop = !this.props.prop;
189
- }
190
- style(css){
191
- css(".foo").color("red");
192
- }
193
- }
194
-
195
- return dot.h(new C(false));
196
-
197
- }, "<div class=\"foo\" data-dot-static-styles=\"background-color:rgb(0, 0, 255);\" style=\"background-color: rgb(0, 0, 255); color: rgb(255, 0, 0);\"></div>");
198
-
199
- addTest("Class based on computed field.", function(){
200
- class C extends Component{
201
- constructor(){
202
- super();
203
- }
204
- props = {
205
- prop: []
206
- };
207
- builder(){
208
- return dot.div().class({
209
- "foo": ()=>this.isFoo,
210
- })
211
- }
212
- get isFoo(){
213
- let value = this.props.prop.length > 0;
214
- return value;
215
- }
216
-
217
- ready(){
218
- this.props.prop.push(1);
219
- }
220
- style(css){
221
- css(".foo").color("red");
222
- }
223
- }
224
-
225
- return dot.h(new C());
226
-
227
- }, "<div class=\"foo\" style=\"color: rgb(255, 0, 0);\"></div>");
@@ -1,14 +0,0 @@
1
- // import addTest from "./core";
2
- // import dot from "../src/dothtml";
3
- // import Component from "../src/component";
4
- // import { IDotElement, IDotGenericElement } from "i-dot";
5
-
6
- // TBD...
7
-
8
- // @component
9
- // class TestComponent implements Component{
10
- // builder(...args: any[]): IDotElement<IDotGenericElement> {
11
- // throw new Error("Method not implemented.");
12
- // }
13
-
14
- // }
@@ -1,153 +0,0 @@
1
- import addTest from "../core";
2
- import dot from "../../src/dothtml";
3
- import Component from "../../src/component";
4
-
5
- // For testing the passing of data into and out of components via properties and events, respectively.
6
-
7
- addTest("Prop default value.", function(){
8
- class MyComp extends Component{
9
- props = {
10
- myProp: 1
11
- }
12
-
13
- builder(){
14
- var ret = dot.span(()=>this.props.myProp);
15
- return ret;
16
- }
17
- };
18
-
19
- var myComp = new MyComp();
20
- return dot.h(myComp);
21
- }, "<span>1</span>");
22
-
23
- addTest("Pass value into component.", function(){
24
- class MyComp extends Component{
25
- props = {
26
- myProp: 0
27
- }
28
-
29
- constructor(){
30
- super();
31
- this.props.myProp = 1;
32
- }
33
-
34
- builder(){
35
- var ret = dot.span(()=>this.props.myProp);
36
- return ret;
37
- }
38
- };
39
-
40
- var myComp = new MyComp();
41
- myComp.props.myProp = 2;
42
- return dot.h(myComp);
43
- }, "<span>2</span>");
44
-
45
- // TODO
46
- // addTest("Binding value into component.", function(){
47
- // const MyComp = dot.component({
48
- // builder(){
49
- // this.myProp = 1;
50
- // var ret = dot.span(()=>this.myProp);
51
- // return ret;
52
- // },
53
- // props:["myProp"]
54
- // });
55
-
56
- // var myComp = MyComp();
57
- // myComp.myProp = 2;
58
- // return dot.h(myComp);
59
- // }, "<span>2</span>");
60
-
61
- addTest("Raise event from component.", function(){
62
- class MyComp extends Component{
63
- props = {
64
- myProp: 0
65
- }
66
-
67
- // events:["go"],
68
- events = {
69
- go: (number)=>undefined
70
- }
71
-
72
- constructor(){
73
- super();
74
- this.props.myProp = 1;
75
- }
76
-
77
- builder(){
78
- var ret = dot.span(()=>this.props.myProp);
79
- return ret;
80
- }
81
-
82
- ready(){
83
- this.events.go(5);
84
- }
85
- }
86
-
87
- var myComp = new MyComp();
88
- myComp.props.myProp = 2;
89
- myComp.on("go", x=>{
90
- myComp.props.myProp=x
91
- });
92
- // Experimented with this syntax.
93
- // myComp.on(myComp.events.go, ()=>{})
94
- return dot.h(myComp);
95
- }, "<span>5</span>");
96
-
97
- addTest("Raise 2 events from component.", function(){
98
- class MyComp extends Component{
99
- constructor(){
100
- super();
101
- this.props.myProp = 1;
102
- }
103
- builder(){
104
- var ret = dot.span(()=>this.props.myProp);
105
- return ret;
106
- }
107
-
108
- props = {
109
- myProp: 0
110
- }
111
-
112
- events = {
113
- go2: (number) => undefined
114
- }
115
-
116
- ready(){
117
- this.events.go2("3");
118
- this.events.go2("4");
119
- }
120
- }
121
-
122
- var myComp = new MyComp();
123
- myComp.props.myProp = 2;
124
- myComp.on("go2", x=>myComp.props.myProp+=x);
125
- return dot.h(myComp);
126
- }, "<span>234</span>");
127
-
128
- addTest("Call a method from outside a component.", function(){
129
- class MyComp extends Component{
130
- constructor(){
131
- super();
132
- this.props.myProp = 1;
133
- }
134
- builder(){
135
- var ret = dot.span(()=>this.props.myProp);
136
- return ret;
137
- }
138
- props={
139
- myProp: 0
140
- };
141
-
142
- go(v){
143
- this.props.myProp = v;
144
- }
145
-
146
-
147
- }
148
-
149
- var myComp = new MyComp();
150
- myComp.props.myProp = 2;
151
- myComp.go(5);
152
- return dot.h(myComp);
153
- }, "<span>5</span>");
@@ -1,258 +0,0 @@
1
- import addTest from "../core";
2
- import dot, { DotComponent } from "../../src/dothtml";
3
- import Component from "../../src/component";
4
-
5
- class comp_legacy extends dot.Component{
6
-
7
- builder(){
8
- return dot.div(dot.div(1));
9
- }
10
- }
11
- class comp_std extends dot.Component{
12
- builder(){
13
- return dot.div(dot.div(1));
14
- }
15
- }
16
- class comp_ready extends dot.Component{
17
- builder(){
18
- return dot.div(dot.div(1));
19
- }
20
-
21
- ready(){
22
- this.$el.innerHTML = "OKAY";
23
- }
24
- }
25
-
26
- class comp_el_one_el extends dot.Component{
27
- builder(){
28
- return dot.div("abc");
29
- }
30
- }
31
-
32
- class comp_el_two_el extends dot.Component{
33
- builder(){
34
- return dot.div("abc").div("abc");
35
- }
36
- }
37
-
38
- abstract class ParameterizedComponent extends dot.Component{
39
- params: Array<any>;
40
- constructor(...params: Array<any>){
41
- super();
42
- this.params = params;
43
- }
44
- }
45
-
46
- // class comp_el_deferred_el extends dot.Component{
47
- // builder(){
48
- // return dot.div("abc").wait(function(){}, 1000);
49
- // }
50
- // }
51
-
52
- // Testing methods:
53
- // TODO: passing callMethod in like this will soon be deprecated.
54
- class comp_methods_basic extends dot.Component{
55
- callMethod: boolean;
56
- constructor(callMethod: boolean){
57
- super();
58
- this.callMethod = callMethod;
59
- }
60
-
61
- builder(){
62
- return dot.div("123");
63
- }
64
-
65
- ready(){
66
- if(this.callMethod) this.setVal("abc");
67
- }
68
- setVal(val){
69
- dot(this.$el).empty().t(val);
70
- }
71
- };
72
-
73
- // Scoped classes
74
- dot.resetScopeClass();
75
- class comp_scoped_class extends dot.Component{
76
- builder(){
77
- return dot.div(dot.div().class("test2")).class("test1")
78
- }
79
- };
80
- class comp_scoped_class_2 extends dot.Component{
81
- builder(){ return dot.div(dot.div().class("test2")).class("test1") }
82
- };
83
-
84
-
85
- // Nameless components (exports):
86
- //addTest("Nameless component.", function(){ var comp = dot.component({builder: function(c){return dot.p(c)} }); return dot.div(comp(":)")) }, "<div><p>:)</p></div>");
87
- // This behavior was deprecated.
88
- //addTest("Nameless component as a dot function.", function(){ var comp = dot.component({builder: function(c){return dot.p(c)} }); return comp(":)") }, "<p>:)</p>" );
89
-
90
- // Named components (extend dot):
91
- addTest("Std params component.", function(){return dot.h(new comp_std())}, "<div><div>1</div></div>");
92
- // 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>");
93
- // addTest("Std prams component beside markup.", function(){return dot.h(2).comp_std().h(3)}, "2<div><div>1</div></div>3");
94
- addTest("Legacy params component.", function(){return dot.h(new comp_legacy())}, "<div><div>1</div></div>");
95
- addTest("Component w/ ready method.", function(){return dot.h(new comp_ready())}, "<div>OKAY</div>");
96
- // addTest("Text component.", function(){return dot.h("a").comp_text().h("b")}, "a1b");
97
- //addTest("Text component w/ ready method.", function(){return dot.h("a").comp_textreplace().h("b")}, "a2b");
98
-
99
- // $el
100
- // addTest("Undefined $el.", function(){try{return new comp_el_undefined_el()}catch(e){return dot.span(e)}}, "<span>Component 'comp_el_undefined_el' must return exactly one child node.</span>");
101
- // addTest("Zero $el.", function(){try{return new comp_el_zero_el()}catch(e){return dot.span(e)}}, "<span>Component 'comp_el_zero_el' must return exactly one child node.</span>");
102
- addTest("One $el.", function(){return dot.h( new comp_el_one_el())}, "<div>abc</div>");
103
- addTest("Two $el.", function(){try{return dot.h( new comp_el_two_el())}catch(e){return dot.span(e)}}, "<span>Component 'comp_el_two_el' must return exactly one child node.</span>");
104
- // addTest("Deferred $el.", function(){try{return new comp_el_deferred_el()}catch(e){return dot.span(e)}}, "<span>Component 'comp_el_deferred_el' must return exactly one child node.</span>");
105
- // addTest("One $el.", function(){return new comp_el_text_zero_el()}, "abc");
106
- // addTest("One $el.", function(){return new comp_el_text_one_el()}, "<div>abc</div>");
107
- // addTest("Undefined $el.", function(){try{return new 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>");
108
-
109
- // methods
110
- addTest("Instantiate comp w/ method.", function(){return dot.h(new comp_methods_basic(false))}, "<div>123</div>");
111
- addTest("Method gets called in ready function.", function(){return dot.h(new comp_methods_basic(true))}, "<div>abc</div>"); // TODO: this functionality will soon be removed in favor of params.
112
-
113
-
114
- // TODO: setup this test and get it working.
115
- // addTest("Computed property w/ updated dependency.", function(){
116
- // let comp = dot.component({
117
- // builder: function(firstName,lastName){this.firstName = firstName; this.lastName = lastName; return dot.p(this.fullName.toUpperCase())},
118
- // computed: {
119
- // fullName: function(){
120
- // console.log("GETTING COMPUTED PROP!");
121
- // return this.firstName + " " + this.lastName;
122
- // }
123
- // }
124
- // });
125
- // return dot.h(comp("J","S"));
126
- // },"<p>J S</p>");
127
-
128
-
129
- // Events // TODO: get these working.
130
- // addTest(
131
- // "Named events work.",
132
- // function(){
133
- // let comp = dot.component({
134
- // builder: function(a,b){this.a = a; this.b = b; return dot.p(a+b)},
135
- // events: ["sumReady"],
136
- // methods: {trigger: function(){this.sumReady(this.a+this.b);}},
137
- // });
138
- // let sumResult = 0;
139
- // let c = comp(1,2).sumReady(function(v){ console.log("CALLING EVENT!!");sumResult = v});
140
- // c.trigger();
141
- // return dot.p(sumResult);
142
- // },
143
- // "<p>3</p>"
144
- // );
145
-
146
- // Scoped classes
147
- // TODO: the tests work in browser, but seem to happen out of order in jest...
148
- // addTest("Component class scope.", function(){return dot.comp_scoped_class()}, "<div class=\"dot-10000-test1\"><div class=\"dot-10000-test2\"></div></div>");
149
- // addTest("Component class scope reuse.", function(){return dot.comp_scoped_class()}, "<div class=\"dot-10000-test1\"><div class=\"dot-10000-test2\"></div></div>");
150
- // addTest("Component class scope alt.", function(){return dot.comp_scoped_class_2()}, "<div class=\"dot-10001-test1\"><div class=\"dot-10001-test2\"></div></div>");
151
-
152
- // Styles
153
- addTest("Set style directly", function(){var ret = dot.p(":)").style("width:100px;"); return ret;}, "<p style=\"width:100px;\">:)</p>");
154
- addTest("Set style via dotcss", function(){var ret = dot.p(":)").style(dot.css.width(100)); return ret;}, "<p style=\"width:100px;\">:)</p>");
155
-
156
- addTest("Styled component.", function(){
157
- class comp extends ParameterizedComponent{
158
- builder(){
159
- return dot.p(this.params[0]);
160
- }
161
- style(css){
162
- css("p").width(100);
163
- }
164
- }
165
- return dot.h(new comp(":)")) }, "<p style=\"width: 100px;\">:)</p>"
166
- );
167
-
168
- addTest("Advanced styled component.", function(){
169
- class comp extends ParameterizedComponent{
170
- builder(){
171
- return dot.p(this.params[0])
172
- }
173
- style(css){
174
- css("p").width(100);
175
- }
176
- }
177
- return dot.h(new comp(":)")).h(new comp(":)"))
178
- }, "<p style=\"width: 100px;\">:)</p><p style=\"width: 100px;\">:)</p>" );
179
-
180
- addTest("Component with multiple styles.", function(){
181
- class comp extends ParameterizedComponent{
182
- builder(){
183
- return dot.p(this.params[0])
184
- }
185
- style(css){
186
- css("p").width(this.params[1]);
187
- }
188
- }
189
- return dot.h(new comp(":)", 200)).h(new comp(":)", 300))
190
- }, "<p style=\"width: 200px;\">:)</p><p style=\"width: 300px;\">:)</p>" );
191
-
192
- addTest("Component with class styles.", function(){
193
- class comp extends ParameterizedComponent{
194
- builder(){
195
- return dot.div(
196
- dot.div(this.params[0])
197
- .div("w").class("w")
198
- .div("ok").class("h")
199
- ).class("w");
200
- }
201
- style(css){
202
- css(".w").width(this.params[1]);css(".h").width(this.params[2]);
203
- }
204
- }
205
- return dot.h(new comp(":)", 200, 400)).h(new comp(":)", 300, 500)).div().class("h");
206
- }, "<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>" );
207
-
208
- addTest("Styles should not apply to nested elements.", function(){
209
- class CompOuter extends ParameterizedComponent{
210
- builder(){
211
- return dot.div(this.params[0]);
212
- }
213
- style(css){
214
- // console.log("CSS???", !!css);
215
- css("div").backgroundColor("#FF0000");
216
- }
217
- };
218
-
219
- class CompInner extends DotComponent{
220
- builder(){
221
- return dot.div("FOOBAR");
222
- }
223
- };
224
-
225
- return dot.h(new CompOuter(new CompInner()))
226
- }, "<div style=\"background-color: rgb(255, 0, 0);\"><div>FOOBAR</div></div>");
227
-
228
- addTest("Styles should not apply to nested elements 2.", function(){
229
- class CompOuter extends ParameterizedComponent{
230
- builder(){
231
- return dot.div(this.params[0]);
232
- }
233
- style(css){
234
- css("div").backgroundColor("#FF0000");
235
- }
236
- }
237
-
238
- class CompInner extends dot.Component{
239
- builder(){return dot.div(dot.div("FOOBAR"));}
240
- }
241
-
242
- return dot.h(new CompOuter(new CompInner()))
243
- }, "<div style=\"background-color: rgb(255, 0, 0);\"><div><div>FOOBAR</div></div></div>");
244
-
245
- // Event Bus
246
-
247
- addTest("Event bus basic usage.", function(){
248
- class comp1 extends dot.Component{
249
- builder(){
250
- var t = this;
251
- dot.bus.on("change", function(v){t.$el.innerHTML = v});
252
- return dot.p();
253
- }
254
- }
255
-
256
- var ret = dot.h(new comp1()); dot.bus.emit("change", "hello");
257
- return ret;
258
- }, "<p>hello</p>");
@@ -1,35 +0,0 @@
1
- import addTest from "./core";
2
- import dot from "../src/dothtml";
3
- import Component from "../src/component";
4
-
5
- class Comp extends Component{
6
- props={
7
- firstName: "",
8
- lastName: ""
9
- }
10
- constructor(firstName, lastName){
11
- super();
12
- this.props.firstName = firstName;
13
- this.props.lastName = lastName;
14
-
15
- }
16
- builder(){
17
- return dot.p(()=>this.fullName.toUpperCase())
18
- }
19
- get fullName(){
20
- return (this.props.firstName||"notset") + " " + (this.props.lastName||"notset");
21
- }
22
- }
23
- addTest("Computed property.", function(){
24
-
25
- return dot.h( new Comp("J","S")).h(new Comp("1","2"));
26
- },"<p>J S</p><p>1 2</p>");
27
-
28
- addTest("Computed property w/ prop dependency.", function(){
29
-
30
- var instance = new Comp("x", "y");
31
- var ret = dot.h(instance);
32
- instance.props.firstName = "j";
33
- instance.props.lastName = "s";
34
- return ret;
35
- },"<p>J S</p>");