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.
- package/lib/dothtml.js +1 -1
- package/package.json +2 -1
- package/.vscode/launch.json +0 -34
- package/.vscode/settings.json +0 -6
- package/azure-pipelines.yml +0 -14
- package/babel.config.js +0 -1
- package/jest.config.ts +0 -207
- package/out.md +0 -1340
- package/src/arg-callback-obj.ts +0 -76
- package/src/built-in-components/nav-link.ts +0 -21
- package/src/built-in-components/router.ts +0 -315
- package/src/component.ts +0 -415
- package/src/dot-util.ts +0 -69
- package/src/dot.ts +0 -1147
- package/src/dothtml.ts +0 -39
- package/src/err.ts +0 -22
- package/src/event-bus.ts +0 -39
- package/src/i-dot.ts +0 -787
- package/src/node-polyfill.ts +0 -11
- package/src/observable-array.ts +0 -289
- package/src/styling/css-types.ts/css-angle.ts +0 -18
- package/src/styling/css-types.ts/css-color.ts +0 -233
- package/src/styling/css-types.ts/css-complex.ts +0 -20
- package/src/styling/css-types.ts/css-data-type.ts +0 -9
- package/src/styling/css-types.ts/css-filter.ts +0 -134
- package/src/styling/css-types.ts/css-length.ts +0 -20
- package/src/styling/css-types.ts/css-number.ts +0 -12
- package/src/styling/css-types.ts/css-percentage.ts +0 -10
- package/src/styling/css-types.ts/css-transform.ts +0 -220
- package/src/styling/css-types.ts/css-unknown.ts +0 -13
- package/src/styling/css-types.ts/css-url.ts +0 -41
- package/src/styling/i-dotcss.ts +0 -1198
- package/src/styling/style-builder.ts +0 -967
- package/src/styling/unit-function-tables.ts +0 -24
- package/tsconfig.json +0 -99
- package/unittests/advanced-bindings.test.ts +0 -421
- package/unittests/array-evaluation.test.ts +0 -7
- package/unittests/basic-functionality.test.ts +0 -88
- package/unittests/calc.test.ts +0 -6
- package/unittests/class-binding.test.ts +0 -227
- package/unittests/components/component-decorator.-.ts +0 -14
- package/unittests/components/components-data.test.ts +0 -153
- package/unittests/components/components.test.ts +0 -258
- package/unittests/computed.test.ts +0 -35
- package/unittests/core.ts +0 -66
- package/unittests/element-and-attribute-coverage.test.ts +0 -472
- package/unittests/hooks.test.ts +0 -67
- package/unittests/immutable-if.test.ts +0 -19
- package/unittests/input-bindings.test.ts +0 -166
- package/unittests/integration.test.ts +0 -5
- package/unittests/iterations.test.ts +0 -18
- package/unittests/logic.test.ts +0 -18
- package/unittests/non-function-props-rerender.test.ts +0 -86
- package/unittests/refs.test.ts +0 -36
- package/unittests/routing.-.ts +0 -56
- package/unittests/scopes.test.ts +0 -22
- package/unittests/special-tags.test.ts +0 -39
- package/unittests/styles.test.ts +0 -9
- package/unittests/styling/animations.test.ts +0 -14
- package/unittests/styling/filters.test.ts +0 -23
- package/unittests/styling/inline-styling.test.ts +0 -18
- package/unittests/styling/pseudo-selectors.test.ts +0 -33
- package/unittests/styling/transformations.test.ts +0 -234
- package/unittests/styling/value-interpretation.test.ts +0 -3
- package/unittests/testpage.ts +0 -5
- package/unittests/wait.test.ts +0 -31
- package/webpack.config.js +0 -28
package/src/dot.ts
DELETED
|
@@ -1,1147 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import eventBus from "./event-bus";
|
|
3
|
-
import {IDotCore, IDotGenericElement} from "./i-dot";
|
|
4
|
-
import dotcss, { _Builder } from "./styling/style-builder";
|
|
5
|
-
import ERR from "./err";
|
|
6
|
-
import { DotContent, IDotElementDocument, IDotDocument } from "./i-dot";
|
|
7
|
-
import { ClassPrefix, eachK, GlobalComponentStack, isF, sT, str } from "./dot-util";
|
|
8
|
-
import Component from "./component";
|
|
9
|
-
import { ArrayArgCallback, AttrArgCallback, ConditionalArgCallback, ContentArgCallback } from "./arg-callback-obj";
|
|
10
|
-
import ObservableArray from "./observable-array";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const dot: IDotCore = (function(targetSelector: string|Element|Node|NodeList|Array<Node|Element>)
|
|
17
|
-
{
|
|
18
|
-
//console.log(targetSelector);
|
|
19
|
-
var targets = targetSelector ? (
|
|
20
|
-
typeof targetSelector == "string" ? document.querySelectorAll(targetSelector)
|
|
21
|
-
: (targetSelector instanceof Element || targetSelector instanceof Node ? [targetSelector]
|
|
22
|
-
: ((targetSelector instanceof NodeList || (targetSelector instanceof Array) && targetSelector[0] && (targetSelector[0] instanceof Element || targetSelector[0] instanceof Node)) ? targetSelector
|
|
23
|
-
: []
|
|
24
|
-
)))
|
|
25
|
-
: [];
|
|
26
|
-
//console.log(targets);
|
|
27
|
-
var newDot = new DotDocument();
|
|
28
|
-
if(targets.length > 0){
|
|
29
|
-
newDot.__document = targets[0];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
dot["__selectionMode"] = SELECTOR_MODE;
|
|
33
|
-
|
|
34
|
-
return newDot;
|
|
35
|
-
}) as IDotCore;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const DOCEL = "DOTHTML-DOCUMENT";
|
|
42
|
-
const DEFEL = "DOTHTML-DEFER";
|
|
43
|
-
var _anonFuncCounter = 0;
|
|
44
|
-
|
|
45
|
-
function ext(name: string, method: Function){
|
|
46
|
-
_p[name] = dot[name] = method;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Deletes one element (and not its children).
|
|
50
|
-
// Used by _p.empty and _p.remove.
|
|
51
|
-
function deleteElement(element: Element){
|
|
52
|
-
var deleted = null;
|
|
53
|
-
var dc: Component = element["__dothtml_component"];
|
|
54
|
-
if(dc){
|
|
55
|
-
// var d = dc.deleting;
|
|
56
|
-
dc.deleting && dc.deleting();
|
|
57
|
-
dc["__$el"] = null;
|
|
58
|
-
deleted = dc.deleted;
|
|
59
|
-
}
|
|
60
|
-
if(element.parentNode) element.parentNode.removeChild(element);
|
|
61
|
-
deleted && deleted.apply(dc);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function _conditionalBlock(T, totalCondition, allConditions, contentCallback){
|
|
65
|
-
var startTextNode = document.createTextNode("");
|
|
66
|
-
var endTextNode = document.createTextNode("");
|
|
67
|
-
//var cb = {f:contentCallback,startNode:startTextNode, endNode:endTextNode,condition:totalCondition};
|
|
68
|
-
var cb = new ConditionalArgCallback(startTextNode, endTextNode, contentCallback, totalCondition);
|
|
69
|
-
dot["__currentArgCallback"].push(cb);
|
|
70
|
-
|
|
71
|
-
var renderContent = totalCondition();
|
|
72
|
-
|
|
73
|
-
T = T._appendOrCreateDocument(startTextNode);
|
|
74
|
-
|
|
75
|
-
for(var i = 0; i < allConditions.length; i++) allConditions[i]();
|
|
76
|
-
cb.lastValue = renderContent;
|
|
77
|
-
if(renderContent) T = T._appendOrCreateDocument(contentCallback);
|
|
78
|
-
|
|
79
|
-
T = T._appendOrCreateDocument(endTextNode);
|
|
80
|
-
dot["__currentArgCallback"].pop();
|
|
81
|
-
return T;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function attachEvent(el: Element, ev: string, val: Function, a3?: boolean){
|
|
85
|
-
if (el.addEventListener) el.addEventListener(ev, val as any, a3 || false);
|
|
86
|
-
else (el as any).attachEvent("on" + ev, val); //compatibility with old browsers.
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function createElement(tag){
|
|
90
|
-
ext(tag, function(c){return this.el(tag, c);});
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
function createAttribute(attribute: string, alias?: string){
|
|
94
|
-
_p[alias || attribute] = function(value){return this.attr(attribute, value);}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// Selection Mode enum.
|
|
98
|
-
export const SELECTOR_MODE = 1;
|
|
99
|
-
export const ATTRIBUTE_MODE = 2;
|
|
100
|
-
|
|
101
|
-
// TODO: this might need to go in just the right place.
|
|
102
|
-
// dotReady(dot, _p, _D);
|
|
103
|
-
// Dot document object.
|
|
104
|
-
// Formerly _D
|
|
105
|
-
var DotDocument: IDotDocument = (function(document?: Element, classPrefix?: number) {
|
|
106
|
-
// Private vars.
|
|
107
|
-
|
|
108
|
-
this.__document = document;
|
|
109
|
-
this.__lastNode = document ? document.lastChild : null;
|
|
110
|
-
this.__if = null;
|
|
111
|
-
this.__pendingCalls = []; //Allows you to set parent attributes from children.
|
|
112
|
-
this.__anonAttrFuncs = {}; //Only to be used by top-level dot object.
|
|
113
|
-
this.__classPrefix = classPrefix || 0;
|
|
114
|
-
this.__classedElements = [];
|
|
115
|
-
this.__selectionMode = SELECTOR_MODE;
|
|
116
|
-
|
|
117
|
-
}) as IDotDocument;
|
|
118
|
-
// Prototype for the dot document object.
|
|
119
|
-
|
|
120
|
-
var _p = (DotDocument as unknown as Function).prototype;
|
|
121
|
-
|
|
122
|
-
var allTags = [
|
|
123
|
-
"a",
|
|
124
|
-
"aside",
|
|
125
|
-
"abbr",
|
|
126
|
-
"address",
|
|
127
|
-
"area",
|
|
128
|
-
"article",
|
|
129
|
-
"audio",
|
|
130
|
-
"b",
|
|
131
|
-
"bdi",
|
|
132
|
-
"bdo",
|
|
133
|
-
"blockQuote",
|
|
134
|
-
"body",
|
|
135
|
-
"br",
|
|
136
|
-
"button",
|
|
137
|
-
"canvas",
|
|
138
|
-
"caption",
|
|
139
|
-
"cite", //*
|
|
140
|
-
"code",
|
|
141
|
-
"col",
|
|
142
|
-
"colGroup",
|
|
143
|
-
"content",
|
|
144
|
-
"data", //*
|
|
145
|
-
"dataList",
|
|
146
|
-
"dd",
|
|
147
|
-
"del",
|
|
148
|
-
"details",
|
|
149
|
-
"dfn",
|
|
150
|
-
"dialog",
|
|
151
|
-
"div",
|
|
152
|
-
"dl",
|
|
153
|
-
"dt",
|
|
154
|
-
"em",
|
|
155
|
-
"embed",
|
|
156
|
-
"fieldSet",
|
|
157
|
-
"figCaption",
|
|
158
|
-
"figure",
|
|
159
|
-
"footer",
|
|
160
|
-
"form", //*
|
|
161
|
-
"h1",
|
|
162
|
-
"h2",
|
|
163
|
-
"h3",
|
|
164
|
-
"h4",
|
|
165
|
-
"h5",
|
|
166
|
-
"h6",
|
|
167
|
-
"header",
|
|
168
|
-
"hr",
|
|
169
|
-
"i",
|
|
170
|
-
"iFrame",
|
|
171
|
-
"img",
|
|
172
|
-
"input",
|
|
173
|
-
"ins",
|
|
174
|
-
"kbd",
|
|
175
|
-
"keyGen",
|
|
176
|
-
"label", //*
|
|
177
|
-
"legend",
|
|
178
|
-
"li",
|
|
179
|
-
"main",
|
|
180
|
-
"map",
|
|
181
|
-
"mark",
|
|
182
|
-
"menu",
|
|
183
|
-
"menuItem",
|
|
184
|
-
"meter",
|
|
185
|
-
"nav",
|
|
186
|
-
"object",
|
|
187
|
-
"ol",
|
|
188
|
-
"optGroup",
|
|
189
|
-
"option",
|
|
190
|
-
"output",
|
|
191
|
-
"p",
|
|
192
|
-
"param",
|
|
193
|
-
"pre",
|
|
194
|
-
"progress",
|
|
195
|
-
"q",
|
|
196
|
-
"rp",
|
|
197
|
-
"rt",
|
|
198
|
-
"ruby",
|
|
199
|
-
"s",
|
|
200
|
-
"samp",
|
|
201
|
-
"section",
|
|
202
|
-
"select",
|
|
203
|
-
"small",
|
|
204
|
-
"source",
|
|
205
|
-
"span", //*
|
|
206
|
-
"strong",
|
|
207
|
-
"svg",
|
|
208
|
-
"sub",
|
|
209
|
-
"summary", //*
|
|
210
|
-
"sup",
|
|
211
|
-
"table",
|
|
212
|
-
"tBody",
|
|
213
|
-
"td",
|
|
214
|
-
"textArea",
|
|
215
|
-
"tFoot",
|
|
216
|
-
"th",
|
|
217
|
-
"tHead",
|
|
218
|
-
"time",
|
|
219
|
-
"tr",
|
|
220
|
-
"track",
|
|
221
|
-
"u",
|
|
222
|
-
"ul",
|
|
223
|
-
"var",
|
|
224
|
-
"video",
|
|
225
|
-
"wbr"
|
|
226
|
-
];
|
|
227
|
-
|
|
228
|
-
var allAttributes = [
|
|
229
|
-
"accept",
|
|
230
|
-
"accessKey",
|
|
231
|
-
"action",
|
|
232
|
-
"align",
|
|
233
|
-
"aLink",
|
|
234
|
-
"alt",
|
|
235
|
-
"archive",
|
|
236
|
-
"autoComplete",
|
|
237
|
-
"autoFocus",
|
|
238
|
-
"autoPlay",
|
|
239
|
-
"autoSave",
|
|
240
|
-
"axis",
|
|
241
|
-
"background",
|
|
242
|
-
"bgColor",
|
|
243
|
-
"border",
|
|
244
|
-
"buffered",
|
|
245
|
-
"cellPadding",
|
|
246
|
-
"cellSpacing",
|
|
247
|
-
"challenge",
|
|
248
|
-
"char",
|
|
249
|
-
"charOff",
|
|
250
|
-
"checked",
|
|
251
|
-
// "cite", //*
|
|
252
|
-
//"class",
|
|
253
|
-
"classId",
|
|
254
|
-
"clear",
|
|
255
|
-
"codeBase",
|
|
256
|
-
"codeType",
|
|
257
|
-
"color",
|
|
258
|
-
"cols",
|
|
259
|
-
"colSpan",
|
|
260
|
-
"compact",
|
|
261
|
-
"contentEditable",
|
|
262
|
-
"contextMenu",
|
|
263
|
-
"controls",
|
|
264
|
-
"coords",
|
|
265
|
-
"dateTime",
|
|
266
|
-
"declare",
|
|
267
|
-
"default",
|
|
268
|
-
//"data", //*
|
|
269
|
-
"dir",
|
|
270
|
-
"dirName",
|
|
271
|
-
"disabled",
|
|
272
|
-
"download",
|
|
273
|
-
"draggable",
|
|
274
|
-
"dropZone",
|
|
275
|
-
"encType",
|
|
276
|
-
"face",
|
|
277
|
-
"font",
|
|
278
|
-
"fontFace",
|
|
279
|
-
"fontFaceFormat",
|
|
280
|
-
"fontFaceName",
|
|
281
|
-
"fontFaceSrc",
|
|
282
|
-
"fontFaceUri",
|
|
283
|
-
"fontSpecification",
|
|
284
|
-
"for",
|
|
285
|
-
"foreignObject",
|
|
286
|
-
// "form", //*
|
|
287
|
-
"formAction",
|
|
288
|
-
"frame",
|
|
289
|
-
"frameBorder",
|
|
290
|
-
"headers",
|
|
291
|
-
"height",
|
|
292
|
-
"hidden",
|
|
293
|
-
"high",
|
|
294
|
-
"hRef",
|
|
295
|
-
"hRefLang",
|
|
296
|
-
"hSpace",
|
|
297
|
-
"icon",
|
|
298
|
-
"id",
|
|
299
|
-
"images",
|
|
300
|
-
"isMap",
|
|
301
|
-
"itemProp",
|
|
302
|
-
"keyType",
|
|
303
|
-
"kind",
|
|
304
|
-
// "label", //*
|
|
305
|
-
"lang",
|
|
306
|
-
"list",
|
|
307
|
-
"longDesc",
|
|
308
|
-
"loop",
|
|
309
|
-
"low",
|
|
310
|
-
"manifest",
|
|
311
|
-
"marginHeight",
|
|
312
|
-
"marginWidth",
|
|
313
|
-
"max",
|
|
314
|
-
"maxLength",
|
|
315
|
-
"media",
|
|
316
|
-
"metadata",
|
|
317
|
-
"method",
|
|
318
|
-
"min",
|
|
319
|
-
"missingGlyph",
|
|
320
|
-
"multiple",
|
|
321
|
-
"muted",
|
|
322
|
-
"name",
|
|
323
|
-
"noHRef",
|
|
324
|
-
"noResize",
|
|
325
|
-
"noShade",
|
|
326
|
-
"noValidate",
|
|
327
|
-
"nowrap",
|
|
328
|
-
"open",
|
|
329
|
-
"optimum",
|
|
330
|
-
"pattern",
|
|
331
|
-
"ping",
|
|
332
|
-
"placeholder",
|
|
333
|
-
"poster",
|
|
334
|
-
"preload",
|
|
335
|
-
"prompt",
|
|
336
|
-
"radioGroup",
|
|
337
|
-
"readOnly",
|
|
338
|
-
"rel",
|
|
339
|
-
"required",
|
|
340
|
-
"rev",
|
|
341
|
-
"reversed",
|
|
342
|
-
"rows",
|
|
343
|
-
"rowSpan",
|
|
344
|
-
"rules",
|
|
345
|
-
"sandbox",
|
|
346
|
-
"scope",
|
|
347
|
-
"scrolling",
|
|
348
|
-
"seamless",
|
|
349
|
-
"selected",
|
|
350
|
-
"shape",
|
|
351
|
-
"size",
|
|
352
|
-
"sizes",
|
|
353
|
-
// "span", //*
|
|
354
|
-
"spellCheck",
|
|
355
|
-
"src",
|
|
356
|
-
"srcDoc",
|
|
357
|
-
"srcLang",
|
|
358
|
-
"srcSet",
|
|
359
|
-
"standby",
|
|
360
|
-
"start",
|
|
361
|
-
"step",
|
|
362
|
-
// "summary", //*
|
|
363
|
-
"style",
|
|
364
|
-
"tabIndex",
|
|
365
|
-
"target",
|
|
366
|
-
"title",
|
|
367
|
-
"type",
|
|
368
|
-
"useMap",
|
|
369
|
-
"vAlign",
|
|
370
|
-
"value",
|
|
371
|
-
"valueType",
|
|
372
|
-
"width",
|
|
373
|
-
"wrap"
|
|
374
|
-
//"dataA", //Special explicit
|
|
375
|
-
//"citeA",
|
|
376
|
-
//"formA",
|
|
377
|
-
//"labelA",
|
|
378
|
-
//"spanA",
|
|
379
|
-
//"summaryA"
|
|
380
|
-
];
|
|
381
|
-
|
|
382
|
-
var specialAttributes = [
|
|
383
|
-
["quoteCite","cite"],
|
|
384
|
-
["objectData","data"],
|
|
385
|
-
["whichForm","form"],
|
|
386
|
-
["trackLabel","label"],
|
|
387
|
-
["colSpan","span"],
|
|
388
|
-
["tableSummary","summary"],
|
|
389
|
-
["optionLabel","label"],
|
|
390
|
-
["acceptCharset","accept-charset"],
|
|
391
|
-
]
|
|
392
|
-
|
|
393
|
-
var allEventAttr = [
|
|
394
|
-
"onAbort",
|
|
395
|
-
"onBlur",
|
|
396
|
-
"onChange",
|
|
397
|
-
"onInput",
|
|
398
|
-
"onCanPlay",
|
|
399
|
-
"onCantPlayThrough",
|
|
400
|
-
"onClick",
|
|
401
|
-
"onCopy",
|
|
402
|
-
"onContextMenu",
|
|
403
|
-
"onCueChange",
|
|
404
|
-
"onCut",
|
|
405
|
-
"onDblClick",
|
|
406
|
-
"onDrag",
|
|
407
|
-
"onDragEnd",
|
|
408
|
-
"onDragEnter",
|
|
409
|
-
"onDragLeave",
|
|
410
|
-
"onDragOver",
|
|
411
|
-
"onDragStart",
|
|
412
|
-
"onDrop",
|
|
413
|
-
"onDurationChange",
|
|
414
|
-
"onEmptied",
|
|
415
|
-
"onEnded",
|
|
416
|
-
"onError",
|
|
417
|
-
"onFocus",
|
|
418
|
-
"onHashChange",
|
|
419
|
-
"onInvalid",
|
|
420
|
-
"onKeyDown",
|
|
421
|
-
"onKeyPress",
|
|
422
|
-
"onKeyUp",
|
|
423
|
-
"onLoad",
|
|
424
|
-
"onLoadedData",
|
|
425
|
-
"onLoadedMetadata",
|
|
426
|
-
"onLoadStart",
|
|
427
|
-
"onMouseDown",
|
|
428
|
-
"onMouseEnter",
|
|
429
|
-
"onMouseMove",
|
|
430
|
-
"onMouseOut",
|
|
431
|
-
"onMouseOver",
|
|
432
|
-
"onMouseUp",
|
|
433
|
-
"onMouseWheel",
|
|
434
|
-
"onOffline",
|
|
435
|
-
"onOnline",
|
|
436
|
-
"onPageHide",
|
|
437
|
-
"onPagePaste",
|
|
438
|
-
"onPageShow",
|
|
439
|
-
"onPause",
|
|
440
|
-
"onPlay",
|
|
441
|
-
"onPlaying",
|
|
442
|
-
"onPopState",
|
|
443
|
-
"onProgress",
|
|
444
|
-
"onRateChange",
|
|
445
|
-
"onReset",
|
|
446
|
-
"onResize",
|
|
447
|
-
"onScroll",
|
|
448
|
-
"onSearch",
|
|
449
|
-
"onSeeked",
|
|
450
|
-
"onSeeking",
|
|
451
|
-
"onSelect",
|
|
452
|
-
"onStalled",
|
|
453
|
-
"onStorage",
|
|
454
|
-
"onSubmit",
|
|
455
|
-
"onSuspend",
|
|
456
|
-
"onTimeUpdate",
|
|
457
|
-
"onToggle",
|
|
458
|
-
"onUnload",
|
|
459
|
-
"onVolumeChange",
|
|
460
|
-
"onWaiting",
|
|
461
|
-
"onWheel",
|
|
462
|
-
]
|
|
463
|
-
|
|
464
|
-
var i;
|
|
465
|
-
for(i in allTags) createElement(allTags[i]);
|
|
466
|
-
for(i in allAttributes) createAttribute(allAttributes[i]);
|
|
467
|
-
for(i in specialAttributes) {
|
|
468
|
-
createAttribute(specialAttributes[i][1],specialAttributes[i][0]);
|
|
469
|
-
}
|
|
470
|
-
for(i in allEventAttr) createAttribute(allEventAttr[i]);
|
|
471
|
-
|
|
472
|
-
ext("as", function<T extends IDotDocument>(dotElement: (...props: any[])=>T): T{
|
|
473
|
-
return this;
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
ext("_getNewDocument", function(){
|
|
477
|
-
return document.createElement(DOCEL);
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
ext("_getAnInstance", function(): IDotDocument{
|
|
481
|
-
if(this.__document || this.__pendingCalls.length > 0) return this;
|
|
482
|
-
else {
|
|
483
|
-
var d = new DotDocument(null, this.__classPrefix);
|
|
484
|
-
d.__if = this.__if;
|
|
485
|
-
return d;
|
|
486
|
-
};
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
ext("_getLastChildOrNull", function(): ChildNode{
|
|
490
|
-
if(this.__document && this.__document.lastChild) return this.__document.lastChild;
|
|
491
|
-
return null;
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
//I'm not sure if this is supported anymore.
|
|
495
|
-
ext("getLast", function(): Node{
|
|
496
|
-
return this._getLastChildOrNull();
|
|
497
|
-
});
|
|
498
|
-
ext("getCurrent", function(): Node{
|
|
499
|
-
let last;
|
|
500
|
-
switch(dot["__selectionMode"]){
|
|
501
|
-
case SELECTOR_MODE:{
|
|
502
|
-
last = this.__document;
|
|
503
|
-
break;
|
|
504
|
-
}
|
|
505
|
-
case ATTRIBUTE_MODE:{
|
|
506
|
-
last = this.getLast() || this.__document;
|
|
507
|
-
break;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
return last;
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
_p.toString = function(){
|
|
514
|
-
if(this.__document) return this.__document.innerHTML;
|
|
515
|
-
else return "";
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
_p.ref = function(name){
|
|
519
|
-
let l = this.getLast();
|
|
520
|
-
let gl = GlobalComponentStack.length;
|
|
521
|
-
if(l && gl > 0){
|
|
522
|
-
let c = GlobalComponentStack[gl - 1];
|
|
523
|
-
c.$refs[name] = l;
|
|
524
|
-
}
|
|
525
|
-
return this;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
//before is passed in so that attributes can be associated with before's sibling, instead of inheritingParent, the default.
|
|
529
|
-
ext("_evalContent", function(content: DotContent, pendingCalls?: Array<unknown>){
|
|
530
|
-
if(content == null || content == undefined) return null;
|
|
531
|
-
if(typeof content === "string" || typeof content === "number" || typeof content === "boolean") { //Raw data
|
|
532
|
-
let nDot = new DotDocument(this._getNewDocument(), this.__classPrefix);
|
|
533
|
-
nDot.__document.innerHTML = content;
|
|
534
|
-
return nDot.__document.childNodes;
|
|
535
|
-
}
|
|
536
|
-
else if(content instanceof Node) return content;
|
|
537
|
-
else if(Object.prototype.toString.call( content ) === '[object Array]') { //Array
|
|
538
|
-
let nDot = new DotDocument(this._getNewDocument(), this.__classPrefix);
|
|
539
|
-
for(let i = 0; i < (content as Array<unknown>).length; i++){
|
|
540
|
-
nDot._appendOrCreateDocument((content as DotContent)[i]);
|
|
541
|
-
}
|
|
542
|
-
if(nDot.__document) return nDot.__document.childNodes;
|
|
543
|
-
}
|
|
544
|
-
else if(isF(content)) //Function to evaluate
|
|
545
|
-
{
|
|
546
|
-
return this._evalContent((content as (()=>DotContent))(), pendingCalls);
|
|
547
|
-
}
|
|
548
|
-
else if(content instanceof Component){
|
|
549
|
-
return this._evalContent(Component.build(content));
|
|
550
|
-
}
|
|
551
|
-
else if(content instanceof DotDocument) { //DOT
|
|
552
|
-
for(let i = 0; i < content["__pendingCalls"].length; i++){
|
|
553
|
-
pendingCalls.push(content["__pendingCalls"][i]);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
let cp = this.__classPrefix;
|
|
557
|
-
for(let i in content["__classedElements"]){
|
|
558
|
-
let el = content["__classedElements"][i];
|
|
559
|
-
if(!cp){
|
|
560
|
-
this["__classedElements"].push(el);
|
|
561
|
-
}
|
|
562
|
-
else{
|
|
563
|
-
el.className = "dot-" + str(cp,16) + "-" + el.className;
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
if(content["__document"]) return content["__document"].childNodes; //Return all the nodes in here.
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
return null;
|
|
570
|
-
});
|
|
571
|
-
|
|
572
|
-
ext("_appendOrCreateDocument", function(content: DotContent, parentEl?: Element, beforeNode?: Node|number){
|
|
573
|
-
var T = this;
|
|
574
|
-
// Validation
|
|
575
|
-
;;; if(parentEl && beforeNode && isNaN(beforeNode as any) && (beforeNode as Node).parentNode != parentEl) throw "beforeNode is not in parentEl.";
|
|
576
|
-
|
|
577
|
-
// Find the parent, or create one.
|
|
578
|
-
//Note: the stuff with setting parentEl to beforeNode's parent is due to a very strange bug where this.__document gets set to some phantom document when the wait function is used inside a div like so: DOT.div(DOT.wait(100, "hello!")); Try it. )
|
|
579
|
-
parentEl = parentEl || (beforeNode && isNaN(beforeNode as any) ? (beforeNode as Node).parentNode : null) || T.__document || T._getNewDocument();
|
|
580
|
-
|
|
581
|
-
if(!isNaN(beforeNode as any)){
|
|
582
|
-
beforeNode = parentEl.childNodes[beforeNode as number];
|
|
583
|
-
//;;; if(!beforeNode) throw "beforeNode not found."; // TODO: reenable this and investigate why it breaks.
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
// nd is a dot wrapper for parentEl (allows us to do dot ops on it).
|
|
587
|
-
var nd = T.__document === parentEl ? T : new DotDocument(parentEl, T.__classPrefix);
|
|
588
|
-
nd.__if = T.__if;
|
|
589
|
-
var pendingCalls = []; //This will populate with pending calls.
|
|
590
|
-
|
|
591
|
-
// Evaluate the content. This does not add it to the DOM pet.
|
|
592
|
-
var eContent;
|
|
593
|
-
var cf = isF(content);
|
|
594
|
-
// If it's a function, we need to consider
|
|
595
|
-
//if(cf) dot.__currentArgCallback.push({f:content,e:parentEl})
|
|
596
|
-
if(cf) dot["__currentArgCallback"].push(new ContentArgCallback(parentEl, content as ()=>string));
|
|
597
|
-
try{
|
|
598
|
-
eContent = nd._evalContent(content, /*parentEl, beforeNode,*/ pendingCalls);
|
|
599
|
-
}
|
|
600
|
-
finally{
|
|
601
|
-
if(cf) dot["__currentArgCallback"].pop();
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
// Pending calls are calls included in the dot element which didn't get consumed and must be propagated up.
|
|
606
|
-
// This usually includes attributes and waits.
|
|
607
|
-
for(var i = 0; i < pendingCalls.length; i++){
|
|
608
|
-
var call = pendingCalls[i];
|
|
609
|
-
//Three possibilities.
|
|
610
|
-
//1. Use the pending call against the last sibling element, if one exists.
|
|
611
|
-
//2. Otherwise, use it on the current parent, if it's ready.
|
|
612
|
-
//3. Otherwise, save it as a pending call right here. // Don't think this ever happens.
|
|
613
|
-
var pendingCallTarget = (beforeNode ? ((beforeNode as Node).previousSibling || parentEl /*Since lastChild will be a timeout*/) : null /*1*/) || parentEl.lastChild /*2*/ || parentEl;
|
|
614
|
-
if(pendingCallTarget && (pendingCallTarget as Element).tagName != "DOCUMENT"){
|
|
615
|
-
if (call.type == "attr") {
|
|
616
|
-
if (!isF(call.params[0])) {
|
|
617
|
-
(pendingCallTarget as Element).setAttribute(call.name, call.params[0]);
|
|
618
|
-
}
|
|
619
|
-
else {
|
|
620
|
-
// TODO: how do we know it's a valid event?
|
|
621
|
-
let newName:string = call.name;
|
|
622
|
-
attachEvent((pendingCallTarget as Element), newName, call.params[0], call.arg3);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
else if(call.type == "wait"){
|
|
626
|
-
call.callback();
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
else{
|
|
630
|
-
nd.__pendingCalls.push(call); /*3*/
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
// Append content to the current document.
|
|
635
|
-
if(eContent !== null && eContent !== undefined){
|
|
636
|
-
if( eContent instanceof NodeList ) {
|
|
637
|
-
//for(var i = 0; i < eContent.length; i++){
|
|
638
|
-
while(eContent.length > 0){
|
|
639
|
-
if(beforeNode) parentEl.insertBefore(eContent[0], beforeNode as Node);
|
|
640
|
-
else parentEl.appendChild(eContent[0]);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
else{
|
|
644
|
-
if(beforeNode) parentEl.insertBefore(eContent, beforeNode as Node);
|
|
645
|
-
else parentEl.appendChild(eContent);
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
return nd;
|
|
650
|
-
//return this;
|
|
651
|
-
});
|
|
652
|
-
|
|
653
|
-
ext("el", function(tag: string, content?: DotContent): IDotElementDocument<IDotGenericElement>{
|
|
654
|
-
var T = this;
|
|
655
|
-
var ne = document.createElement(tag);
|
|
656
|
-
var nDoc = T.__document || T._getNewDocument();
|
|
657
|
-
nDoc.appendChild(ne);
|
|
658
|
-
if(content) T._appendOrCreateDocument(content, ne);
|
|
659
|
-
var ret = T.__document === nDoc ? T : new DotDocument(nDoc, T.__classPrefix);
|
|
660
|
-
if(content && content instanceof DotDocument) for(var i in content["__classedElements"]) ret.__classedElements.push(content["__classedElements"][i]);
|
|
661
|
-
|
|
662
|
-
dot["__selectionMode"] = ATTRIBUTE_MODE;
|
|
663
|
-
|
|
664
|
-
return ret;
|
|
665
|
-
});
|
|
666
|
-
|
|
667
|
-
ext("h", function(content): IDotDocument{
|
|
668
|
-
var T = this;
|
|
669
|
-
var hDoc = T._getNewDocument();
|
|
670
|
-
var hDot = new DotDocument(hDoc, T.__classPrefix);
|
|
671
|
-
//if(typeof content === "string" || typeof content === "number" || typeof content === "boolean") hDoc.innerHTML = content; //Raw data
|
|
672
|
-
hDot._appendOrCreateDocument(content)
|
|
673
|
-
|
|
674
|
-
var nDoc = T.__document || T._getNewDocument();
|
|
675
|
-
while(hDoc.childNodes.length > 0){
|
|
676
|
-
nDoc.appendChild(hDoc.childNodes[0]);
|
|
677
|
-
}
|
|
678
|
-
return T.__document === nDoc ? T : new DotDocument(nDoc, T.__classPrefix);
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
ext("t", function(content): IDotDocument{
|
|
682
|
-
var textNode = document.createTextNode(content);
|
|
683
|
-
var nDoc = this.__document || this._getNewDocument();
|
|
684
|
-
nDoc.appendChild(textNode);
|
|
685
|
-
return new DotDocument(nDoc, this.__classPrefix);
|
|
686
|
-
});
|
|
687
|
-
|
|
688
|
-
ext("attr", function(attr, value, arg3?){
|
|
689
|
-
var T = this;
|
|
690
|
-
if (isF(value)) { // events.
|
|
691
|
-
if (attr.indexOf("on") == 0 && allEventAttr.indexOf(attr) != -1) {
|
|
692
|
-
attr = attr.substring(2).toLowerCase();
|
|
693
|
-
}
|
|
694
|
-
else {
|
|
695
|
-
// Unrecognized event.
|
|
696
|
-
dot["__anonAttrFuncs"][_anonFuncCounter] = (value);
|
|
697
|
-
value = "dot.__anonAttrFuncs[" + (_anonFuncCounter++) + "](arguments[0]);"
|
|
698
|
-
// attr = attr.substring(2);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
if(T.__document) {
|
|
703
|
-
var cn = T.__document.childNodes;
|
|
704
|
-
var last = cn[cn.length - 1];
|
|
705
|
-
if(last && last.setAttribute){
|
|
706
|
-
if (!isF(value)) {
|
|
707
|
-
|
|
708
|
-
// Objects (except for the css builder :/)
|
|
709
|
-
if(typeof value == "object" && !(value instanceof _Builder)){
|
|
710
|
-
var originalValue = value;
|
|
711
|
-
var valueSetter = function(){
|
|
712
|
-
var str = "";
|
|
713
|
-
eachK(originalValue, function(k,v){
|
|
714
|
-
v = isF(v) ? v() : v;
|
|
715
|
-
if(!v) return;
|
|
716
|
-
str += " " + k
|
|
717
|
-
});
|
|
718
|
-
return str.substring(1);
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
//dot.__currentArgCallback.push({f:valueSetter,e:parentEl,a:attr})
|
|
722
|
-
dot["__currentArgCallback"].push(new AttrArgCallback(last, attr, valueSetter));
|
|
723
|
-
value = valueSetter();
|
|
724
|
-
dot["__currentArgCallback"].pop();
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
var eValue = last.getAttribute(attr); //Appends the new value to any existing value.
|
|
728
|
-
if (!eValue) eValue = ""; else eValue += " ";
|
|
729
|
-
last.setAttribute(attr, eValue + (value === undefined ? attr : value)); //||attr is for self-explaining attributes
|
|
730
|
-
}
|
|
731
|
-
else {
|
|
732
|
-
attachEvent(last, attr, value, arg3);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
else{
|
|
737
|
-
// TODO: should probably remove pending calls. This has turned out to be an anti-pattern.
|
|
738
|
-
var pD = T._getAnInstance();
|
|
739
|
-
//if(!pD.__pendingCalls.length > 0) pD.__pendingCalls = [];
|
|
740
|
-
pD.__pendingCalls.push({ type: "attr", name: attr, params: [value], arg3: arg3 });
|
|
741
|
-
return pD;
|
|
742
|
-
}
|
|
743
|
-
return T;
|
|
744
|
-
});
|
|
745
|
-
|
|
746
|
-
ext("_appendSetElement", function(targetId: string, appendMode){
|
|
747
|
-
var T = this;
|
|
748
|
-
if(!targetId) {ERR("A", targetId); return T;}
|
|
749
|
-
var destination = document.getElementById(targetId);
|
|
750
|
-
if(!destination) {ERR("F", targetId); return T;}
|
|
751
|
-
if(T.__document) {
|
|
752
|
-
if(!appendMode) destination.innerHTML = "";
|
|
753
|
-
while(T.__document.childNodes.length > 0) destination.appendChild(T.__document.childNodes[0]);
|
|
754
|
-
}
|
|
755
|
-
return T;
|
|
756
|
-
});
|
|
757
|
-
|
|
758
|
-
ext("iterate", function(iterations: number, callback: (i: number)=>DotContent){
|
|
759
|
-
var target = this;
|
|
760
|
-
// var copycontent = null;
|
|
761
|
-
|
|
762
|
-
// Not sure what this was used for before the TS port.
|
|
763
|
-
// var content = callback;
|
|
764
|
-
// if(content instanceof DotDocument) {
|
|
765
|
-
// copycontent = content.__document.cloneNode(true);
|
|
766
|
-
// }
|
|
767
|
-
|
|
768
|
-
for(var i = 0; i < iterations; i++){
|
|
769
|
-
let content: DotContent = null;
|
|
770
|
-
if(isF(callback)) content = callback(i);
|
|
771
|
-
// if(copycontent) content.__document = copycontent.cloneNode(true);
|
|
772
|
-
target = target._appendOrCreateDocument(content);
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
return target;
|
|
776
|
-
});
|
|
777
|
-
|
|
778
|
-
ext("each", function(array, callback, forceNoDeferred){
|
|
779
|
-
var target = this;
|
|
780
|
-
|
|
781
|
-
if(isF(array)){
|
|
782
|
-
if(!forceNoDeferred){
|
|
783
|
-
return target.defer(function(v){
|
|
784
|
-
v.each(array, callback, true);
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
// console.log(this.__document);
|
|
788
|
-
var func = array;
|
|
789
|
-
//target = target._appendOrCreateDocument();
|
|
790
|
-
// dot.__currentArgCallback.push({f:callback,d:target});
|
|
791
|
-
dot["__currentArgCallback"].push(new ArrayArgCallback(target, callback));
|
|
792
|
-
try{
|
|
793
|
-
array = func();
|
|
794
|
-
}
|
|
795
|
-
finally{
|
|
796
|
-
dot["__currentArgCallback"].pop();
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
if(array instanceof Array || array instanceof ObservableArray){
|
|
801
|
-
for(var i = 0; i < (array as Array<any>).length; i++){
|
|
802
|
-
target = target._appendOrCreateDocument(callback(array[i], i));
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
else{
|
|
806
|
-
var keys = Object.keys(array);
|
|
807
|
-
for(var i = 0; i < keys.length; i++){
|
|
808
|
-
var k = keys[i];
|
|
809
|
-
target = target._appendOrCreateDocument(callback(array[k], k));
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
return target;
|
|
813
|
-
});
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
//SVG
|
|
817
|
-
//_p.svg = function(){ERR("S")};
|
|
818
|
-
|
|
819
|
-
//Data is a special attribute.
|
|
820
|
-
_p.customData = function(suffix, value){
|
|
821
|
-
return this.attr("data-" + suffix, value);
|
|
822
|
-
};
|
|
823
|
-
|
|
824
|
-
_p.class = function(value){
|
|
825
|
-
var cp = this.__classPrefix;
|
|
826
|
-
// This handles legitimate class prefixes. If we are dealing with a compted class list, each class list name is prefixed.
|
|
827
|
-
if(cp){
|
|
828
|
-
var prefix = "dot-" + str(cp, 16) + "-";
|
|
829
|
-
if(typeof value == "string") value = prefix + value;
|
|
830
|
-
else if(typeof value == "object"){
|
|
831
|
-
var v2 = {};
|
|
832
|
-
eachK(value, function(k,v){
|
|
833
|
-
v2[prefix + k] = v;
|
|
834
|
-
});
|
|
835
|
-
value = v2;
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
else
|
|
839
|
-
{
|
|
840
|
-
var el = this.getLast();
|
|
841
|
-
el && this.__classedElements.push(el);
|
|
842
|
-
}
|
|
843
|
-
return this.attr("class", value);
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
_p.play = function(){
|
|
847
|
-
let last: HTMLVideoElement|HTMLAudioElement = this.getCurrent();
|
|
848
|
-
last.play && last.play();
|
|
849
|
-
return this;
|
|
850
|
-
}
|
|
851
|
-
_p.pause = function(resetTime){
|
|
852
|
-
let last: HTMLVideoElement|HTMLAudioElement = this.getCurrent();
|
|
853
|
-
last.pause && last.pause();
|
|
854
|
-
if(resetTime) last.currentTime = 0;
|
|
855
|
-
return this;
|
|
856
|
-
}
|
|
857
|
-
_p.stop = function(){
|
|
858
|
-
return this.pause(true);
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
/**
|
|
862
|
-
* Sets the value of an input or texterea.
|
|
863
|
-
* @param {string} value - The value to be set.
|
|
864
|
-
*/
|
|
865
|
-
_p.setVal = function(value): IDotElementDocument<IDotGenericElement>{
|
|
866
|
-
let last = this.getCurrent();
|
|
867
|
-
|
|
868
|
-
if(!last) return this;
|
|
869
|
-
|
|
870
|
-
// console.log("CHECKVALUE", value);
|
|
871
|
-
//if ( typeof value === "number" ) val += "";
|
|
872
|
-
if ( Array.isArray && Array.isArray( value ) || !Array.isArray && value.join ) {
|
|
873
|
-
value = value.join("");
|
|
874
|
-
}
|
|
875
|
-
else if(value == null){
|
|
876
|
-
value = "";
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
if ( last.type == "checkbox" ) {
|
|
880
|
-
last.checked = value ? true : false;
|
|
881
|
-
}
|
|
882
|
-
else if ( last.type == "radio" ) {
|
|
883
|
-
last.checked = value ? true : false;
|
|
884
|
-
}
|
|
885
|
-
else if ( last.tagName == "OPTION" ) {
|
|
886
|
-
last.selected = value ? true : false;
|
|
887
|
-
}
|
|
888
|
-
else {
|
|
889
|
-
// console.log("UPDATING VALUE!!", value, last, last.value);
|
|
890
|
-
last.value = value;
|
|
891
|
-
// console.log("UPDATED!!", value, last, last.value);
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
return this;
|
|
895
|
-
};
|
|
896
|
-
|
|
897
|
-
_p.getVal = function(){
|
|
898
|
-
var element: Element = this.__lastNode || this.__document;
|
|
899
|
-
if(!element || element.nodeType !== 1) return undefined;
|
|
900
|
-
|
|
901
|
-
if ( element["type"] == "checkbox" ) {
|
|
902
|
-
return element["checked"] ? true : false;
|
|
903
|
-
}
|
|
904
|
-
else if ( element["type"] == "radio" ) {
|
|
905
|
-
return element["checked"] ? true : false;
|
|
906
|
-
}
|
|
907
|
-
else if ( element.tagName == "OPTION" ) {
|
|
908
|
-
return element["selected"] ? true : false;
|
|
909
|
-
}
|
|
910
|
-
else {
|
|
911
|
-
return element["value"];
|
|
912
|
-
}
|
|
913
|
-
};
|
|
914
|
-
|
|
915
|
-
ext("when", function(condition, contentCallback, ar){
|
|
916
|
-
var T = this._getAnInstance();
|
|
917
|
-
if(isF(condition)){
|
|
918
|
-
if(!ar) ar = T.__conditionalArray = [condition];
|
|
919
|
-
var l = ar.length - 1;
|
|
920
|
-
var totalCondition = function(){
|
|
921
|
-
for(var i = 0; i < l; i++){
|
|
922
|
-
if(!!ar[i]()) {
|
|
923
|
-
return false;
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
return !!condition();
|
|
927
|
-
}
|
|
928
|
-
T = _conditionalBlock(T, totalCondition, ar, contentCallback);
|
|
929
|
-
// ar.push(condition);
|
|
930
|
-
}
|
|
931
|
-
else{
|
|
932
|
-
// Old:
|
|
933
|
-
if(!!condition) {
|
|
934
|
-
T = T._appendOrCreateDocument(isF(contentCallback) ? contentCallback() : contentCallback);
|
|
935
|
-
T.__if = true;
|
|
936
|
-
}
|
|
937
|
-
else{
|
|
938
|
-
T.__if = false;
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
return T;
|
|
942
|
-
});
|
|
943
|
-
|
|
944
|
-
ext("otherwiseWhen", function(condition, callback): IDotDocument{
|
|
945
|
-
if(isF(condition)){
|
|
946
|
-
var ar = this.__conditionalArray;
|
|
947
|
-
if(!ar) ERR("MC");
|
|
948
|
-
//var l = ar.length - 1;
|
|
949
|
-
// var newCondition = function(){
|
|
950
|
-
// for(var i = 0; i <= l; i++){
|
|
951
|
-
// if(ar[i]()) return false;
|
|
952
|
-
// }
|
|
953
|
-
// return !!condition();
|
|
954
|
-
// }
|
|
955
|
-
ar.push(condition);
|
|
956
|
-
return this.when(condition, callback, ar);
|
|
957
|
-
}
|
|
958
|
-
else{
|
|
959
|
-
if(!this.__if){
|
|
960
|
-
return this.when(condition, callback);
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
return this;
|
|
964
|
-
});
|
|
965
|
-
|
|
966
|
-
ext("otherwise", function(callback): IDotDocument{
|
|
967
|
-
var ar = this.__conditionalArray;
|
|
968
|
-
if(ar){
|
|
969
|
-
//var l = ar.length - 1;
|
|
970
|
-
var newCondition = function(){
|
|
971
|
-
return true;
|
|
972
|
-
}
|
|
973
|
-
ar.push(newCondition);
|
|
974
|
-
return this.when(newCondition, callback, ar);
|
|
975
|
-
}
|
|
976
|
-
else if(!this.__if){
|
|
977
|
-
this.__if = null;
|
|
978
|
-
return this._getAnInstance()._appendOrCreateDocument(callback);
|
|
979
|
-
}
|
|
980
|
-
return this;
|
|
981
|
-
});
|
|
982
|
-
|
|
983
|
-
ext("script", function(callback): IDotDocument{
|
|
984
|
-
var last = this.getLast();
|
|
985
|
-
sT(function(){callback(last);}, 0);
|
|
986
|
-
return this;
|
|
987
|
-
});
|
|
988
|
-
|
|
989
|
-
ext("wait", function(timeout, callback): IDotDocument{
|
|
990
|
-
var timeoutDot = this.el(DEFEL);
|
|
991
|
-
var timeoutNode = timeoutDot.__document.lastChild;
|
|
992
|
-
|
|
993
|
-
sT(()=>{
|
|
994
|
-
timeoutDot._appendOrCreateDocument(callback, null, timeoutNode);
|
|
995
|
-
timeoutNode.parentElement.removeChild(timeoutNode);
|
|
996
|
-
}, timeout);
|
|
997
|
-
|
|
998
|
-
return timeoutDot;
|
|
999
|
-
// Ideally something like this:
|
|
1000
|
-
//return this.defer(function(d){d.h(callback)}, timeout);
|
|
1001
|
-
});
|
|
1002
|
-
|
|
1003
|
-
ext("defer", function(callback){
|
|
1004
|
-
if(!isF(callback)) ERR("XF", "defer");
|
|
1005
|
-
var deferDot = this.el(DEFEL);
|
|
1006
|
-
var deferNode = deferDot.__document.lastChild;
|
|
1007
|
-
|
|
1008
|
-
sT(()=>{
|
|
1009
|
-
callback(dot(deferNode.parentElement));
|
|
1010
|
-
deferNode.parentElement.removeChild(deferNode);
|
|
1011
|
-
}, 0);
|
|
1012
|
-
|
|
1013
|
-
return deferDot;
|
|
1014
|
-
});
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
ext("empty", function(){
|
|
1018
|
-
if(this.__document){
|
|
1019
|
-
// Build a queue of items to remove.
|
|
1020
|
-
var queue = [this.__document];
|
|
1021
|
-
var firstQ = true;
|
|
1022
|
-
var stack = [];
|
|
1023
|
-
while(queue.length > 0)
|
|
1024
|
-
{
|
|
1025
|
-
var current = queue.shift();
|
|
1026
|
-
if(current.childNodes.length > 0){
|
|
1027
|
-
for(var i = 0; i < current.childNodes.length; i++){
|
|
1028
|
-
queue.push(current.childNodes[i]);
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
!firstQ && stack.push(current);
|
|
1032
|
-
firstQ = false;
|
|
1033
|
-
|
|
1034
|
-
}
|
|
1035
|
-
while(stack.length > 0){
|
|
1036
|
-
deleteElement(stack.pop());
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
// Drop all the other nodes (like text)
|
|
1040
|
-
// Text seems to get deleted even without this code :).
|
|
1041
|
-
//while (this.__document.firstChild) {
|
|
1042
|
-
// this.__document.removeChild(this.__document.firstChild);
|
|
1043
|
-
//}
|
|
1044
|
-
|
|
1045
|
-
return this;
|
|
1046
|
-
});
|
|
1047
|
-
|
|
1048
|
-
ext("remove", function(){
|
|
1049
|
-
this.empty();
|
|
1050
|
-
deleteElement(this.__document);
|
|
1051
|
-
});
|
|
1052
|
-
|
|
1053
|
-
ext("scopeClass", function(prefix: number|string|null, content: DotContent){
|
|
1054
|
-
if(prefix == null){
|
|
1055
|
-
prefix = ClassPrefix.next;
|
|
1056
|
-
}
|
|
1057
|
-
var T = this;
|
|
1058
|
-
|
|
1059
|
-
//T.__classPrefix = prefix || classPrefix.next;
|
|
1060
|
-
//doc.__oldClassPrefix.push(prefix);
|
|
1061
|
-
T.__classPrefix = prefix;
|
|
1062
|
-
var ret = T.h(content);
|
|
1063
|
-
T.__classPrefix = 0;
|
|
1064
|
-
//doc.__oldClassPrefix.pop();
|
|
1065
|
-
//T.__classPrefix = oldCp;
|
|
1066
|
-
return ret;
|
|
1067
|
-
});
|
|
1068
|
-
|
|
1069
|
-
_p.bindTo = function(prop: any){
|
|
1070
|
-
let lastProp: string = dot["__lastProp"];
|
|
1071
|
-
let lastIndex: number = dot["__lastIndex"];
|
|
1072
|
-
let lastComponent: Component = dot["__lastComponent"];
|
|
1073
|
-
|
|
1074
|
-
let last = this.getLast();
|
|
1075
|
-
//var noListener = true;
|
|
1076
|
-
let _value = lastComponent.props[lastProp];
|
|
1077
|
-
if(lastIndex != null && lastIndex != undefined) _value = _value[lastIndex];
|
|
1078
|
-
|
|
1079
|
-
let ret = this.setVal(_value);
|
|
1080
|
-
|
|
1081
|
-
// Binding from the input to the prop.
|
|
1082
|
-
attachEvent(last, "change", function(e){lastComponent.props[lastProp] = dot(last).as(dot.input).getVal();})
|
|
1083
|
-
|
|
1084
|
-
lastComponent["__propContainer"].bindings[lastProp].push({
|
|
1085
|
-
element: last
|
|
1086
|
-
});
|
|
1087
|
-
|
|
1088
|
-
//var noListener = false;
|
|
1089
|
-
return ret;
|
|
1090
|
-
};
|
|
1091
|
-
|
|
1092
|
-
// ext("resetScopeClass", function(){
|
|
1093
|
-
// ClassPrefix.reset();
|
|
1094
|
-
// });
|
|
1095
|
-
|
|
1096
|
-
dot.resetScopeClass = function(){
|
|
1097
|
-
ClassPrefix.reset();
|
|
1098
|
-
return this;
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
// _p.bindTo = function(binding){
|
|
1102
|
-
// var last = this.getLast();
|
|
1103
|
-
// //var noListener = true;
|
|
1104
|
-
// var ret = this.setVal(binding.value);
|
|
1105
|
-
// attachEvent(last, "change", function(e){binding.value = this.getVal();})
|
|
1106
|
-
// binding.subscribe(last);
|
|
1107
|
-
// //var noListener = false;
|
|
1108
|
-
// return ret;
|
|
1109
|
-
// }
|
|
1110
|
-
|
|
1111
|
-
// export DotDocument;
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
dot.css = dotcss;
|
|
1126
|
-
dot.bus = eventBus;
|
|
1127
|
-
|
|
1128
|
-
// dot.component = addComponent;
|
|
1129
|
-
// TODO: might remove this in v4+
|
|
1130
|
-
// dot.removeComponent = removeComponent;
|
|
1131
|
-
|
|
1132
|
-
//Fill in all the other fields.
|
|
1133
|
-
//if(Object.create) dot.prototype = Object.create(_p);
|
|
1134
|
-
// dot.prototype.constructor = dot;
|
|
1135
|
-
dot["__currentArgCallback"] = [];
|
|
1136
|
-
dot["__document"] = null;
|
|
1137
|
-
dot["__if"] = null;
|
|
1138
|
-
dot["__pendingCalls"] = [];
|
|
1139
|
-
dot["__anonAttrFuncs"] = {};
|
|
1140
|
-
|
|
1141
|
-
// TODO: these may already exist?
|
|
1142
|
-
//dot.data = DotDocument.prototype.data;
|
|
1143
|
-
//dot.dataA = DotDocument.prototype.dataA;
|
|
1144
|
-
//dot.cite = DotDocument.prototype.cite;
|
|
1145
|
-
//dot.form = DotDocument.prototype.form;
|
|
1146
|
-
|
|
1147
|
-
export default dot;
|