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.
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 +821 -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 +911 -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
@@ -13,10 +13,11 @@ function formatHTML(html){
13
13
  html = html.split(" value=\"\"").join("");
14
14
  html = html.split(" type=submit").join("");
15
15
  html = html.split("\"").join("");
16
+ html = html.split("\'").join("");
16
17
  return html;
17
18
  }
18
19
 
19
- export default function addTest(description, testFunc, expected, testTimeout){
20
+ export default function addTest(description: string, testFunc: Function, expected: string|Array<string>, testTimeout?: number){
20
21
  //if(description != "Conditional rendering - if true->false elseif false->true.") return;
21
22
  // let exception = null;
22
23
  // try{
@@ -43,7 +44,9 @@ export default function addTest(description, testFunc, expected, testTimeout){
43
44
  let testExpected = formatHTML(expected[i]);
44
45
  if(testExpected == processedResult) break;
45
46
  }
46
- if(!i == expected.length) i = 0;
47
+ // Not sure how this was supposed to work???
48
+ // if(!i == expected.length) i = 0;
49
+ if(i == expected.length) i = 0;
47
50
  expect(processedResult).toBe(formatHTML(expected[i]));
48
51
  }
49
52
  else{
@@ -0,0 +1,472 @@
1
+ import dot from "../src/dot";
2
+ import addTest from "./core";
3
+ var dotDocuments = [...new Set([
4
+ "as",
5
+ "el",
6
+ "h",
7
+ "t",
8
+ "iterate",
9
+ "each",
10
+ "remove",
11
+ "getLast",
12
+ "empty",
13
+ "script",
14
+ "when",
15
+ "otherwiseWhen",
16
+ "otherwise",
17
+ "a",
18
+ "aside",
19
+ "abbr",
20
+ "address",
21
+ "area",
22
+ "article",
23
+ "audio",
24
+ "b",
25
+ "bdi",
26
+ "bdo",
27
+ "blockQuote",
28
+ "body",
29
+ "br",
30
+ "button",
31
+ "canvas",
32
+ "caption",
33
+ "cite",
34
+ "code",
35
+ "col",
36
+ "colGroup",
37
+ "content",
38
+ "data",
39
+ "dataList",
40
+ "dd",
41
+ "del",
42
+ "details",
43
+ "dfn",
44
+ "dialog",
45
+ "div",
46
+ "dl",
47
+ "dt",
48
+ "em",
49
+ "embed",
50
+ "fieldSet",
51
+ "figCaption",
52
+ "figure",
53
+ "footer",
54
+ "form",
55
+ "h1",
56
+ "h2",
57
+ "h3",
58
+ "h4",
59
+ "h5",
60
+ "h6",
61
+ "header",
62
+ "hr",
63
+ "i",
64
+ "iFrame",
65
+ "img",
66
+ "input",
67
+ "ins",
68
+ "kbd",
69
+ "keyGen",
70
+ "label",
71
+ "legend",
72
+ "li",
73
+ "main",
74
+ "map",
75
+ "mark",
76
+ "menu",
77
+ "meter",
78
+ "nav",
79
+ "object",
80
+ "ol",
81
+ "optGroup",
82
+ "option",
83
+ "output",
84
+ "p",
85
+ "param",
86
+ "pre",
87
+ "progress",
88
+ "q",
89
+ "rp",
90
+ "rt",
91
+ "ruby",
92
+ "s",
93
+ "samp",
94
+ "section",
95
+ "select",
96
+ "small",
97
+ "source",
98
+ "span",
99
+ "strong",
100
+ "svg",
101
+ "sub",
102
+ "summary",
103
+ "sup",
104
+ "table",
105
+ "tBody",
106
+ "td",
107
+ "textArea",
108
+ "tFoot",
109
+ "th",
110
+ "tHead",
111
+ "time",
112
+ "tr",
113
+ "track",
114
+ "u",
115
+ "ul",
116
+ "var",
117
+ "video",
118
+ "wbr"
119
+ ])];
120
+
121
+ var dotElements = [...new Set([
122
+ "attr",
123
+ "scopeClass",
124
+ "bgColor",
125
+ "color",
126
+ "aLink",
127
+ "archive",
128
+ "accessKey",
129
+ "class",
130
+ "contentEditable",
131
+ "dir",
132
+ "draggable",
133
+ "dropZone",
134
+ "hidden",
135
+ "id",
136
+ "itemProp",
137
+ "lang",
138
+ "spellCheck",
139
+ "style",
140
+ "tabIndex",
141
+ "title",
142
+ "onHashChange",
143
+ "onOffline",
144
+ "onOnline",
145
+ "onPageHide",
146
+ "onPageShow",
147
+ "onPopState",
148
+ "onResize",
149
+ "onStorage",
150
+ "onSearch",
151
+ "onToggle",
152
+ "onAbort",
153
+ "onCantPlayThrough",
154
+ "onDurationChange",
155
+ "onEmptied",
156
+ "onEnded",
157
+ "onLoadedData",
158
+ "onLoadStart",
159
+ "onLoadedMetadata",
160
+ "onPause",
161
+ "onPlay",
162
+ "onPlaying",
163
+ "onProgress",
164
+ "onRateChange",
165
+ "onSeeked",
166
+ "onSeeking",
167
+ "onStalled",
168
+ "onSuspend",
169
+ "onTimeUpdate",
170
+ "onVolumeChange",
171
+ "onWaiting",
172
+ "onCanPlay",
173
+ "onContextMenu",
174
+ "onCopy",
175
+ "onCut",
176
+ "onPagePaste",
177
+ "onCueChange",
178
+ "onDrag",
179
+ "onDragEnd",
180
+ "onDragStart",
181
+ "onDragEnter",
182
+ "onDragOver",
183
+ "onDragLeave",
184
+ "onDrop",
185
+ "onError",
186
+ "onInvalid",
187
+ "onMouseWheel",
188
+ "onWheel",
189
+ "onBlur",
190
+ "onChange",
191
+ "onClick",
192
+ "onDblClick",
193
+ "onFocus",
194
+ "onInput",
195
+ "onKeyDown",
196
+ "onKeyPress",
197
+ "onKeyUp",
198
+ "onLoad",
199
+ "onMouseDown",
200
+ "onMouseEnter",
201
+ "onMouseMove",
202
+ "onMouseOut",
203
+ "onMouseOver",
204
+ "onMouseUp",
205
+ "onReset",
206
+ "onScroll",
207
+ "onSelect",
208
+ "onSubmit",
209
+ "onUnload",
210
+ "download",
211
+ "hRef",
212
+ "hRefLang",
213
+ "media",
214
+ "ping",
215
+ "rel",
216
+ "rev",
217
+ "target",
218
+ "type",
219
+ "alt",
220
+ "coords",
221
+ "download",
222
+ "media",
223
+ "noHRef",
224
+ "rel",
225
+ "shape",
226
+ "target",
227
+ "autoPlay",
228
+ "buffered",
229
+ "controls",
230
+ "loop",
231
+ "muted",
232
+ "preload",
233
+ "src",
234
+ "pause",
235
+ "play",
236
+ "stop",
237
+ "quoteCite",
238
+ "align",
239
+ "background",
240
+ "clear",
241
+ "autoFocus",
242
+ "formAction",
243
+ "disabled",
244
+ "name",
245
+ "type",
246
+ "whichForm",
247
+ "value",
248
+ "height",
249
+ "width",
250
+ "charOff",
251
+ "colSpan",
252
+ "vAlign",
253
+ "charOff",
254
+ "colSpan",
255
+ "vAlign",
256
+ "dateTime",
257
+ "quoteCite",
258
+ "open",
259
+ "height",
260
+ "src",
261
+ "type",
262
+ "width",
263
+ "disabled",
264
+ "name",
265
+ "whichForm",
266
+ "acceptCharset",
267
+ "action",
268
+ "autoComplete",
269
+ "encType",
270
+ "method",
271
+ "name",
272
+ "noValidate",
273
+ "rel",
274
+ "target",
275
+ "noShade",
276
+ "height",
277
+ "longDesc",
278
+ "marginHeight",
279
+ "marginWidth",
280
+ "name",
281
+ "sandbox",
282
+ "scrolling",
283
+ "seamless",
284
+ "src",
285
+ "srcDoc",
286
+ "width",
287
+ "alt",
288
+ "height",
289
+ "hSpace",
290
+ "isMap",
291
+ "longDesc",
292
+ "sizes",
293
+ "src",
294
+ "srcSet",
295
+ "useMap",
296
+ "width",
297
+ "accept",
298
+ "alt",
299
+ "autoComplete",
300
+ "autoFocus",
301
+ "checked",
302
+ "dirName",
303
+ "disabled",
304
+ "formAction",
305
+ "list",
306
+ "max",
307
+ "maxLength",
308
+ "min",
309
+ "multiple",
310
+ "name",
311
+ "pattern",
312
+ "placeholder",
313
+ "readOnly",
314
+ "required",
315
+ "size",
316
+ "src",
317
+ "step",
318
+ "type",
319
+ "whichForm",
320
+ "value",
321
+ "width",
322
+ "bindTo",
323
+ "getVal",
324
+ "setVal",
325
+ "dateTime",
326
+ "quoteCite",
327
+ "challenge",
328
+ "keyType",
329
+ "for",
330
+ "whichForm",
331
+ "value",
332
+ "name",
333
+ "type",
334
+ "high",
335
+ "low",
336
+ "max",
337
+ "min",
338
+ "optimum",
339
+ "whichForm",
340
+ "value",
341
+ "classId",
342
+ "codeBase",
343
+ "codeType",
344
+ "objectData",
345
+ "declare",
346
+ "height",
347
+ "name",
348
+ "standby",
349
+ "type",
350
+ "useMap",
351
+ "whichForm",
352
+ "width",
353
+ "reversed",
354
+ "start",
355
+ "disabled",
356
+ "disabled",
357
+ "optionLabel",
358
+ "selected",
359
+ "value",
360
+ "bindTo",
361
+ "getVal",
362
+ "setVal",
363
+ "for",
364
+ "name",
365
+ "whichForm",
366
+ "name",
367
+ "value",
368
+ "valueType",
369
+ "max",
370
+ "value",
371
+ "quoteCite",
372
+ "autoFocus",
373
+ "disabled",
374
+ "multiple",
375
+ "name",
376
+ "required",
377
+ "size",
378
+ "whichForm",
379
+ "bindTo",
380
+ "getVal",
381
+ "setVal",
382
+ "media",
383
+ "src",
384
+ "type",
385
+ "sizes",
386
+ "src",
387
+ "srcSet",
388
+ "type",
389
+ "border",
390
+ "cellPadding",
391
+ "cellSpacing",
392
+ "frame",
393
+ "rules",
394
+ "tableSummary",
395
+ "autoFocus",
396
+ "cols",
397
+ "dirName",
398
+ "disabled",
399
+ "maxLength",
400
+ "name",
401
+ "placeholder",
402
+ "readOnly",
403
+ "required",
404
+ "rows",
405
+ "whichForm",
406
+ "wrap",
407
+ "bindTo",
408
+ "getVal",
409
+ "setVal",
410
+ "charOff",
411
+ "vAlign",
412
+ "axis",
413
+ "char",
414
+ "colSpan",
415
+ "charOff",
416
+ "headers",
417
+ "nowrap",
418
+ "rowSpan",
419
+ "vAlign",
420
+ "charOff",
421
+ "vAlign",
422
+ "dateTime",
423
+ "axis",
424
+ "colSpan",
425
+ "charOff",
426
+ "headers",
427
+ "rowSpan",
428
+ "scope",
429
+ "vAlign",
430
+ "charOff",
431
+ "vAlign",
432
+ "charOff",
433
+ "vAlign",
434
+ "default",
435
+ "kind",
436
+ "src",
437
+ "srcLang",
438
+ "trackLabel",
439
+ "autoPlay",
440
+ "buffered",
441
+ "controls",
442
+ "height",
443
+ "loop",
444
+ "muted",
445
+ "poster",
446
+ "preload",
447
+ "src",
448
+ "width",
449
+ "pause",
450
+ "play",
451
+ "stop",
452
+ ])];
453
+
454
+ for(let s of dotDocuments){
455
+ addTest(`${s} - core`, ()=>{
456
+ return dot.t(typeof dot[s])
457
+ }, "function");
458
+ addTest(`${s} - query`, ()=>{
459
+ return dot.t(typeof dot("body")[s])
460
+ }, "function");
461
+ addTest(`${s} - next`, ()=>{
462
+ return dot.t(typeof dot.div()[s])
463
+ }, "function");
464
+ }
465
+ for(let s of dotElements){
466
+ addTest(`${s} - query`, ()=>{
467
+ return dot.t(typeof dot("body")[s])
468
+ }, "function");
469
+ addTest(`${s} - next`, ()=>{
470
+ return dot.t(typeof dot.div()[s])
471
+ }, "function");
472
+ }
@@ -0,0 +1,67 @@
1
+ import addTest from "./core";
2
+ import dot from "../src/dothtml";
3
+ import Component from "../src/component";
4
+
5
+ // Testing hooks:
6
+ // class CompHooksRegister extends Component{
7
+ // x: number = 0;
8
+ // add: boolean = false;
9
+
10
+ // register(){ this.x = (this.x || 0); this.add1(); }
11
+ // builder(x, add){this.x = x||this.x; this.add = add||this.add; if(this.add)this.add1(); return dot.div(this.x) }
12
+ // add1(){ this.x++ }
13
+ // }
14
+
15
+ class CompHooksCreate extends Component{
16
+ myEl: Element;
17
+ testVal: any;
18
+ created(val){ this.myEl = this.$el; this.testVal = val }
19
+ builder(){ return dot.div("val: " + this.testVal + ", hadEl: " + (this.myEl ? "yes" : "no")) }
20
+ }
21
+
22
+ class CompHooksDelete extends Component{
23
+ deleteMe: boolean;
24
+ addEarlyMessage: boolean;
25
+ addLateMessage: boolean;
26
+ messageInSibling: string;
27
+ parent: ChildNode | ParentNode;
28
+
29
+ created(deleteMe: boolean, addEarlyMessage: boolean, addLateMessage: boolean, messageInSibling: string){
30
+ this.deleteMe = deleteMe;
31
+ this.addEarlyMessage = addEarlyMessage;
32
+ this.addLateMessage = addLateMessage;
33
+ this.messageInSibling = messageInSibling;
34
+ }
35
+ builder(){ return dot.span("not deleted"); }
36
+ ready(){ this.parent = this.messageInSibling ? this.$el.parentNode.nextSibling : this.$el.parentNode; if(this.deleteMe) dot(this.parent).empty(); }
37
+ deleting(){
38
+ if(this.addEarlyMessage) dot(this.messageInSibling ? this.$el.parentNode.nextSibling : this.$el.parentNode ).p("deleted");
39
+ }
40
+ deleted(){ if(this.addLateMessage) dot(this.parent).b(this.$el ? "failure" : "success"); }
41
+ }
42
+
43
+ // register
44
+ // I guess these are no longer valid.
45
+ // addTest("Register hook gets called once.", function(){return dot.h(new CompHooksRegister())}, "<div>1</div>");
46
+ // addTest("Register hook gets called only once.", function(){return dot.h(new CompHooksRegister())}, "<div>1</div>");
47
+ // addTest("Prototype vars set by register cook can be updated.", function(){return dot.h(new CompHooksRegister(true))}, "<div>2</div>");
48
+ // addTest("Prototype vars are cloned from prototype.", function(){return dot.h(new CompHooksRegister())}, "<div>1</div>"); // Kind of a weird javascript behavior. Cool though.
49
+
50
+ // create
51
+ addTest("Created hook.", function(){return dot.h(new CompHooksCreate("abc"));}, "<div>val: abc, hadEl: no</div>");
52
+
53
+ // delete
54
+ addTest("Delete hook doesn't get called right away.", function(){return dot.div(new CompHooksDelete());}, "<div><span>not deleted</span></div>");
55
+ addTest("Deleting hook.", function(){return dot.div(new CompHooksDelete(true, true));}, "<div><p>deleted</p></div>");
56
+ addTest("Deleted hook.", function(){return dot.div(new CompHooksDelete(true, false, true));}, "<div><b>success</b></div>");
57
+
58
+ //Ensure deletion happens for inner components when using remove.
59
+ addTest("Nested deleting via remove().", function(){ return dot.h(function(){ var ret = dot.i().div(
60
+ new CompHooksDelete(false, true, false, true)
61
+ ); var del = ret.getLast();
62
+ ret = ret.b(); setTimeout(function(){dot(del).remove() }, 0); return ret; }) }, "<i></i><b><p>deleted</p></b>");
63
+
64
+ addTest("Nested deleted via remove().", function(){ return dot.h(function(){ var ret = dot.i().div(
65
+ new CompHooksDelete(false, false, true, true)
66
+ ); var del = ret.getLast();
67
+ ret = ret.b(); setTimeout(function(){dot(del).remove() }, 0); return ret; }) }, "<i></i><b><b>success</b></b>");
@@ -0,0 +1,19 @@
1
+ import addTest from "./core";
2
+ import dot from "../src/dothtml";
3
+
4
+ addTest("Conditional true.", function(){ return dot.h(1).when(true, dot.h("true")).h(2); }, "1true2");
5
+ addTest("Conditional false.", function(){ return dot.h(1).when(false, dot.h("false")).h(2); }, "12");
6
+ addTest("Conditional true true.", function(){ return dot.h(1).when(true, dot.h(2)).when(true, dot.h(3)).h(4); }, "1234");
7
+
8
+ // No longer valid - use class bindings.
9
+ //addTest("Conditional class.", function(){ return dot.div(1).when(true, dot["class"](2)); }, "<div class=\"2\">1</div>");
10
+
11
+ //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.
12
+ //addTest("Conditional deep class.", function(){ return dot.div(1).when(true, dot.when(true, dot["class"](2))); }, "<div class=\"2\">1</div>");
13
+ //addTest("Conditional deep class with more confusion.", function(){ return dot.div(1).when(true, dot.when(true, dot["class"](2)).div(3)); }, "<div class=\"2\">1</div><div>3</div>");
14
+
15
+ // Truthiness.
16
+
17
+ // No longer valid in ts.
18
+ // addTest("If null.", function(){ return dot.when(null, "if").otherwise("else"); }, "else");
19
+ // addTest("If {}.", function(){ return dot.when({}, "if").otherwise("else"); }, "if");