@tko/binding.core 4.0.0-alpha8.0 → 4.0.0-beta1.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/dist/attr.js +36 -0
- package/dist/attr.js.map +7 -0
- package/dist/checked.js +94 -0
- package/dist/checked.js.map +7 -0
- package/dist/click.js +5 -0
- package/dist/click.js.map +7 -0
- package/dist/css.js +28 -0
- package/dist/css.js.map +7 -0
- package/dist/descendantsComplete.js +14 -0
- package/dist/descendantsComplete.js.map +7 -0
- package/dist/enableDisable.js +21 -0
- package/dist/enableDisable.js.map +7 -0
- package/dist/event.js +75 -0
- package/dist/event.js.map +7 -0
- package/dist/hasfocus.js +48 -0
- package/dist/hasfocus.js.map +7 -0
- package/dist/html.js +15 -0
- package/dist/html.js.map +7 -0
- package/dist/index.cjs +3956 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +50 -0
- package/dist/index.mjs.map +7 -0
- package/dist/let.js +12 -0
- package/dist/let.js.map +7 -0
- package/dist/options.js +130 -0
- package/dist/options.js.map +7 -0
- package/dist/selectedOptions.js +41 -0
- package/dist/selectedOptions.js.map +7 -0
- package/dist/style.js +30 -0
- package/dist/style.js.map +7 -0
- package/dist/submit.js +26 -0
- package/dist/submit.js.map +7 -0
- package/dist/test-helper.js +14 -0
- package/dist/test-helper.js.map +7 -0
- package/dist/text.js +13 -0
- package/dist/text.js.map +7 -0
- package/dist/textInput.js +151 -0
- package/dist/textInput.js.map +7 -0
- package/dist/uniqueName.js +13 -0
- package/dist/uniqueName.js.map +7 -0
- package/dist/using.js +12 -0
- package/dist/using.js.map +7 -0
- package/dist/value.js +103 -0
- package/dist/value.js.map +7 -0
- package/dist/visible.js +20 -0
- package/dist/visible.js.map +7 -0
- package/package.json +18 -28
- package/dist/binding.core.es6.js +0 -1044
- package/dist/binding.core.es6.js.map +0 -1
- package/dist/binding.core.js +0 -1143
- package/dist/binding.core.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3956 @@
|
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0-beta1.0 CommonJS
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// index.ts
|
|
21
|
+
var binding_exports = {};
|
|
22
|
+
__export(binding_exports, {
|
|
23
|
+
bindings: () => bindings
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(binding_exports);
|
|
26
|
+
|
|
27
|
+
// ../utils/dist/array.js
|
|
28
|
+
var { isArray } = Array;
|
|
29
|
+
function arrayForEach(array, action, thisArg) {
|
|
30
|
+
if (arguments.length > 2) {
|
|
31
|
+
action = action.bind(thisArg);
|
|
32
|
+
}
|
|
33
|
+
for (let i = 0, j = array.length; i < j; ++i) {
|
|
34
|
+
action(array[i], i, array);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function arrayIndexOf(array, item) {
|
|
38
|
+
return (isArray(array) ? array : [...array]).indexOf(item);
|
|
39
|
+
}
|
|
40
|
+
function arrayFirst(array, predicate, predicateOwner) {
|
|
41
|
+
return (isArray(array) ? array : [...array]).find(predicate, predicateOwner);
|
|
42
|
+
}
|
|
43
|
+
function arrayMap(array = [], mapping, thisArg) {
|
|
44
|
+
if (arguments.length > 2) {
|
|
45
|
+
mapping = mapping.bind(thisArg);
|
|
46
|
+
}
|
|
47
|
+
return array === null ? [] : Array.from(array, mapping);
|
|
48
|
+
}
|
|
49
|
+
function arrayRemoveItem(array, itemToRemove) {
|
|
50
|
+
var index = arrayIndexOf(array, itemToRemove);
|
|
51
|
+
if (index > 0) {
|
|
52
|
+
array.splice(index, 1);
|
|
53
|
+
} else if (index === 0) {
|
|
54
|
+
array.shift();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function arrayFilter(array, predicate, thisArg) {
|
|
58
|
+
if (arguments.length > 2) {
|
|
59
|
+
predicate = predicate.bind(thisArg);
|
|
60
|
+
}
|
|
61
|
+
return array === null ? [] : (isArray(array) ? array : [...array]).filter(predicate);
|
|
62
|
+
}
|
|
63
|
+
function arrayPushAll(array, valuesToPush) {
|
|
64
|
+
if (isArray(valuesToPush)) {
|
|
65
|
+
array.push.apply(array, valuesToPush);
|
|
66
|
+
} else {
|
|
67
|
+
for (var i = 0, j = valuesToPush.length; i < j; i++) {
|
|
68
|
+
array.push(valuesToPush[i]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return array;
|
|
72
|
+
}
|
|
73
|
+
function addOrRemoveItem(array, value2, included) {
|
|
74
|
+
var existingEntryIndex = arrayIndexOf(typeof array.peek === "function" ? array.peek() : array, value2);
|
|
75
|
+
if (existingEntryIndex < 0) {
|
|
76
|
+
if (included) {
|
|
77
|
+
array.push(value2);
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
if (!included) {
|
|
81
|
+
array.splice(existingEntryIndex, 1);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function makeArray(arrayLikeObject) {
|
|
86
|
+
return Array.from(arrayLikeObject);
|
|
87
|
+
}
|
|
88
|
+
function findMovesInArrayComparison(left, right, limitFailedCompares) {
|
|
89
|
+
if (left.length && right.length) {
|
|
90
|
+
var failedCompares, l, r, leftItem, rightItem;
|
|
91
|
+
for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {
|
|
92
|
+
for (r = 0; rightItem = right[r]; ++r) {
|
|
93
|
+
if (leftItem.value === rightItem.value) {
|
|
94
|
+
leftItem.moved = rightItem.index;
|
|
95
|
+
rightItem.moved = leftItem.index;
|
|
96
|
+
right.splice(r, 1);
|
|
97
|
+
failedCompares = r = 0;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
failedCompares += r;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
var statusNotInOld = "added";
|
|
106
|
+
var statusNotInNew = "deleted";
|
|
107
|
+
function compareArrays(oldArray, newArray, options3) {
|
|
108
|
+
options3 = typeof options3 === "boolean" ? { dontLimitMoves: options3 } : options3 || {};
|
|
109
|
+
oldArray = oldArray || [];
|
|
110
|
+
newArray = newArray || [];
|
|
111
|
+
if (oldArray.length < newArray.length) {
|
|
112
|
+
return compareSmallArrayToBigArray(oldArray, newArray, statusNotInOld, statusNotInNew, options3);
|
|
113
|
+
} else {
|
|
114
|
+
return compareSmallArrayToBigArray(newArray, oldArray, statusNotInNew, statusNotInOld, options3);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options3) {
|
|
118
|
+
var myMin = Math.min, myMax = Math.max, editDistanceMatrix = [], smlIndex, smlIndexMax = smlArray.length, bigIndex, bigIndexMax = bigArray.length, compareRange = bigIndexMax - smlIndexMax || 1, maxDistance = smlIndexMax + bigIndexMax + 1, thisRow, lastRow, bigIndexMaxForRow, bigIndexMinForRow;
|
|
119
|
+
for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {
|
|
120
|
+
lastRow = thisRow;
|
|
121
|
+
editDistanceMatrix.push(thisRow = []);
|
|
122
|
+
bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);
|
|
123
|
+
bigIndexMinForRow = myMax(0, smlIndex - 1);
|
|
124
|
+
for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {
|
|
125
|
+
if (!bigIndex) {
|
|
126
|
+
thisRow[bigIndex] = smlIndex + 1;
|
|
127
|
+
} else if (!smlIndex) {
|
|
128
|
+
thisRow[bigIndex] = bigIndex + 1;
|
|
129
|
+
} else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1]) {
|
|
130
|
+
thisRow[bigIndex] = lastRow[bigIndex - 1];
|
|
131
|
+
} else {
|
|
132
|
+
var northDistance = lastRow[bigIndex] || maxDistance;
|
|
133
|
+
var westDistance = thisRow[bigIndex - 1] || maxDistance;
|
|
134
|
+
thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
var editScript = [], meMinusOne, notInSml = [], notInBig = [];
|
|
139
|
+
for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex; ) {
|
|
140
|
+
meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;
|
|
141
|
+
if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {
|
|
142
|
+
notInSml.push(editScript[editScript.length] = {
|
|
143
|
+
"status": statusNotInSml,
|
|
144
|
+
"value": bigArray[--bigIndex],
|
|
145
|
+
"index": bigIndex
|
|
146
|
+
});
|
|
147
|
+
} else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {
|
|
148
|
+
notInBig.push(editScript[editScript.length] = {
|
|
149
|
+
"status": statusNotInBig,
|
|
150
|
+
"value": smlArray[--smlIndex],
|
|
151
|
+
"index": smlIndex
|
|
152
|
+
});
|
|
153
|
+
} else {
|
|
154
|
+
--bigIndex;
|
|
155
|
+
--smlIndex;
|
|
156
|
+
if (!options3.sparse) {
|
|
157
|
+
editScript.push({
|
|
158
|
+
"status": "retained",
|
|
159
|
+
"value": bigArray[bigIndex]
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
findMovesInArrayComparison(notInBig, notInSml, !options3.dontLimitMoves && smlIndexMax * 10);
|
|
165
|
+
return editScript.reverse();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ../utils/dist/options.js
|
|
169
|
+
var options = {
|
|
170
|
+
deferUpdates: false,
|
|
171
|
+
useOnlyNativeEvents: false,
|
|
172
|
+
protoProperty: "__ko_proto__",
|
|
173
|
+
defaultBindingAttribute: "data-bind",
|
|
174
|
+
allowVirtualElements: true,
|
|
175
|
+
bindingGlobals: /* @__PURE__ */ Object.create(null),
|
|
176
|
+
bindingProviderInstance: null,
|
|
177
|
+
createChildContextWithAs: false,
|
|
178
|
+
jQuery: globalThis.jQuery,
|
|
179
|
+
Promise: globalThis.Promise,
|
|
180
|
+
taskScheduler: null,
|
|
181
|
+
debug: false,
|
|
182
|
+
global: globalThis,
|
|
183
|
+
document: globalThis.document,
|
|
184
|
+
filters: {},
|
|
185
|
+
includeDestroyed: false,
|
|
186
|
+
foreachHidesDestroyed: false,
|
|
187
|
+
onError: function(e) {
|
|
188
|
+
throw e;
|
|
189
|
+
},
|
|
190
|
+
set: function(name, value2) {
|
|
191
|
+
options[name] = value2;
|
|
192
|
+
},
|
|
193
|
+
getBindingHandler() {
|
|
194
|
+
},
|
|
195
|
+
cleanExternalData() {
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
Object.defineProperty(options, "$", {
|
|
199
|
+
get: function() {
|
|
200
|
+
return options.jQuery;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
var options_default = options;
|
|
204
|
+
|
|
205
|
+
// ../utils/dist/error.js
|
|
206
|
+
function catchFunctionErrors(delegate) {
|
|
207
|
+
if (!options_default.onError) {
|
|
208
|
+
return delegate;
|
|
209
|
+
}
|
|
210
|
+
return (...args) => {
|
|
211
|
+
try {
|
|
212
|
+
return delegate(...args);
|
|
213
|
+
} catch (err) {
|
|
214
|
+
options_default.onError(err);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function deferError(error) {
|
|
219
|
+
safeSetTimeout(function() {
|
|
220
|
+
throw error;
|
|
221
|
+
}, 0);
|
|
222
|
+
}
|
|
223
|
+
function safeSetTimeout(handler2, timeout) {
|
|
224
|
+
return setTimeout(catchFunctionErrors(handler2), timeout);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// ../utils/dist/async.js
|
|
228
|
+
function throttle(callback, timeout) {
|
|
229
|
+
var timeoutInstance;
|
|
230
|
+
return function(...args) {
|
|
231
|
+
if (!timeoutInstance) {
|
|
232
|
+
timeoutInstance = safeSetTimeout(function() {
|
|
233
|
+
timeoutInstance = void 0;
|
|
234
|
+
callback(...args);
|
|
235
|
+
}, timeout);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function debounce(callback, timeout) {
|
|
240
|
+
var timeoutInstance;
|
|
241
|
+
return function(...args) {
|
|
242
|
+
clearTimeout(timeoutInstance);
|
|
243
|
+
timeoutInstance = safeSetTimeout(() => callback(...args), timeout);
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// ../utils/dist/ie.js
|
|
248
|
+
var ieVersion = options_default.document && function() {
|
|
249
|
+
var version = 3, div = options_default.document.createElement("div"), iElems = div.getElementsByTagName("i");
|
|
250
|
+
while (div.innerHTML = "<!--[if gt IE " + ++version + "]><i></i><![endif]-->", iElems[0]) {
|
|
251
|
+
}
|
|
252
|
+
if (!version) {
|
|
253
|
+
const userAgent = window.navigator.userAgent;
|
|
254
|
+
return ua.match(/MSIE ([^ ]+)/) || ua.match(/rv:([^ )]+)/);
|
|
255
|
+
}
|
|
256
|
+
return version > 4 ? version : void 0;
|
|
257
|
+
}();
|
|
258
|
+
|
|
259
|
+
// ../utils/dist/object.js
|
|
260
|
+
function hasOwnProperty(obj, propName) {
|
|
261
|
+
return Object.prototype.hasOwnProperty.call(obj, propName);
|
|
262
|
+
}
|
|
263
|
+
function isObjectLike(obj) {
|
|
264
|
+
if (obj === null) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
return typeof obj === "object" || typeof obj === "function";
|
|
268
|
+
}
|
|
269
|
+
function extend(target, source) {
|
|
270
|
+
if (source) {
|
|
271
|
+
for (var prop in source) {
|
|
272
|
+
if (hasOwnProperty(source, prop)) {
|
|
273
|
+
target[prop] = source[prop];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return target;
|
|
278
|
+
}
|
|
279
|
+
function objectForEach(obj, action) {
|
|
280
|
+
for (var prop in obj) {
|
|
281
|
+
if (hasOwnProperty(obj, prop)) {
|
|
282
|
+
action(prop, obj[prop]);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
function objectMap(source, mapping, thisArg) {
|
|
287
|
+
if (!source) {
|
|
288
|
+
return source;
|
|
289
|
+
}
|
|
290
|
+
if (arguments.length > 2) {
|
|
291
|
+
mapping = mapping.bind(thisArg);
|
|
292
|
+
}
|
|
293
|
+
var target = {};
|
|
294
|
+
for (var prop in source) {
|
|
295
|
+
if (hasOwnProperty(source, prop)) {
|
|
296
|
+
target[prop] = mapping(source[prop], prop, source);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return target;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// ../utils/dist/function.js
|
|
303
|
+
function testOverwrite() {
|
|
304
|
+
try {
|
|
305
|
+
Object.defineProperty(function x() {
|
|
306
|
+
}, "length", {});
|
|
307
|
+
return true;
|
|
308
|
+
} catch (e) {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
var functionSupportsLengthOverwrite = testOverwrite();
|
|
313
|
+
function overwriteLengthPropertyIfSupported(fn, descriptor) {
|
|
314
|
+
if (functionSupportsLengthOverwrite) {
|
|
315
|
+
Object.defineProperty(fn, "length", descriptor);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// ../utils/dist/string.js
|
|
320
|
+
function stringTrim(string) {
|
|
321
|
+
return string === null || string === void 0 ? "" : string.trim ? string.trim() : string.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g, "");
|
|
322
|
+
}
|
|
323
|
+
function stringStartsWith(string, startsWith) {
|
|
324
|
+
string = string || "";
|
|
325
|
+
if (startsWith.length > string.length) {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
return string.substring(0, startsWith.length) === startsWith;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// ../utils/dist/symbol.js
|
|
332
|
+
var useSymbols = typeof Symbol === "function";
|
|
333
|
+
function createSymbolOrString(identifier) {
|
|
334
|
+
return useSymbols ? Symbol(identifier) : identifier;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// ../utils/dist/css.js
|
|
338
|
+
var cssClassNameRegex = /\S+/g;
|
|
339
|
+
function toggleDomNodeCssClass(node, classNames, shouldHaveClass) {
|
|
340
|
+
var addOrRemoveFn;
|
|
341
|
+
if (!classNames) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (typeof node.classList === "object") {
|
|
345
|
+
addOrRemoveFn = node.classList[shouldHaveClass ? "add" : "remove"];
|
|
346
|
+
arrayForEach(classNames.match(cssClassNameRegex), function(className) {
|
|
347
|
+
addOrRemoveFn.call(node.classList, className);
|
|
348
|
+
});
|
|
349
|
+
} else if (typeof node.className["baseVal"] === "string") {
|
|
350
|
+
toggleObjectClassPropertyString(node.className, "baseVal", classNames, shouldHaveClass);
|
|
351
|
+
} else {
|
|
352
|
+
toggleObjectClassPropertyString(node, "className", classNames, shouldHaveClass);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function toggleObjectClassPropertyString(obj, prop, classNames, shouldHaveClass) {
|
|
356
|
+
var currentClassNames = obj[prop].match(cssClassNameRegex) || [];
|
|
357
|
+
arrayForEach(classNames.match(cssClassNameRegex), function(className) {
|
|
358
|
+
addOrRemoveItem(currentClassNames, className, shouldHaveClass);
|
|
359
|
+
});
|
|
360
|
+
obj[prop] = currentClassNames.join(" ");
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// ../utils/dist/jquery.js
|
|
364
|
+
var jQueryInstance = options_default.global && options_default.global.jQuery;
|
|
365
|
+
|
|
366
|
+
// ../utils/dist/dom/info.js
|
|
367
|
+
function domNodeIsContainedBy(node, containedByNode) {
|
|
368
|
+
if (node === containedByNode) {
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
if (node.nodeType === 11) {
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
if (containedByNode.contains) {
|
|
375
|
+
return containedByNode.contains(node.nodeType !== 1 ? node.parentNode : node);
|
|
376
|
+
}
|
|
377
|
+
if (containedByNode.compareDocumentPosition) {
|
|
378
|
+
return (containedByNode.compareDocumentPosition(node) & 16) == 16;
|
|
379
|
+
}
|
|
380
|
+
while (node && node != containedByNode) {
|
|
381
|
+
node = node.parentNode;
|
|
382
|
+
}
|
|
383
|
+
return !!node;
|
|
384
|
+
}
|
|
385
|
+
function domNodeIsAttachedToDocument(node) {
|
|
386
|
+
return domNodeIsContainedBy(node, node.ownerDocument.documentElement);
|
|
387
|
+
}
|
|
388
|
+
function anyDomNodeIsAttachedToDocument(nodes) {
|
|
389
|
+
return !!arrayFirst(nodes, domNodeIsAttachedToDocument);
|
|
390
|
+
}
|
|
391
|
+
function tagNameLower(element) {
|
|
392
|
+
return element && element.tagName && element.tagName.toLowerCase();
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// ../utils/dist/dom/data.js
|
|
396
|
+
var data_exports = {};
|
|
397
|
+
__export(data_exports, {
|
|
398
|
+
clear: () => clear,
|
|
399
|
+
get: () => get,
|
|
400
|
+
getOrSet: () => getOrSet,
|
|
401
|
+
nextKey: () => nextKey,
|
|
402
|
+
set: () => set
|
|
403
|
+
});
|
|
404
|
+
var datastoreTime = new Date().getTime();
|
|
405
|
+
var dataStoreKeyExpandoPropertyName = `__ko__${datastoreTime}`;
|
|
406
|
+
var dataStoreSymbol = Symbol("Knockout data");
|
|
407
|
+
var dataStore;
|
|
408
|
+
var uniqueId = 0;
|
|
409
|
+
var modern = {
|
|
410
|
+
getDataForNode(node, createIfNotFound) {
|
|
411
|
+
let dataForNode = node[dataStoreSymbol];
|
|
412
|
+
if (!dataForNode && createIfNotFound) {
|
|
413
|
+
dataForNode = node[dataStoreSymbol] = {};
|
|
414
|
+
}
|
|
415
|
+
return dataForNode;
|
|
416
|
+
},
|
|
417
|
+
clear(node) {
|
|
418
|
+
if (node[dataStoreSymbol]) {
|
|
419
|
+
delete node[dataStoreSymbol];
|
|
420
|
+
return true;
|
|
421
|
+
}
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
var IE = {
|
|
426
|
+
getDataforNode(node, createIfNotFound) {
|
|
427
|
+
let dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
|
428
|
+
const hasExistingDataStore = dataStoreKey && dataStoreKey !== "null" && dataStore[dataStoreKey];
|
|
429
|
+
if (!hasExistingDataStore) {
|
|
430
|
+
if (!createIfNotFound) {
|
|
431
|
+
return void 0;
|
|
432
|
+
}
|
|
433
|
+
dataStoreKey = node[dataStoreKeyExpandoPropertyName] = "ko" + uniqueId++;
|
|
434
|
+
dataStore[dataStoreKey] = {};
|
|
435
|
+
}
|
|
436
|
+
return dataStore[dataStoreKey];
|
|
437
|
+
},
|
|
438
|
+
clear(node) {
|
|
439
|
+
const dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
|
440
|
+
if (dataStoreKey) {
|
|
441
|
+
delete dataStore[dataStoreKey];
|
|
442
|
+
node[dataStoreKeyExpandoPropertyName] = null;
|
|
443
|
+
return true;
|
|
444
|
+
}
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
var { getDataForNode, clear } = ieVersion ? IE : modern;
|
|
449
|
+
function nextKey() {
|
|
450
|
+
return uniqueId++ + dataStoreKeyExpandoPropertyName;
|
|
451
|
+
}
|
|
452
|
+
function get(node, key) {
|
|
453
|
+
const dataForNode = getDataForNode(node, false);
|
|
454
|
+
return dataForNode && dataForNode[key];
|
|
455
|
+
}
|
|
456
|
+
function set(node, key, value2) {
|
|
457
|
+
var dataForNode = getDataForNode(node, value2 !== void 0);
|
|
458
|
+
dataForNode && (dataForNode[key] = value2);
|
|
459
|
+
}
|
|
460
|
+
function getOrSet(node, key, value2) {
|
|
461
|
+
const dataForNode = getDataForNode(node, true);
|
|
462
|
+
return dataForNode[key] || (dataForNode[key] = value2);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// ../utils/dist/dom/disposal.js
|
|
466
|
+
var domDataKey = nextKey();
|
|
467
|
+
var cleanableNodeTypes = { 1: true, 8: true, 9: true };
|
|
468
|
+
var cleanableNodeTypesWithDescendants = { 1: true, 9: true };
|
|
469
|
+
function getDisposeCallbacksCollection(node, createIfNotFound) {
|
|
470
|
+
var allDisposeCallbacks = get(node, domDataKey);
|
|
471
|
+
if (allDisposeCallbacks === void 0 && createIfNotFound) {
|
|
472
|
+
allDisposeCallbacks = [];
|
|
473
|
+
set(node, domDataKey, allDisposeCallbacks);
|
|
474
|
+
}
|
|
475
|
+
return allDisposeCallbacks;
|
|
476
|
+
}
|
|
477
|
+
function destroyCallbacksCollection(node) {
|
|
478
|
+
set(node, domDataKey, void 0);
|
|
479
|
+
}
|
|
480
|
+
function cleanSingleNode(node) {
|
|
481
|
+
var callbacks = getDisposeCallbacksCollection(node, false);
|
|
482
|
+
if (callbacks) {
|
|
483
|
+
callbacks = callbacks.slice(0);
|
|
484
|
+
for (let i = 0; i < callbacks.length; i++) {
|
|
485
|
+
callbacks[i](node);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
clear(node);
|
|
489
|
+
for (let i = 0, j = otherNodeCleanerFunctions.length; i < j; ++i) {
|
|
490
|
+
otherNodeCleanerFunctions[i](node);
|
|
491
|
+
}
|
|
492
|
+
if (options_default.cleanExternalData) {
|
|
493
|
+
options_default.cleanExternalData(node);
|
|
494
|
+
}
|
|
495
|
+
if (cleanableNodeTypesWithDescendants[node.nodeType]) {
|
|
496
|
+
cleanNodesInList(node.childNodes, true);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
function cleanNodesInList(nodeList, onlyComments) {
|
|
500
|
+
const cleanedNodes = [];
|
|
501
|
+
let lastCleanedNode;
|
|
502
|
+
for (var i = 0; i < nodeList.length; i++) {
|
|
503
|
+
if (!onlyComments || nodeList[i].nodeType === 8) {
|
|
504
|
+
cleanSingleNode(cleanedNodes[cleanedNodes.length] = lastCleanedNode = nodeList[i]);
|
|
505
|
+
if (nodeList[i] !== lastCleanedNode) {
|
|
506
|
+
while (i-- && arrayIndexOf(cleanedNodes, nodeList[i]) === -1) {
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
function addDisposeCallback(node, callback) {
|
|
513
|
+
if (typeof callback !== "function") {
|
|
514
|
+
throw new Error("Callback must be a function");
|
|
515
|
+
}
|
|
516
|
+
getDisposeCallbacksCollection(node, true).push(callback);
|
|
517
|
+
}
|
|
518
|
+
function removeDisposeCallback(node, callback) {
|
|
519
|
+
var callbacksCollection = getDisposeCallbacksCollection(node, false);
|
|
520
|
+
if (callbacksCollection) {
|
|
521
|
+
arrayRemoveItem(callbacksCollection, callback);
|
|
522
|
+
if (callbacksCollection.length === 0) {
|
|
523
|
+
destroyCallbacksCollection(node);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
function cleanNode(node) {
|
|
528
|
+
if (cleanableNodeTypes[node.nodeType]) {
|
|
529
|
+
cleanSingleNode(node);
|
|
530
|
+
if (cleanableNodeTypesWithDescendants[node.nodeType]) {
|
|
531
|
+
cleanNodesInList(node.getElementsByTagName("*"));
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return node;
|
|
535
|
+
}
|
|
536
|
+
function removeNode(node) {
|
|
537
|
+
cleanNode(node);
|
|
538
|
+
if (node.parentNode) {
|
|
539
|
+
node.parentNode.removeChild(node);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
var otherNodeCleanerFunctions = [];
|
|
543
|
+
function cleanjQueryData(node) {
|
|
544
|
+
var jQueryCleanNodeFn = jQueryInstance ? jQueryInstance.cleanData : null;
|
|
545
|
+
if (jQueryCleanNodeFn) {
|
|
546
|
+
jQueryCleanNodeFn([node]);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
otherNodeCleanerFunctions.push(cleanjQueryData);
|
|
550
|
+
|
|
551
|
+
// ../utils/dist/dom/event.js
|
|
552
|
+
var knownEvents = {};
|
|
553
|
+
var knownEventTypesByEventName = {};
|
|
554
|
+
var keyEventTypeName = options_default.global.navigator && /Firefox\/2/i.test(options_default.global.navigator.userAgent) ? "KeyboardEvent" : "UIEvents";
|
|
555
|
+
knownEvents[keyEventTypeName] = ["keyup", "keydown", "keypress"];
|
|
556
|
+
knownEvents["MouseEvents"] = [
|
|
557
|
+
"click",
|
|
558
|
+
"dblclick",
|
|
559
|
+
"mousedown",
|
|
560
|
+
"mouseup",
|
|
561
|
+
"mousemove",
|
|
562
|
+
"mouseover",
|
|
563
|
+
"mouseout",
|
|
564
|
+
"mouseenter",
|
|
565
|
+
"mouseleave"
|
|
566
|
+
];
|
|
567
|
+
objectForEach(knownEvents, function(eventType, knownEventsForType) {
|
|
568
|
+
if (knownEventsForType.length) {
|
|
569
|
+
for (var i = 0, j = knownEventsForType.length; i < j; i++) {
|
|
570
|
+
knownEventTypesByEventName[knownEventsForType[i]] = eventType;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
function isClickOnCheckableElement(element, eventType) {
|
|
575
|
+
if (tagNameLower(element) !== "input" || !element.type)
|
|
576
|
+
return false;
|
|
577
|
+
if (eventType.toLowerCase() != "click")
|
|
578
|
+
return false;
|
|
579
|
+
var inputType = element.type;
|
|
580
|
+
return inputType == "checkbox" || inputType == "radio";
|
|
581
|
+
}
|
|
582
|
+
var eventsThatMustBeRegisteredUsingAttachEvent = { "propertychange": true };
|
|
583
|
+
var jQueryEventAttachName;
|
|
584
|
+
function registerEventHandler(element, eventType, handler2, eventOptions = false) {
|
|
585
|
+
const wrappedHandler = catchFunctionErrors(handler2);
|
|
586
|
+
const mustUseAttachEvent = ieVersion && eventsThatMustBeRegisteredUsingAttachEvent[eventType];
|
|
587
|
+
const mustUseNative = Boolean(eventOptions);
|
|
588
|
+
if (!options_default.useOnlyNativeEvents && !mustUseAttachEvent && !mustUseNative && jQueryInstance) {
|
|
589
|
+
if (!jQueryEventAttachName) {
|
|
590
|
+
jQueryEventAttachName = typeof jQueryInstance(element).on === "function" ? "on" : "bind";
|
|
591
|
+
}
|
|
592
|
+
jQueryInstance(element)[jQueryEventAttachName](eventType, wrappedHandler);
|
|
593
|
+
} else if (!mustUseAttachEvent && typeof element.addEventListener === "function") {
|
|
594
|
+
element.addEventListener(eventType, wrappedHandler, eventOptions);
|
|
595
|
+
} else if (typeof element.attachEvent !== "undefined") {
|
|
596
|
+
const attachEventHandler = function(event) {
|
|
597
|
+
wrappedHandler.call(element, event);
|
|
598
|
+
};
|
|
599
|
+
const attachEventName = "on" + eventType;
|
|
600
|
+
element.attachEvent(attachEventName, attachEventHandler);
|
|
601
|
+
addDisposeCallback(element, function() {
|
|
602
|
+
element.detachEvent(attachEventName, attachEventHandler);
|
|
603
|
+
});
|
|
604
|
+
} else {
|
|
605
|
+
throw new Error("Browser doesn't support addEventListener or attachEvent");
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
function triggerEvent(element, eventType) {
|
|
609
|
+
if (!(element && element.nodeType)) {
|
|
610
|
+
throw new Error("element must be a DOM node when calling triggerEvent");
|
|
611
|
+
}
|
|
612
|
+
var useClickWorkaround = isClickOnCheckableElement(element, eventType);
|
|
613
|
+
if (!options_default.useOnlyNativeEvents && jQueryInstance && !useClickWorkaround) {
|
|
614
|
+
jQueryInstance(element).trigger(eventType);
|
|
615
|
+
} else if (typeof document.createEvent === "function") {
|
|
616
|
+
if (typeof element.dispatchEvent === "function") {
|
|
617
|
+
var eventCategory = knownEventTypesByEventName[eventType] || "HTMLEvents";
|
|
618
|
+
var event = document.createEvent(eventCategory);
|
|
619
|
+
event.initEvent(eventType, true, true, options_default.global, 0, 0, 0, 0, 0, false, false, false, false, 0, element);
|
|
620
|
+
element.dispatchEvent(event);
|
|
621
|
+
} else {
|
|
622
|
+
throw new Error("The supplied element doesn't support dispatchEvent");
|
|
623
|
+
}
|
|
624
|
+
} else if (useClickWorkaround && element.click) {
|
|
625
|
+
element.click();
|
|
626
|
+
} else if (typeof element.fireEvent !== "undefined") {
|
|
627
|
+
element.fireEvent("on" + eventType);
|
|
628
|
+
} else {
|
|
629
|
+
throw new Error("Browser doesn't support triggering events");
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// ../utils/dist/dom/manipulation.js
|
|
634
|
+
function setDomNodeChildren(domNode, childNodes2) {
|
|
635
|
+
emptyDomNode(domNode);
|
|
636
|
+
if (childNodes2) {
|
|
637
|
+
for (var i = 0, j = childNodes2.length; i < j; i++) {
|
|
638
|
+
domNode.appendChild(childNodes2[i]);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
function replaceDomNodes(nodeToReplaceOrNodeArray, newNodesArray) {
|
|
643
|
+
var nodesToReplaceArray = nodeToReplaceOrNodeArray.nodeType ? [nodeToReplaceOrNodeArray] : nodeToReplaceOrNodeArray;
|
|
644
|
+
if (nodesToReplaceArray.length > 0) {
|
|
645
|
+
var insertionPoint = nodesToReplaceArray[0];
|
|
646
|
+
var parent = insertionPoint.parentNode;
|
|
647
|
+
for (var i = 0, j = newNodesArray.length; i < j; i++) {
|
|
648
|
+
parent.insertBefore(newNodesArray[i], insertionPoint);
|
|
649
|
+
}
|
|
650
|
+
for (i = 0, j = nodesToReplaceArray.length; i < j; i++) {
|
|
651
|
+
removeNode(nodesToReplaceArray[i]);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
function setElementName(element, name) {
|
|
656
|
+
element.name = name;
|
|
657
|
+
if (ieVersion <= 7) {
|
|
658
|
+
try {
|
|
659
|
+
element.mergeAttributes(document.createElement("<input name='" + element.name + "'/>"), false);
|
|
660
|
+
} catch (e) {
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
function emptyDomNode(domNode) {
|
|
665
|
+
while (domNode.firstChild) {
|
|
666
|
+
removeNode(domNode.firstChild);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// ../utils/dist/dom/fixes.js
|
|
671
|
+
function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {
|
|
672
|
+
if (continuousNodeArray.length) {
|
|
673
|
+
parentNode = parentNode.nodeType === 8 && parentNode.parentNode || parentNode;
|
|
674
|
+
while (continuousNodeArray.length && continuousNodeArray[0].parentNode !== parentNode) {
|
|
675
|
+
continuousNodeArray.splice(0, 1);
|
|
676
|
+
}
|
|
677
|
+
while (continuousNodeArray.length > 1 && continuousNodeArray[continuousNodeArray.length - 1].parentNode !== parentNode) {
|
|
678
|
+
continuousNodeArray.length--;
|
|
679
|
+
}
|
|
680
|
+
if (continuousNodeArray.length > 1) {
|
|
681
|
+
var current = continuousNodeArray[0], last = continuousNodeArray[continuousNodeArray.length - 1];
|
|
682
|
+
continuousNodeArray.length = 0;
|
|
683
|
+
while (current !== last) {
|
|
684
|
+
continuousNodeArray.push(current);
|
|
685
|
+
current = current.nextSibling;
|
|
686
|
+
}
|
|
687
|
+
continuousNodeArray.push(last);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
return continuousNodeArray;
|
|
691
|
+
}
|
|
692
|
+
function setOptionNodeSelectionState(optionNode, isSelected) {
|
|
693
|
+
if (ieVersion < 7) {
|
|
694
|
+
optionNode.setAttribute("selected", isSelected);
|
|
695
|
+
} else {
|
|
696
|
+
optionNode.selected = isSelected;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
function forceRefresh(node) {
|
|
700
|
+
if (ieVersion >= 9) {
|
|
701
|
+
var elem = node.nodeType == 1 ? node : node.parentNode;
|
|
702
|
+
if (elem.style) {
|
|
703
|
+
elem.style.zoom = elem.style.zoom;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
function ensureSelectElementIsRenderedCorrectly(selectElement) {
|
|
708
|
+
if (ieVersion) {
|
|
709
|
+
var originalWidth = selectElement.style.width;
|
|
710
|
+
selectElement.style.width = 0;
|
|
711
|
+
selectElement.style.width = originalWidth;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
// ../utils/dist/dom/virtualElements.js
|
|
716
|
+
var virtualElements_exports = {};
|
|
717
|
+
__export(virtualElements_exports, {
|
|
718
|
+
allowedBindings: () => allowedBindings,
|
|
719
|
+
childNodes: () => childNodes,
|
|
720
|
+
emptyNode: () => emptyNode,
|
|
721
|
+
endCommentRegex: () => endCommentRegex,
|
|
722
|
+
firstChild: () => firstChild,
|
|
723
|
+
getVirtualChildren: () => getVirtualChildren,
|
|
724
|
+
hasBindingValue: () => hasBindingValue,
|
|
725
|
+
insertAfter: () => insertAfter,
|
|
726
|
+
isEndComment: () => isEndComment,
|
|
727
|
+
isStartComment: () => isStartComment,
|
|
728
|
+
lastChild: () => lastChild,
|
|
729
|
+
nextSibling: () => nextSibling,
|
|
730
|
+
normaliseVirtualElementDomStructure: () => normaliseVirtualElementDomStructure,
|
|
731
|
+
prepend: () => prepend,
|
|
732
|
+
previousSibling: () => previousSibling,
|
|
733
|
+
setDomNodeChildren: () => setDomNodeChildren2,
|
|
734
|
+
startCommentRegex: () => startCommentRegex,
|
|
735
|
+
virtualNodeBindingValue: () => virtualNodeBindingValue
|
|
736
|
+
});
|
|
737
|
+
var commentNodesHaveTextProperty = options_default.document && options_default.document.createComment("test").text === "<!--test-->";
|
|
738
|
+
var startCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*ko(?:\s+([\s\S]+))?\s*-->$/ : /^\s*ko(?:\s+([\s\S]+))?\s*$/;
|
|
739
|
+
var endCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*\/ko\s*-->$/ : /^\s*\/ko\s*$/;
|
|
740
|
+
var htmlTagsWithOptionallyClosingChildren = { "ul": true, "ol": true };
|
|
741
|
+
function isStartComment(node) {
|
|
742
|
+
return node.nodeType == 8 && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
|
|
743
|
+
}
|
|
744
|
+
function isEndComment(node) {
|
|
745
|
+
return node.nodeType == 8 && endCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
|
|
746
|
+
}
|
|
747
|
+
function isUnmatchedEndComment(node) {
|
|
748
|
+
return isEndComment(node) && !get(node, matchedEndCommentDataKey);
|
|
749
|
+
}
|
|
750
|
+
var matchedEndCommentDataKey = "__ko_matchedEndComment__";
|
|
751
|
+
function getVirtualChildren(startComment, allowUnbalanced) {
|
|
752
|
+
var currentNode = startComment;
|
|
753
|
+
var depth = 1;
|
|
754
|
+
var children = [];
|
|
755
|
+
while (currentNode = currentNode.nextSibling) {
|
|
756
|
+
if (isEndComment(currentNode)) {
|
|
757
|
+
set(currentNode, matchedEndCommentDataKey, true);
|
|
758
|
+
depth--;
|
|
759
|
+
if (depth === 0) {
|
|
760
|
+
return children;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
children.push(currentNode);
|
|
764
|
+
if (isStartComment(currentNode)) {
|
|
765
|
+
depth++;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
if (!allowUnbalanced) {
|
|
769
|
+
throw new Error("Cannot find closing comment tag to match: " + startComment.nodeValue);
|
|
770
|
+
}
|
|
771
|
+
return null;
|
|
772
|
+
}
|
|
773
|
+
function getMatchingEndComment(startComment, allowUnbalanced) {
|
|
774
|
+
var allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);
|
|
775
|
+
if (allVirtualChildren) {
|
|
776
|
+
if (allVirtualChildren.length > 0) {
|
|
777
|
+
return allVirtualChildren[allVirtualChildren.length - 1].nextSibling;
|
|
778
|
+
}
|
|
779
|
+
return startComment.nextSibling;
|
|
780
|
+
} else {
|
|
781
|
+
return null;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
function getUnbalancedChildTags(node) {
|
|
785
|
+
var childNode = node.firstChild, captureRemaining = null;
|
|
786
|
+
if (childNode) {
|
|
787
|
+
do {
|
|
788
|
+
if (captureRemaining) {
|
|
789
|
+
captureRemaining.push(childNode);
|
|
790
|
+
} else if (isStartComment(childNode)) {
|
|
791
|
+
var matchingEndComment = getMatchingEndComment(childNode, true);
|
|
792
|
+
if (matchingEndComment) {
|
|
793
|
+
childNode = matchingEndComment;
|
|
794
|
+
} else {
|
|
795
|
+
captureRemaining = [childNode];
|
|
796
|
+
}
|
|
797
|
+
} else if (isEndComment(childNode)) {
|
|
798
|
+
captureRemaining = [childNode];
|
|
799
|
+
}
|
|
800
|
+
} while (childNode = childNode.nextSibling);
|
|
801
|
+
}
|
|
802
|
+
return captureRemaining;
|
|
803
|
+
}
|
|
804
|
+
var allowedBindings = {};
|
|
805
|
+
var hasBindingValue = isStartComment;
|
|
806
|
+
function childNodes(node) {
|
|
807
|
+
return isStartComment(node) ? getVirtualChildren(node) : node.childNodes;
|
|
808
|
+
}
|
|
809
|
+
function emptyNode(node) {
|
|
810
|
+
if (!isStartComment(node)) {
|
|
811
|
+
emptyDomNode(node);
|
|
812
|
+
} else {
|
|
813
|
+
var virtualChildren = childNodes(node);
|
|
814
|
+
for (var i = 0, j = virtualChildren.length; i < j; i++) {
|
|
815
|
+
removeNode(virtualChildren[i]);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
function setDomNodeChildren2(node, childNodes2) {
|
|
820
|
+
if (!isStartComment(node)) {
|
|
821
|
+
setDomNodeChildren(node, childNodes2);
|
|
822
|
+
} else {
|
|
823
|
+
emptyNode(node);
|
|
824
|
+
const endCommentNode = node.nextSibling;
|
|
825
|
+
const parentNode = endCommentNode.parentNode;
|
|
826
|
+
for (var i = 0, j = childNodes2.length; i < j; ++i) {
|
|
827
|
+
parentNode.insertBefore(childNodes2[i], endCommentNode);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
function prepend(containerNode, nodeToPrepend) {
|
|
832
|
+
if (!isStartComment(containerNode)) {
|
|
833
|
+
if (containerNode.firstChild) {
|
|
834
|
+
containerNode.insertBefore(nodeToPrepend, containerNode.firstChild);
|
|
835
|
+
} else {
|
|
836
|
+
containerNode.appendChild(nodeToPrepend);
|
|
837
|
+
}
|
|
838
|
+
} else {
|
|
839
|
+
containerNode.parentNode.insertBefore(nodeToPrepend, containerNode.nextSibling);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
function insertAfter(containerNode, nodeToInsert, insertAfterNode) {
|
|
843
|
+
if (!insertAfterNode) {
|
|
844
|
+
prepend(containerNode, nodeToInsert);
|
|
845
|
+
} else if (!isStartComment(containerNode)) {
|
|
846
|
+
if (insertAfterNode.nextSibling) {
|
|
847
|
+
containerNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
|
|
848
|
+
} else {
|
|
849
|
+
containerNode.appendChild(nodeToInsert);
|
|
850
|
+
}
|
|
851
|
+
} else {
|
|
852
|
+
containerNode.parentNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
function firstChild(node) {
|
|
856
|
+
if (!isStartComment(node)) {
|
|
857
|
+
if (node.firstChild && isEndComment(node.firstChild)) {
|
|
858
|
+
throw new Error("Found invalid end comment, as the first child of " + node.outerHTML);
|
|
859
|
+
}
|
|
860
|
+
return node.firstChild;
|
|
861
|
+
}
|
|
862
|
+
if (!node.nextSibling || isEndComment(node.nextSibling)) {
|
|
863
|
+
return null;
|
|
864
|
+
}
|
|
865
|
+
return node.nextSibling;
|
|
866
|
+
}
|
|
867
|
+
function lastChild(node) {
|
|
868
|
+
let nextChild = firstChild(node);
|
|
869
|
+
let lastChildNode;
|
|
870
|
+
do {
|
|
871
|
+
lastChildNode = nextChild;
|
|
872
|
+
} while (nextChild = nextSibling(nextChild));
|
|
873
|
+
return lastChildNode;
|
|
874
|
+
}
|
|
875
|
+
function nextSibling(node) {
|
|
876
|
+
if (isStartComment(node)) {
|
|
877
|
+
node = getMatchingEndComment(node);
|
|
878
|
+
}
|
|
879
|
+
if (node.nextSibling && isEndComment(node.nextSibling)) {
|
|
880
|
+
if (isUnmatchedEndComment(node.nextSibling)) {
|
|
881
|
+
throw Error("Found end comment without a matching opening comment, as next sibling of " + node.outerHTML);
|
|
882
|
+
}
|
|
883
|
+
return null;
|
|
884
|
+
} else {
|
|
885
|
+
return node.nextSibling;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
function previousSibling(node) {
|
|
889
|
+
var depth = 0;
|
|
890
|
+
do {
|
|
891
|
+
if (node.nodeType === 8) {
|
|
892
|
+
if (isStartComment(node)) {
|
|
893
|
+
if (--depth === 0) {
|
|
894
|
+
return node;
|
|
895
|
+
}
|
|
896
|
+
} else if (isEndComment(node)) {
|
|
897
|
+
depth++;
|
|
898
|
+
}
|
|
899
|
+
} else {
|
|
900
|
+
if (depth === 0) {
|
|
901
|
+
return node;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
} while (node = node.previousSibling);
|
|
905
|
+
}
|
|
906
|
+
function virtualNodeBindingValue(node) {
|
|
907
|
+
var regexMatch = (commentNodesHaveTextProperty ? node.text : node.nodeValue).match(startCommentRegex);
|
|
908
|
+
return regexMatch ? regexMatch[1] : null;
|
|
909
|
+
}
|
|
910
|
+
function normaliseVirtualElementDomStructure(elementVerified) {
|
|
911
|
+
if (!htmlTagsWithOptionallyClosingChildren[tagNameLower(elementVerified)]) {
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
var childNode = elementVerified.firstChild;
|
|
915
|
+
if (childNode) {
|
|
916
|
+
do {
|
|
917
|
+
if (childNode.nodeType === 1) {
|
|
918
|
+
var unbalancedTags = getUnbalancedChildTags(childNode);
|
|
919
|
+
if (unbalancedTags) {
|
|
920
|
+
var nodeToInsertBefore = childNode.nextSibling;
|
|
921
|
+
for (var i = 0; i < unbalancedTags.length; i++) {
|
|
922
|
+
if (nodeToInsertBefore) {
|
|
923
|
+
elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore);
|
|
924
|
+
} else {
|
|
925
|
+
elementVerified.appendChild(unbalancedTags[i]);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
} while (childNode = childNode.nextSibling);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// ../utils/dist/dom/html.js
|
|
935
|
+
var none = [0, "", ""];
|
|
936
|
+
var table = [1, "<table>", "</table>"];
|
|
937
|
+
var tbody = [2, "<table><tbody>", "</tbody></table>"];
|
|
938
|
+
var colgroup = [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"];
|
|
939
|
+
var tr = [3, "<table><tbody><tr>", "</tr></tbody></table>"];
|
|
940
|
+
var select = [1, "<select multiple='multiple'>", "</select>"];
|
|
941
|
+
var fieldset = [1, "<fieldset>", "</fieldset>"];
|
|
942
|
+
var map = [1, "<map>", "</map>"];
|
|
943
|
+
var object = [1, "<object>", "</object>"];
|
|
944
|
+
var lookup = {
|
|
945
|
+
"area": map,
|
|
946
|
+
"col": colgroup,
|
|
947
|
+
"colgroup": table,
|
|
948
|
+
"caption": table,
|
|
949
|
+
"legend": fieldset,
|
|
950
|
+
"thead": table,
|
|
951
|
+
"tbody": table,
|
|
952
|
+
"tfoot": table,
|
|
953
|
+
"tr": tbody,
|
|
954
|
+
"td": tr,
|
|
955
|
+
"th": tr,
|
|
956
|
+
"option": select,
|
|
957
|
+
"optgroup": select,
|
|
958
|
+
"param": object
|
|
959
|
+
};
|
|
960
|
+
var supportsTemplateTag = options_default.document && "content" in options_default.document.createElement("template");
|
|
961
|
+
function getWrap(tags) {
|
|
962
|
+
const m = tags.match(/^(?:<!--.*?-->\s*?)*?<([a-z]+)[\s>]/);
|
|
963
|
+
return m && lookup[m[1]] || none;
|
|
964
|
+
}
|
|
965
|
+
function simpleHtmlParse(html2, documentContext) {
|
|
966
|
+
documentContext || (documentContext = document);
|
|
967
|
+
var windowContext = documentContext["parentWindow"] || documentContext["defaultView"] || window;
|
|
968
|
+
var tags = stringTrim(html2).toLowerCase(), div = documentContext.createElement("div"), wrap = getWrap(tags), depth = wrap[0];
|
|
969
|
+
var markup = "ignored<div>" + wrap[1] + html2 + wrap[2] + "</div>";
|
|
970
|
+
if (typeof windowContext["innerShiv"] === "function") {
|
|
971
|
+
div.appendChild(windowContext["innerShiv"](markup));
|
|
972
|
+
} else {
|
|
973
|
+
div.innerHTML = markup;
|
|
974
|
+
}
|
|
975
|
+
while (depth--) {
|
|
976
|
+
div = div.lastChild;
|
|
977
|
+
}
|
|
978
|
+
return makeArray(div.lastChild.childNodes);
|
|
979
|
+
}
|
|
980
|
+
function templateHtmlParse(html2, documentContext) {
|
|
981
|
+
if (!documentContext) {
|
|
982
|
+
documentContext = document;
|
|
983
|
+
}
|
|
984
|
+
var template = documentContext.createElement("template");
|
|
985
|
+
template.innerHTML = html2;
|
|
986
|
+
return makeArray(template.content.childNodes);
|
|
987
|
+
}
|
|
988
|
+
function jQueryHtmlParse(html2, documentContext) {
|
|
989
|
+
if (jQueryInstance.parseHTML) {
|
|
990
|
+
return jQueryInstance.parseHTML(html2, documentContext) || [];
|
|
991
|
+
} else {
|
|
992
|
+
var elems = jQueryInstance.clean([html2], documentContext);
|
|
993
|
+
if (elems && elems[0]) {
|
|
994
|
+
var elem = elems[0];
|
|
995
|
+
while (elem.parentNode && elem.parentNode.nodeType !== 11) {
|
|
996
|
+
elem = elem.parentNode;
|
|
997
|
+
}
|
|
998
|
+
if (elem.parentNode) {
|
|
999
|
+
elem.parentNode.removeChild(elem);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return elems;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
function parseHtmlFragment(html2, documentContext) {
|
|
1006
|
+
return supportsTemplateTag ? templateHtmlParse(html2, documentContext) : jQueryInstance ? jQueryHtmlParse(html2, documentContext) : simpleHtmlParse(html2, documentContext);
|
|
1007
|
+
}
|
|
1008
|
+
function setHtml(node, html2) {
|
|
1009
|
+
emptyDomNode(node);
|
|
1010
|
+
if (typeof html2 === "function") {
|
|
1011
|
+
html2 = html2();
|
|
1012
|
+
}
|
|
1013
|
+
if (html2 !== null && html2 !== void 0) {
|
|
1014
|
+
if (typeof html2 !== "string") {
|
|
1015
|
+
html2 = html2.toString();
|
|
1016
|
+
}
|
|
1017
|
+
if (jQueryInstance && !supportsTemplateTag) {
|
|
1018
|
+
jQueryInstance(node).html(html2);
|
|
1019
|
+
} else {
|
|
1020
|
+
var parsedNodes = parseHtmlFragment(html2, node.ownerDocument);
|
|
1021
|
+
if (node.nodeType === 8) {
|
|
1022
|
+
if (html2 === null) {
|
|
1023
|
+
emptyNode(node);
|
|
1024
|
+
} else {
|
|
1025
|
+
setDomNodeChildren2(node, parsedNodes);
|
|
1026
|
+
}
|
|
1027
|
+
} else {
|
|
1028
|
+
for (var i = 0; i < parsedNodes.length; i++) {
|
|
1029
|
+
node.appendChild(parsedNodes[i]);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
function setTextContent(element, textContent) {
|
|
1036
|
+
var value2 = typeof textContent === "function" ? textContent() : textContent;
|
|
1037
|
+
if (value2 === null || value2 === void 0) {
|
|
1038
|
+
value2 = "";
|
|
1039
|
+
}
|
|
1040
|
+
var innerTextNode = firstChild(element);
|
|
1041
|
+
if (!innerTextNode || innerTextNode.nodeType != 3 || nextSibling(innerTextNode)) {
|
|
1042
|
+
setDomNodeChildren2(element, [element.ownerDocument.createTextNode(value2)]);
|
|
1043
|
+
} else {
|
|
1044
|
+
innerTextNode.data = value2;
|
|
1045
|
+
}
|
|
1046
|
+
forceRefresh(element);
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
// ../utils/dist/dom/selectExtensions.js
|
|
1050
|
+
var hasDomDataExpandoProperty = Symbol("Knockout selectExtensions hasDomDataProperty");
|
|
1051
|
+
var selectExtensions = {
|
|
1052
|
+
optionValueDomDataKey: nextKey(),
|
|
1053
|
+
readValue: function(element) {
|
|
1054
|
+
switch (tagNameLower(element)) {
|
|
1055
|
+
case "option":
|
|
1056
|
+
if (element[hasDomDataExpandoProperty] === true) {
|
|
1057
|
+
return get(element, selectExtensions.optionValueDomDataKey);
|
|
1058
|
+
}
|
|
1059
|
+
return element.value;
|
|
1060
|
+
case "select":
|
|
1061
|
+
return element.selectedIndex >= 0 ? selectExtensions.readValue(element.options[element.selectedIndex]) : void 0;
|
|
1062
|
+
default:
|
|
1063
|
+
return element.value;
|
|
1064
|
+
}
|
|
1065
|
+
},
|
|
1066
|
+
writeValue: function(element, value2, allowUnset) {
|
|
1067
|
+
switch (tagNameLower(element)) {
|
|
1068
|
+
case "option":
|
|
1069
|
+
if (typeof value2 === "string") {
|
|
1070
|
+
set(element, selectExtensions.optionValueDomDataKey, void 0);
|
|
1071
|
+
if (hasDomDataExpandoProperty in element) {
|
|
1072
|
+
delete element[hasDomDataExpandoProperty];
|
|
1073
|
+
}
|
|
1074
|
+
element.value = value2;
|
|
1075
|
+
} else {
|
|
1076
|
+
set(element, selectExtensions.optionValueDomDataKey, value2);
|
|
1077
|
+
element[hasDomDataExpandoProperty] = true;
|
|
1078
|
+
element.value = typeof value2 === "number" ? value2 : "";
|
|
1079
|
+
}
|
|
1080
|
+
break;
|
|
1081
|
+
case "select":
|
|
1082
|
+
if (value2 === "" || value2 === null) {
|
|
1083
|
+
value2 = void 0;
|
|
1084
|
+
}
|
|
1085
|
+
var selection = -1;
|
|
1086
|
+
for (let i = 0, n = element.options.length, optionValue; i < n; ++i) {
|
|
1087
|
+
optionValue = selectExtensions.readValue(element.options[i]);
|
|
1088
|
+
const strictEqual = optionValue === value2;
|
|
1089
|
+
const blankEqual = optionValue === "" && value2 === void 0;
|
|
1090
|
+
const numericEqual = typeof value2 === "number" && Number(optionValue) === value2;
|
|
1091
|
+
if (strictEqual || blankEqual || numericEqual) {
|
|
1092
|
+
selection = i;
|
|
1093
|
+
break;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
if (allowUnset || selection >= 0 || value2 === void 0 && element.size > 1) {
|
|
1097
|
+
element.selectedIndex = selection;
|
|
1098
|
+
}
|
|
1099
|
+
break;
|
|
1100
|
+
default:
|
|
1101
|
+
if (value2 === null || value2 === void 0) {
|
|
1102
|
+
value2 = "";
|
|
1103
|
+
}
|
|
1104
|
+
element.value = value2;
|
|
1105
|
+
break;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
// ../utils/dist/tasks.js
|
|
1111
|
+
var tasks_exports = {};
|
|
1112
|
+
__export(tasks_exports, {
|
|
1113
|
+
cancel: () => cancel,
|
|
1114
|
+
resetForTesting: () => resetForTesting,
|
|
1115
|
+
runEarly: () => processTasks,
|
|
1116
|
+
schedule: () => schedule
|
|
1117
|
+
});
|
|
1118
|
+
var taskQueue = [];
|
|
1119
|
+
var taskQueueLength = 0;
|
|
1120
|
+
var nextHandle = 1;
|
|
1121
|
+
var nextIndexToProcess = 0;
|
|
1122
|
+
var w = options_default.global;
|
|
1123
|
+
if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
|
|
1124
|
+
options_default.taskScheduler = function(callback) {
|
|
1125
|
+
var div = w.document.createElement("div");
|
|
1126
|
+
new w.MutationObserver(callback).observe(div, { attributes: true });
|
|
1127
|
+
return function() {
|
|
1128
|
+
div.classList.toggle("foo");
|
|
1129
|
+
};
|
|
1130
|
+
}(scheduledProcess);
|
|
1131
|
+
} else if (w && w.document && "onreadystatechange" in w.document.createElement("script")) {
|
|
1132
|
+
options_default.taskScheduler = function(callback) {
|
|
1133
|
+
var script = document.createElement("script");
|
|
1134
|
+
script.onreadystatechange = function() {
|
|
1135
|
+
script.onreadystatechange = null;
|
|
1136
|
+
document.documentElement.removeChild(script);
|
|
1137
|
+
script = null;
|
|
1138
|
+
callback();
|
|
1139
|
+
};
|
|
1140
|
+
document.documentElement.appendChild(script);
|
|
1141
|
+
};
|
|
1142
|
+
} else {
|
|
1143
|
+
options_default.taskScheduler = function(callback) {
|
|
1144
|
+
setTimeout(callback, 0);
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
function processTasks() {
|
|
1148
|
+
if (taskQueueLength) {
|
|
1149
|
+
var mark = taskQueueLength, countMarks = 0;
|
|
1150
|
+
for (var task; nextIndexToProcess < taskQueueLength; ) {
|
|
1151
|
+
if (task = taskQueue[nextIndexToProcess++]) {
|
|
1152
|
+
if (nextIndexToProcess > mark) {
|
|
1153
|
+
if (++countMarks >= 5e3) {
|
|
1154
|
+
nextIndexToProcess = taskQueueLength;
|
|
1155
|
+
deferError(Error("'Too much recursion' after processing " + countMarks + " task groups."));
|
|
1156
|
+
break;
|
|
1157
|
+
}
|
|
1158
|
+
mark = taskQueueLength;
|
|
1159
|
+
}
|
|
1160
|
+
try {
|
|
1161
|
+
task();
|
|
1162
|
+
} catch (ex) {
|
|
1163
|
+
deferError(ex);
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
function scheduledProcess() {
|
|
1170
|
+
processTasks();
|
|
1171
|
+
nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
|
|
1172
|
+
}
|
|
1173
|
+
function scheduleTaskProcessing() {
|
|
1174
|
+
options_default.taskScheduler(scheduledProcess);
|
|
1175
|
+
}
|
|
1176
|
+
function schedule(func) {
|
|
1177
|
+
if (!taskQueueLength) {
|
|
1178
|
+
scheduleTaskProcessing();
|
|
1179
|
+
}
|
|
1180
|
+
taskQueue[taskQueueLength++] = func;
|
|
1181
|
+
return nextHandle++;
|
|
1182
|
+
}
|
|
1183
|
+
function cancel(handle) {
|
|
1184
|
+
var index = handle - (nextHandle - taskQueueLength);
|
|
1185
|
+
if (index >= nextIndexToProcess && index < taskQueueLength) {
|
|
1186
|
+
taskQueue[index] = null;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
function resetForTesting() {
|
|
1190
|
+
var length = taskQueueLength - nextIndexToProcess;
|
|
1191
|
+
nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
|
|
1192
|
+
return length;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
// ../observable/dist/dependencyDetection.js
|
|
1196
|
+
var dependencyDetection_exports = {};
|
|
1197
|
+
__export(dependencyDetection_exports, {
|
|
1198
|
+
begin: () => begin,
|
|
1199
|
+
end: () => end,
|
|
1200
|
+
getDependencies: () => getDependencies,
|
|
1201
|
+
getDependenciesCount: () => getDependenciesCount,
|
|
1202
|
+
ignore: () => ignore,
|
|
1203
|
+
ignoreDependencies: () => ignore,
|
|
1204
|
+
isInitial: () => isInitial,
|
|
1205
|
+
registerDependency: () => registerDependency
|
|
1206
|
+
});
|
|
1207
|
+
|
|
1208
|
+
// ../observable/dist/subscribableSymbol.js
|
|
1209
|
+
var SUBSCRIBABLE_SYM = Symbol("Knockout Subscribable");
|
|
1210
|
+
function isSubscribable(instance) {
|
|
1211
|
+
return instance && instance[SUBSCRIBABLE_SYM] || false;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
// ../observable/dist/dependencyDetection.js
|
|
1215
|
+
var outerFrames = [];
|
|
1216
|
+
var currentFrame;
|
|
1217
|
+
var lastId = 0;
|
|
1218
|
+
function getId() {
|
|
1219
|
+
return ++lastId;
|
|
1220
|
+
}
|
|
1221
|
+
function begin(options3) {
|
|
1222
|
+
outerFrames.push(currentFrame);
|
|
1223
|
+
currentFrame = options3;
|
|
1224
|
+
}
|
|
1225
|
+
function end() {
|
|
1226
|
+
currentFrame = outerFrames.pop();
|
|
1227
|
+
}
|
|
1228
|
+
function registerDependency(subscribable2) {
|
|
1229
|
+
if (currentFrame) {
|
|
1230
|
+
if (!isSubscribable(subscribable2)) {
|
|
1231
|
+
throw new Error("Only subscribable things can act as dependencies");
|
|
1232
|
+
}
|
|
1233
|
+
currentFrame.callback.call(currentFrame.callbackTarget, subscribable2, subscribable2._id || (subscribable2._id = getId()));
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
function ignore(callback, callbackTarget, callbackArgs) {
|
|
1237
|
+
try {
|
|
1238
|
+
begin();
|
|
1239
|
+
return callback.apply(callbackTarget, callbackArgs || []);
|
|
1240
|
+
} finally {
|
|
1241
|
+
end();
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
function getDependenciesCount() {
|
|
1245
|
+
if (currentFrame) {
|
|
1246
|
+
return currentFrame.computed.getDependenciesCount();
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
function getDependencies() {
|
|
1250
|
+
if (currentFrame) {
|
|
1251
|
+
return currentFrame.computed.getDependencies();
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
function isInitial() {
|
|
1255
|
+
if (currentFrame) {
|
|
1256
|
+
return currentFrame.isInitial;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
// ../observable/dist/defer.js
|
|
1261
|
+
function deferUpdates(target) {
|
|
1262
|
+
if (target._deferUpdates) {
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
target._deferUpdates = true;
|
|
1266
|
+
target.limit(function(callback) {
|
|
1267
|
+
let handle;
|
|
1268
|
+
let ignoreUpdates = false;
|
|
1269
|
+
return function() {
|
|
1270
|
+
if (!ignoreUpdates) {
|
|
1271
|
+
tasks_exports.cancel(handle);
|
|
1272
|
+
handle = tasks_exports.schedule(callback);
|
|
1273
|
+
try {
|
|
1274
|
+
ignoreUpdates = true;
|
|
1275
|
+
target.notifySubscribers(void 0, "dirty");
|
|
1276
|
+
} finally {
|
|
1277
|
+
ignoreUpdates = false;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
// ../observable/dist/Subscription.js
|
|
1285
|
+
var Subscription = class {
|
|
1286
|
+
constructor(target, observer, disposeCallback) {
|
|
1287
|
+
this._target = target;
|
|
1288
|
+
this._callback = observer.next;
|
|
1289
|
+
this._disposeCallback = disposeCallback;
|
|
1290
|
+
this._isDisposed = false;
|
|
1291
|
+
this._domNodeDisposalCallback = null;
|
|
1292
|
+
}
|
|
1293
|
+
dispose() {
|
|
1294
|
+
if (this._domNodeDisposalCallback) {
|
|
1295
|
+
removeDisposeCallback(this._node, this._domNodeDisposalCallback);
|
|
1296
|
+
}
|
|
1297
|
+
this._isDisposed = true;
|
|
1298
|
+
this._disposeCallback();
|
|
1299
|
+
}
|
|
1300
|
+
disposeWhenNodeIsRemoved(node) {
|
|
1301
|
+
this._node = node;
|
|
1302
|
+
addDisposeCallback(node, this._domNodeDisposalCallback = this.dispose.bind(this));
|
|
1303
|
+
}
|
|
1304
|
+
unsubscribe() {
|
|
1305
|
+
this.dispose();
|
|
1306
|
+
}
|
|
1307
|
+
get closed() {
|
|
1308
|
+
return this._isDisposed;
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
|
|
1312
|
+
// ../observable/dist/extenders.js
|
|
1313
|
+
var primitiveTypes = {
|
|
1314
|
+
"undefined": 1,
|
|
1315
|
+
"boolean": 1,
|
|
1316
|
+
"number": 1,
|
|
1317
|
+
"string": 1
|
|
1318
|
+
};
|
|
1319
|
+
function valuesArePrimitiveAndEqual(a, b) {
|
|
1320
|
+
var oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
|
|
1321
|
+
return oldValueIsPrimitive ? a === b : false;
|
|
1322
|
+
}
|
|
1323
|
+
function applyExtenders(requestedExtenders) {
|
|
1324
|
+
var target = this;
|
|
1325
|
+
if (requestedExtenders) {
|
|
1326
|
+
objectForEach(requestedExtenders, function(key, value2) {
|
|
1327
|
+
var extenderHandler = extenders[key];
|
|
1328
|
+
if (typeof extenderHandler === "function") {
|
|
1329
|
+
target = extenderHandler(target, value2) || target;
|
|
1330
|
+
} else {
|
|
1331
|
+
options_default.onError(new Error("Extender not found: " + key));
|
|
1332
|
+
}
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
return target;
|
|
1336
|
+
}
|
|
1337
|
+
function notify(target, notifyWhen) {
|
|
1338
|
+
target.equalityComparer = notifyWhen == "always" ? null : valuesArePrimitiveAndEqual;
|
|
1339
|
+
}
|
|
1340
|
+
function deferred(target, option) {
|
|
1341
|
+
if (option !== true) {
|
|
1342
|
+
throw new Error("The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled.");
|
|
1343
|
+
}
|
|
1344
|
+
deferUpdates(target);
|
|
1345
|
+
}
|
|
1346
|
+
function rateLimit(target, options22) {
|
|
1347
|
+
var timeout, method, limitFunction;
|
|
1348
|
+
if (typeof options22 === "number") {
|
|
1349
|
+
timeout = options22;
|
|
1350
|
+
} else {
|
|
1351
|
+
timeout = options22.timeout;
|
|
1352
|
+
method = options22.method;
|
|
1353
|
+
}
|
|
1354
|
+
target._deferUpdates = false;
|
|
1355
|
+
limitFunction = method === "notifyWhenChangesStop" ? debounce : throttle;
|
|
1356
|
+
target.limit(function(callback) {
|
|
1357
|
+
return limitFunction(callback, timeout);
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
var extenders = {
|
|
1361
|
+
notify,
|
|
1362
|
+
deferred,
|
|
1363
|
+
rateLimit
|
|
1364
|
+
};
|
|
1365
|
+
|
|
1366
|
+
// ../observable/dist/subscribable.js
|
|
1367
|
+
var LATEST_VALUE = Symbol("Knockout latest value");
|
|
1368
|
+
if (!Symbol.observable) {
|
|
1369
|
+
Symbol.observable = Symbol.for("@tko/Symbol.observable");
|
|
1370
|
+
}
|
|
1371
|
+
function subscribable() {
|
|
1372
|
+
Object.setPrototypeOf(this, ko_subscribable_fn);
|
|
1373
|
+
ko_subscribable_fn.init(this);
|
|
1374
|
+
}
|
|
1375
|
+
var defaultEvent = "change";
|
|
1376
|
+
var ko_subscribable_fn = {
|
|
1377
|
+
[SUBSCRIBABLE_SYM]: true,
|
|
1378
|
+
[Symbol.observable]() {
|
|
1379
|
+
return this;
|
|
1380
|
+
},
|
|
1381
|
+
init(instance) {
|
|
1382
|
+
instance._subscriptions = { change: [] };
|
|
1383
|
+
instance._versionNumber = 1;
|
|
1384
|
+
},
|
|
1385
|
+
subscribe(callback, callbackTarget, event) {
|
|
1386
|
+
const isTC39Callback = typeof callback === "object" && callback.next;
|
|
1387
|
+
event = event || defaultEvent;
|
|
1388
|
+
const observer = isTC39Callback ? callback : {
|
|
1389
|
+
next: callbackTarget ? callback.bind(callbackTarget) : callback
|
|
1390
|
+
};
|
|
1391
|
+
const subscriptionInstance = new Subscription(this, observer, () => {
|
|
1392
|
+
arrayRemoveItem(this._subscriptions[event], subscriptionInstance);
|
|
1393
|
+
if (this.afterSubscriptionRemove) {
|
|
1394
|
+
this.afterSubscriptionRemove(event);
|
|
1395
|
+
}
|
|
1396
|
+
});
|
|
1397
|
+
if (this.beforeSubscriptionAdd) {
|
|
1398
|
+
this.beforeSubscriptionAdd(event);
|
|
1399
|
+
}
|
|
1400
|
+
if (!this._subscriptions[event]) {
|
|
1401
|
+
this._subscriptions[event] = [];
|
|
1402
|
+
}
|
|
1403
|
+
this._subscriptions[event].push(subscriptionInstance);
|
|
1404
|
+
if (isTC39Callback && LATEST_VALUE in this) {
|
|
1405
|
+
observer.next(this[LATEST_VALUE]);
|
|
1406
|
+
}
|
|
1407
|
+
return subscriptionInstance;
|
|
1408
|
+
},
|
|
1409
|
+
notifySubscribers(valueToNotify, event) {
|
|
1410
|
+
event = event || defaultEvent;
|
|
1411
|
+
if (event === defaultEvent) {
|
|
1412
|
+
this.updateVersion();
|
|
1413
|
+
}
|
|
1414
|
+
if (this.hasSubscriptionsForEvent(event)) {
|
|
1415
|
+
const subs = event === defaultEvent && this._changeSubscriptions || [...this._subscriptions[event]];
|
|
1416
|
+
try {
|
|
1417
|
+
begin();
|
|
1418
|
+
for (let i = 0, subscriptionInstance; subscriptionInstance = subs[i]; ++i) {
|
|
1419
|
+
if (!subscriptionInstance._isDisposed) {
|
|
1420
|
+
subscriptionInstance._callback(valueToNotify);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
} finally {
|
|
1424
|
+
end();
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
},
|
|
1428
|
+
getVersion() {
|
|
1429
|
+
return this._versionNumber;
|
|
1430
|
+
},
|
|
1431
|
+
hasChanged(versionToCheck) {
|
|
1432
|
+
return this.getVersion() !== versionToCheck;
|
|
1433
|
+
},
|
|
1434
|
+
updateVersion() {
|
|
1435
|
+
++this._versionNumber;
|
|
1436
|
+
},
|
|
1437
|
+
hasSubscriptionsForEvent(event) {
|
|
1438
|
+
return this._subscriptions[event] && this._subscriptions[event].length;
|
|
1439
|
+
},
|
|
1440
|
+
getSubscriptionsCount(event) {
|
|
1441
|
+
if (event) {
|
|
1442
|
+
return this._subscriptions[event] && this._subscriptions[event].length || 0;
|
|
1443
|
+
} else {
|
|
1444
|
+
var total = 0;
|
|
1445
|
+
objectForEach(this._subscriptions, function(eventName, subscriptions) {
|
|
1446
|
+
if (eventName !== "dirty") {
|
|
1447
|
+
total += subscriptions.length;
|
|
1448
|
+
}
|
|
1449
|
+
});
|
|
1450
|
+
return total;
|
|
1451
|
+
}
|
|
1452
|
+
},
|
|
1453
|
+
isDifferent(oldValue, newValue) {
|
|
1454
|
+
return !this.equalityComparer || !this.equalityComparer(oldValue, newValue);
|
|
1455
|
+
},
|
|
1456
|
+
once(cb) {
|
|
1457
|
+
const subs = this.subscribe((nv) => {
|
|
1458
|
+
subs.dispose();
|
|
1459
|
+
cb(nv);
|
|
1460
|
+
});
|
|
1461
|
+
},
|
|
1462
|
+
when(test, returnValue) {
|
|
1463
|
+
const current = this.peek();
|
|
1464
|
+
const givenRv = arguments.length > 1;
|
|
1465
|
+
const testFn = typeof test === "function" ? test : (v) => v === test;
|
|
1466
|
+
if (testFn(current)) {
|
|
1467
|
+
return options_default.Promise.resolve(givenRv ? returnValue : current);
|
|
1468
|
+
}
|
|
1469
|
+
return new options_default.Promise((resolve, reject) => {
|
|
1470
|
+
const subs = this.subscribe((newValue) => {
|
|
1471
|
+
if (testFn(newValue)) {
|
|
1472
|
+
subs.dispose();
|
|
1473
|
+
resolve(givenRv ? returnValue : newValue);
|
|
1474
|
+
}
|
|
1475
|
+
});
|
|
1476
|
+
});
|
|
1477
|
+
},
|
|
1478
|
+
yet(test, ...args) {
|
|
1479
|
+
const testFn = typeof test === "function" ? test : (v) => v === test;
|
|
1480
|
+
const negated = (v) => !testFn(v);
|
|
1481
|
+
return this.when(negated, ...args);
|
|
1482
|
+
},
|
|
1483
|
+
next() {
|
|
1484
|
+
return new Promise((resolve) => this.once(resolve));
|
|
1485
|
+
},
|
|
1486
|
+
toString() {
|
|
1487
|
+
return "[object Object]";
|
|
1488
|
+
},
|
|
1489
|
+
extend: applyExtenders
|
|
1490
|
+
};
|
|
1491
|
+
Object.setPrototypeOf(ko_subscribable_fn, Function.prototype);
|
|
1492
|
+
subscribable.fn = ko_subscribable_fn;
|
|
1493
|
+
|
|
1494
|
+
// ../observable/dist/observable.js
|
|
1495
|
+
function observable(initialValue) {
|
|
1496
|
+
function Observable() {
|
|
1497
|
+
if (arguments.length > 0) {
|
|
1498
|
+
if (Observable.isDifferent(Observable[LATEST_VALUE], arguments[0])) {
|
|
1499
|
+
Observable.valueWillMutate();
|
|
1500
|
+
Observable[LATEST_VALUE] = arguments[0];
|
|
1501
|
+
Observable.valueHasMutated();
|
|
1502
|
+
}
|
|
1503
|
+
return this;
|
|
1504
|
+
} else {
|
|
1505
|
+
registerDependency(Observable);
|
|
1506
|
+
return Observable[LATEST_VALUE];
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
overwriteLengthPropertyIfSupported(Observable, { value: void 0 });
|
|
1510
|
+
Observable[LATEST_VALUE] = initialValue;
|
|
1511
|
+
subscribable.fn.init(Observable);
|
|
1512
|
+
Object.setPrototypeOf(Observable, observable.fn);
|
|
1513
|
+
if (options_default.deferUpdates) {
|
|
1514
|
+
deferUpdates(Observable);
|
|
1515
|
+
}
|
|
1516
|
+
return Observable;
|
|
1517
|
+
}
|
|
1518
|
+
observable.fn = {
|
|
1519
|
+
equalityComparer: valuesArePrimitiveAndEqual,
|
|
1520
|
+
peek() {
|
|
1521
|
+
return this[LATEST_VALUE];
|
|
1522
|
+
},
|
|
1523
|
+
valueHasMutated() {
|
|
1524
|
+
this.notifySubscribers(this[LATEST_VALUE], "spectate");
|
|
1525
|
+
this.notifySubscribers(this[LATEST_VALUE]);
|
|
1526
|
+
},
|
|
1527
|
+
valueWillMutate() {
|
|
1528
|
+
this.notifySubscribers(this[LATEST_VALUE], "beforeChange");
|
|
1529
|
+
},
|
|
1530
|
+
modify(fn, peek22 = true) {
|
|
1531
|
+
return this(fn(peek22 ? this.peek() : this()));
|
|
1532
|
+
},
|
|
1533
|
+
isWriteable: true
|
|
1534
|
+
};
|
|
1535
|
+
function limitNotifySubscribers(value2, event) {
|
|
1536
|
+
if (!event || event === defaultEvent) {
|
|
1537
|
+
this._limitChange(value2);
|
|
1538
|
+
} else if (event === "beforeChange") {
|
|
1539
|
+
this._limitBeforeChange(value2);
|
|
1540
|
+
} else {
|
|
1541
|
+
this._origNotifySubscribers(value2, event);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
subscribable.fn.limit = function limit(limitFunction) {
|
|
1545
|
+
var self = this;
|
|
1546
|
+
var selfIsObservable = isObservable(self);
|
|
1547
|
+
var beforeChange = "beforeChange";
|
|
1548
|
+
var ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
|
|
1549
|
+
if (!self._origNotifySubscribers) {
|
|
1550
|
+
self._origNotifySubscribers = self.notifySubscribers;
|
|
1551
|
+
self.notifySubscribers = limitNotifySubscribers;
|
|
1552
|
+
}
|
|
1553
|
+
var finish = limitFunction(function() {
|
|
1554
|
+
self._notificationIsPending = false;
|
|
1555
|
+
if (selfIsObservable && pendingValue === self) {
|
|
1556
|
+
pendingValue = self._evalIfChanged ? self._evalIfChanged() : self();
|
|
1557
|
+
}
|
|
1558
|
+
const shouldNotify = notifyNextChange || didUpdate && self.isDifferent(previousValue, pendingValue);
|
|
1559
|
+
self._notifyNextChange = didUpdate = ignoreBeforeChange = false;
|
|
1560
|
+
if (shouldNotify) {
|
|
1561
|
+
self._origNotifySubscribers(previousValue = pendingValue);
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
Object.assign(self, {
|
|
1565
|
+
_limitChange(value2, isDirty) {
|
|
1566
|
+
if (!isDirty || !self._notificationIsPending) {
|
|
1567
|
+
didUpdate = !isDirty;
|
|
1568
|
+
}
|
|
1569
|
+
self._changeSubscriptions = [...self._subscriptions[defaultEvent]];
|
|
1570
|
+
self._notificationIsPending = ignoreBeforeChange = true;
|
|
1571
|
+
pendingValue = value2;
|
|
1572
|
+
finish();
|
|
1573
|
+
},
|
|
1574
|
+
_limitBeforeChange(value2) {
|
|
1575
|
+
if (!ignoreBeforeChange) {
|
|
1576
|
+
previousValue = value2;
|
|
1577
|
+
self._origNotifySubscribers(value2, beforeChange);
|
|
1578
|
+
}
|
|
1579
|
+
},
|
|
1580
|
+
_notifyNextChangeIfValueIsDifferent() {
|
|
1581
|
+
if (self.isDifferent(previousValue, self.peek(true))) {
|
|
1582
|
+
notifyNextChange = true;
|
|
1583
|
+
}
|
|
1584
|
+
},
|
|
1585
|
+
_recordUpdate() {
|
|
1586
|
+
didUpdate = true;
|
|
1587
|
+
}
|
|
1588
|
+
});
|
|
1589
|
+
};
|
|
1590
|
+
Object.setPrototypeOf(observable.fn, subscribable.fn);
|
|
1591
|
+
var protoProperty = observable.protoProperty = options_default.protoProperty;
|
|
1592
|
+
observable.fn[protoProperty] = observable;
|
|
1593
|
+
observable.observablePrototypes = /* @__PURE__ */ new Set([observable]);
|
|
1594
|
+
function isObservable(instance) {
|
|
1595
|
+
const proto = typeof instance === "function" && instance[protoProperty];
|
|
1596
|
+
if (proto && !observable.observablePrototypes.has(proto)) {
|
|
1597
|
+
throw Error("Invalid object that looks like an observable; possibly from another Knockout instance");
|
|
1598
|
+
}
|
|
1599
|
+
return !!proto;
|
|
1600
|
+
}
|
|
1601
|
+
function unwrap(value2) {
|
|
1602
|
+
return isObservable(value2) ? value2() : value2;
|
|
1603
|
+
}
|
|
1604
|
+
function isWriteableObservable(instance) {
|
|
1605
|
+
return isObservable(instance) && instance.isWriteable;
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
// ../observable/dist/observableArray.changeTracking.js
|
|
1609
|
+
var arrayChangeEventName = "arrayChange";
|
|
1610
|
+
function trackArrayChanges(target, options3) {
|
|
1611
|
+
target.compareArrayOptions = {};
|
|
1612
|
+
if (options3 && typeof options3 === "object") {
|
|
1613
|
+
extend(target.compareArrayOptions, options3);
|
|
1614
|
+
}
|
|
1615
|
+
target.compareArrayOptions.sparse = true;
|
|
1616
|
+
if (target.cacheDiffForKnownOperation) {
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
let trackingChanges = false;
|
|
1620
|
+
let cachedDiff = null;
|
|
1621
|
+
let arrayChangeSubscription;
|
|
1622
|
+
let pendingNotifications = 0;
|
|
1623
|
+
let underlyingNotifySubscribersFunction;
|
|
1624
|
+
let underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
|
|
1625
|
+
let underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
|
|
1626
|
+
target.beforeSubscriptionAdd = function(event) {
|
|
1627
|
+
if (underlyingBeforeSubscriptionAddFunction) {
|
|
1628
|
+
underlyingBeforeSubscriptionAddFunction.call(target, event);
|
|
1629
|
+
}
|
|
1630
|
+
if (event === arrayChangeEventName) {
|
|
1631
|
+
trackChanges();
|
|
1632
|
+
}
|
|
1633
|
+
};
|
|
1634
|
+
target.afterSubscriptionRemove = function(event) {
|
|
1635
|
+
if (underlyingAfterSubscriptionRemoveFunction) {
|
|
1636
|
+
underlyingAfterSubscriptionRemoveFunction.call(target, event);
|
|
1637
|
+
}
|
|
1638
|
+
if (event === arrayChangeEventName && !target.hasSubscriptionsForEvent(arrayChangeEventName)) {
|
|
1639
|
+
if (underlyingNotifySubscribersFunction) {
|
|
1640
|
+
target.notifySubscribers = underlyingNotifySubscribersFunction;
|
|
1641
|
+
underlyingNotifySubscribersFunction = void 0;
|
|
1642
|
+
}
|
|
1643
|
+
if (arrayChangeSubscription) {
|
|
1644
|
+
arrayChangeSubscription.dispose();
|
|
1645
|
+
}
|
|
1646
|
+
arrayChangeSubscription = null;
|
|
1647
|
+
trackingChanges = false;
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1650
|
+
function trackChanges() {
|
|
1651
|
+
if (trackingChanges) {
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1654
|
+
trackingChanges = true;
|
|
1655
|
+
underlyingNotifySubscribersFunction = target["notifySubscribers"];
|
|
1656
|
+
target.notifySubscribers = function(valueToNotify, event) {
|
|
1657
|
+
if (!event || event === defaultEvent) {
|
|
1658
|
+
++pendingNotifications;
|
|
1659
|
+
}
|
|
1660
|
+
return underlyingNotifySubscribersFunction.apply(this, arguments);
|
|
1661
|
+
};
|
|
1662
|
+
var previousContents = [].concat(target.peek() === void 0 ? [] : target.peek());
|
|
1663
|
+
cachedDiff = null;
|
|
1664
|
+
arrayChangeSubscription = target.subscribe(function(currentContents) {
|
|
1665
|
+
let changes;
|
|
1666
|
+
currentContents = [].concat(currentContents || []);
|
|
1667
|
+
if (target.hasSubscriptionsForEvent(arrayChangeEventName)) {
|
|
1668
|
+
changes = getChanges(previousContents, currentContents);
|
|
1669
|
+
}
|
|
1670
|
+
previousContents = currentContents;
|
|
1671
|
+
cachedDiff = null;
|
|
1672
|
+
pendingNotifications = 0;
|
|
1673
|
+
if (changes && changes.length) {
|
|
1674
|
+
target.notifySubscribers(changes, arrayChangeEventName);
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
function getChanges(previousContents, currentContents) {
|
|
1679
|
+
if (!cachedDiff || pendingNotifications > 1) {
|
|
1680
|
+
cachedDiff = trackArrayChanges.compareArrays(previousContents, currentContents, target.compareArrayOptions);
|
|
1681
|
+
}
|
|
1682
|
+
return cachedDiff;
|
|
1683
|
+
}
|
|
1684
|
+
target.cacheDiffForKnownOperation = function(rawArray, operationName, args) {
|
|
1685
|
+
if (!trackingChanges || pendingNotifications) {
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
var diff = [], arrayLength = rawArray.length, argsLength = args.length, offset = 0;
|
|
1689
|
+
function pushDiff(status, value2, index) {
|
|
1690
|
+
return diff[diff.length] = { "status": status, "value": value2, "index": index };
|
|
1691
|
+
}
|
|
1692
|
+
switch (operationName) {
|
|
1693
|
+
case "push":
|
|
1694
|
+
offset = arrayLength;
|
|
1695
|
+
case "unshift":
|
|
1696
|
+
for (let index = 0; index < argsLength; index++) {
|
|
1697
|
+
pushDiff("added", args[index], offset + index);
|
|
1698
|
+
}
|
|
1699
|
+
break;
|
|
1700
|
+
case "pop":
|
|
1701
|
+
offset = arrayLength - 1;
|
|
1702
|
+
case "shift":
|
|
1703
|
+
if (arrayLength) {
|
|
1704
|
+
pushDiff("deleted", rawArray[offset], offset);
|
|
1705
|
+
}
|
|
1706
|
+
break;
|
|
1707
|
+
case "splice":
|
|
1708
|
+
var startIndex = Math.min(Math.max(0, args[0] < 0 ? arrayLength + args[0] : args[0]), arrayLength), endDeleteIndex = argsLength === 1 ? arrayLength : Math.min(startIndex + (args[1] || 0), arrayLength), endAddIndex = startIndex + argsLength - 2, endIndex = Math.max(endDeleteIndex, endAddIndex), additions = [], deletions = [];
|
|
1709
|
+
for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
|
|
1710
|
+
if (index < endDeleteIndex) {
|
|
1711
|
+
deletions.push(pushDiff("deleted", rawArray[index], index));
|
|
1712
|
+
}
|
|
1713
|
+
if (index < endAddIndex) {
|
|
1714
|
+
additions.push(pushDiff("added", args[argsIndex], index));
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
findMovesInArrayComparison(deletions, additions);
|
|
1718
|
+
break;
|
|
1719
|
+
default:
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
cachedDiff = diff;
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
trackArrayChanges.compareArrays = compareArrays;
|
|
1726
|
+
extenders.trackArrayChanges = trackArrayChanges;
|
|
1727
|
+
|
|
1728
|
+
// ../observable/dist/observableArray.js
|
|
1729
|
+
function observableArray(initialValues) {
|
|
1730
|
+
initialValues = initialValues || [];
|
|
1731
|
+
if (typeof initialValues !== "object" || !("length" in initialValues)) {
|
|
1732
|
+
throw new Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");
|
|
1733
|
+
}
|
|
1734
|
+
var result = observable(initialValues);
|
|
1735
|
+
Object.setPrototypeOf(result, observableArray.fn);
|
|
1736
|
+
trackArrayChanges(result);
|
|
1737
|
+
overwriteLengthPropertyIfSupported(result, { get: () => result().length });
|
|
1738
|
+
return result;
|
|
1739
|
+
}
|
|
1740
|
+
observableArray.fn = {
|
|
1741
|
+
remove(valueOrPredicate) {
|
|
1742
|
+
var underlyingArray = this.peek();
|
|
1743
|
+
var removedValues = [];
|
|
1744
|
+
var predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value22) {
|
|
1745
|
+
return value22 === valueOrPredicate;
|
|
1746
|
+
};
|
|
1747
|
+
for (var i = 0; i < underlyingArray.length; i++) {
|
|
1748
|
+
var value2 = underlyingArray[i];
|
|
1749
|
+
if (predicate(value2)) {
|
|
1750
|
+
if (removedValues.length === 0) {
|
|
1751
|
+
this.valueWillMutate();
|
|
1752
|
+
}
|
|
1753
|
+
if (underlyingArray[i] !== value2) {
|
|
1754
|
+
throw Error("Array modified during remove; cannot remove item");
|
|
1755
|
+
}
|
|
1756
|
+
removedValues.push(value2);
|
|
1757
|
+
underlyingArray.splice(i, 1);
|
|
1758
|
+
i--;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
if (removedValues.length) {
|
|
1762
|
+
this.valueHasMutated();
|
|
1763
|
+
}
|
|
1764
|
+
return removedValues;
|
|
1765
|
+
},
|
|
1766
|
+
removeAll(arrayOfValues) {
|
|
1767
|
+
if (arrayOfValues === void 0) {
|
|
1768
|
+
var underlyingArray = this.peek();
|
|
1769
|
+
var allValues = underlyingArray.slice(0);
|
|
1770
|
+
this.valueWillMutate();
|
|
1771
|
+
underlyingArray.splice(0, underlyingArray.length);
|
|
1772
|
+
this.valueHasMutated();
|
|
1773
|
+
return allValues;
|
|
1774
|
+
}
|
|
1775
|
+
if (!arrayOfValues) {
|
|
1776
|
+
return [];
|
|
1777
|
+
}
|
|
1778
|
+
return this["remove"](function(value2) {
|
|
1779
|
+
return arrayIndexOf(arrayOfValues, value2) >= 0;
|
|
1780
|
+
});
|
|
1781
|
+
},
|
|
1782
|
+
destroy(valueOrPredicate) {
|
|
1783
|
+
var underlyingArray = this.peek();
|
|
1784
|
+
var predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value22) {
|
|
1785
|
+
return value22 === valueOrPredicate;
|
|
1786
|
+
};
|
|
1787
|
+
this.valueWillMutate();
|
|
1788
|
+
for (var i = underlyingArray.length - 1; i >= 0; i--) {
|
|
1789
|
+
var value2 = underlyingArray[i];
|
|
1790
|
+
if (predicate(value2)) {
|
|
1791
|
+
value2["_destroy"] = true;
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
this.valueHasMutated();
|
|
1795
|
+
},
|
|
1796
|
+
destroyAll(arrayOfValues) {
|
|
1797
|
+
if (arrayOfValues === void 0) {
|
|
1798
|
+
return this.destroy(function() {
|
|
1799
|
+
return true;
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
if (!arrayOfValues) {
|
|
1803
|
+
return [];
|
|
1804
|
+
}
|
|
1805
|
+
return this.destroy(function(value2) {
|
|
1806
|
+
return arrayIndexOf(arrayOfValues, value2) >= 0;
|
|
1807
|
+
});
|
|
1808
|
+
},
|
|
1809
|
+
indexOf(item) {
|
|
1810
|
+
return arrayIndexOf(this(), item);
|
|
1811
|
+
},
|
|
1812
|
+
replace(oldItem, newItem) {
|
|
1813
|
+
var index = this.indexOf(oldItem);
|
|
1814
|
+
if (index >= 0) {
|
|
1815
|
+
this.valueWillMutate();
|
|
1816
|
+
this.peek()[index] = newItem;
|
|
1817
|
+
this.valueHasMutated();
|
|
1818
|
+
}
|
|
1819
|
+
},
|
|
1820
|
+
sorted(compareFn) {
|
|
1821
|
+
return [...this()].sort(compareFn);
|
|
1822
|
+
},
|
|
1823
|
+
reversed() {
|
|
1824
|
+
return [...this()].reverse();
|
|
1825
|
+
},
|
|
1826
|
+
[Symbol.iterator]: function* () {
|
|
1827
|
+
yield* this();
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
Object.setPrototypeOf(observableArray.fn, observable.fn);
|
|
1831
|
+
arrayForEach(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function(methodName) {
|
|
1832
|
+
observableArray.fn[methodName] = function() {
|
|
1833
|
+
var underlyingArray = this.peek();
|
|
1834
|
+
this.valueWillMutate();
|
|
1835
|
+
this.cacheDiffForKnownOperation(underlyingArray, methodName, arguments);
|
|
1836
|
+
var methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
|
|
1837
|
+
this.valueHasMutated();
|
|
1838
|
+
return methodCallResult === underlyingArray ? this : methodCallResult;
|
|
1839
|
+
};
|
|
1840
|
+
});
|
|
1841
|
+
arrayForEach(["slice"], function(methodName) {
|
|
1842
|
+
observableArray.fn[methodName] = function() {
|
|
1843
|
+
var underlyingArray = this();
|
|
1844
|
+
return underlyingArray[methodName].apply(underlyingArray, arguments);
|
|
1845
|
+
};
|
|
1846
|
+
});
|
|
1847
|
+
observableArray.trackArrayChanges = trackArrayChanges;
|
|
1848
|
+
|
|
1849
|
+
// src/attr.ts
|
|
1850
|
+
var attr = {
|
|
1851
|
+
update: function(element, valueAccessor, allBindings) {
|
|
1852
|
+
var value2 = unwrap(valueAccessor()) || {};
|
|
1853
|
+
objectForEach(value2, function(attrName, attrValue) {
|
|
1854
|
+
attrValue = unwrap(attrValue);
|
|
1855
|
+
var prefixLen = attrName.indexOf(":");
|
|
1856
|
+
var namespace = prefixLen > 0 && element.lookupNamespaceURI(attrName.substr(0, prefixLen));
|
|
1857
|
+
const toRemove = attrValue === false || attrValue === null || attrValue === void 0;
|
|
1858
|
+
if (toRemove) {
|
|
1859
|
+
if (namespace) {
|
|
1860
|
+
element.removeAttributeNS(namespace, attrName);
|
|
1861
|
+
} else {
|
|
1862
|
+
element.removeAttribute(attrName);
|
|
1863
|
+
}
|
|
1864
|
+
} else {
|
|
1865
|
+
attrValue = attrValue.toString();
|
|
1866
|
+
if (namespace) {
|
|
1867
|
+
element.setAttributeNS(namespace, attrName, attrValue);
|
|
1868
|
+
} else {
|
|
1869
|
+
element.setAttribute(attrName, attrValue);
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
if (attrName === "name") {
|
|
1873
|
+
setElementName(element, toRemove ? "" : attrValue);
|
|
1874
|
+
}
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
};
|
|
1878
|
+
|
|
1879
|
+
// ../computed/dist/computed.js
|
|
1880
|
+
var computedState = createSymbolOrString("_state");
|
|
1881
|
+
var DISPOSED_STATE = {
|
|
1882
|
+
dependencyTracking: null,
|
|
1883
|
+
dependenciesCount: 0,
|
|
1884
|
+
isDisposed: true,
|
|
1885
|
+
isStale: false,
|
|
1886
|
+
isDirty: false,
|
|
1887
|
+
isSleeping: false,
|
|
1888
|
+
disposeWhenNodeIsRemoved: null,
|
|
1889
|
+
readFunction: null,
|
|
1890
|
+
_options: null
|
|
1891
|
+
};
|
|
1892
|
+
function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options22) {
|
|
1893
|
+
if (typeof evaluatorFunctionOrOptions === "object") {
|
|
1894
|
+
options22 = evaluatorFunctionOrOptions;
|
|
1895
|
+
} else {
|
|
1896
|
+
options22 = options22 || {};
|
|
1897
|
+
if (evaluatorFunctionOrOptions) {
|
|
1898
|
+
options22.read = evaluatorFunctionOrOptions;
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
if (typeof options22.read !== "function") {
|
|
1902
|
+
throw Error("Pass a function that returns the value of the computed");
|
|
1903
|
+
}
|
|
1904
|
+
var writeFunction = options22.write;
|
|
1905
|
+
var state = {
|
|
1906
|
+
latestValue: void 0,
|
|
1907
|
+
isStale: true,
|
|
1908
|
+
isDirty: true,
|
|
1909
|
+
isBeingEvaluated: false,
|
|
1910
|
+
suppressDisposalUntilDisposeWhenReturnsFalse: false,
|
|
1911
|
+
isDisposed: false,
|
|
1912
|
+
pure: false,
|
|
1913
|
+
isSleeping: false,
|
|
1914
|
+
readFunction: options22.read,
|
|
1915
|
+
evaluatorFunctionTarget: evaluatorFunctionTarget || options22.owner,
|
|
1916
|
+
disposeWhenNodeIsRemoved: options22.disposeWhenNodeIsRemoved || options22.disposeWhenNodeIsRemoved || null,
|
|
1917
|
+
disposeWhen: options22.disposeWhen || options22.disposeWhen,
|
|
1918
|
+
domNodeDisposalCallback: null,
|
|
1919
|
+
dependencyTracking: {},
|
|
1920
|
+
dependenciesCount: 0,
|
|
1921
|
+
evaluationTimeoutInstance: null
|
|
1922
|
+
};
|
|
1923
|
+
function computedObservable() {
|
|
1924
|
+
if (arguments.length > 0) {
|
|
1925
|
+
if (typeof writeFunction === "function") {
|
|
1926
|
+
writeFunction.apply(state.evaluatorFunctionTarget, arguments);
|
|
1927
|
+
} else {
|
|
1928
|
+
throw new Error("Cannot write a value to a computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");
|
|
1929
|
+
}
|
|
1930
|
+
return this;
|
|
1931
|
+
} else {
|
|
1932
|
+
if (!state.isDisposed) {
|
|
1933
|
+
dependencyDetection_exports.registerDependency(computedObservable);
|
|
1934
|
+
}
|
|
1935
|
+
if (state.isDirty || state.isSleeping && computedObservable.haveDependenciesChanged()) {
|
|
1936
|
+
computedObservable.evaluateImmediate();
|
|
1937
|
+
}
|
|
1938
|
+
return state.latestValue;
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
computedObservable[computedState] = state;
|
|
1942
|
+
computedObservable.isWriteable = typeof writeFunction === "function";
|
|
1943
|
+
subscribable.fn.init(computedObservable);
|
|
1944
|
+
Object.setPrototypeOf(computedObservable, computed.fn);
|
|
1945
|
+
if (options22.pure) {
|
|
1946
|
+
state.pure = true;
|
|
1947
|
+
state.isSleeping = true;
|
|
1948
|
+
extend(computedObservable, pureComputedOverrides);
|
|
1949
|
+
} else if (options22.deferEvaluation) {
|
|
1950
|
+
extend(computedObservable, deferEvaluationOverrides);
|
|
1951
|
+
}
|
|
1952
|
+
if (options_default.deferUpdates) {
|
|
1953
|
+
extenders.deferred(computedObservable, true);
|
|
1954
|
+
}
|
|
1955
|
+
if (options_default.debug) {
|
|
1956
|
+
computedObservable._options = options22;
|
|
1957
|
+
}
|
|
1958
|
+
if (state.disposeWhenNodeIsRemoved) {
|
|
1959
|
+
state.suppressDisposalUntilDisposeWhenReturnsFalse = true;
|
|
1960
|
+
if (!state.disposeWhenNodeIsRemoved.nodeType) {
|
|
1961
|
+
state.disposeWhenNodeIsRemoved = null;
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
if (!state.isSleeping && !options22.deferEvaluation) {
|
|
1965
|
+
computedObservable.evaluateImmediate();
|
|
1966
|
+
}
|
|
1967
|
+
if (state.disposeWhenNodeIsRemoved && computedObservable.isActive()) {
|
|
1968
|
+
addDisposeCallback(state.disposeWhenNodeIsRemoved, state.domNodeDisposalCallback = function() {
|
|
1969
|
+
computedObservable.dispose();
|
|
1970
|
+
});
|
|
1971
|
+
}
|
|
1972
|
+
return computedObservable;
|
|
1973
|
+
}
|
|
1974
|
+
function computedDisposeDependencyCallback(id, entryToDispose) {
|
|
1975
|
+
if (entryToDispose !== null && entryToDispose.dispose) {
|
|
1976
|
+
entryToDispose.dispose();
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
function computedBeginDependencyDetectionCallback(subscribable2, id) {
|
|
1980
|
+
var computedObservable = this.computedObservable, state = computedObservable[computedState];
|
|
1981
|
+
if (!state.isDisposed) {
|
|
1982
|
+
if (this.disposalCount && this.disposalCandidates[id]) {
|
|
1983
|
+
computedObservable.addDependencyTracking(id, subscribable2, this.disposalCandidates[id]);
|
|
1984
|
+
this.disposalCandidates[id] = null;
|
|
1985
|
+
--this.disposalCount;
|
|
1986
|
+
} else if (!state.dependencyTracking[id]) {
|
|
1987
|
+
computedObservable.addDependencyTracking(id, subscribable2, state.isSleeping ? { _target: subscribable2 } : computedObservable.subscribeToDependency(subscribable2));
|
|
1988
|
+
}
|
|
1989
|
+
if (subscribable2._notificationIsPending) {
|
|
1990
|
+
subscribable2._notifyNextChangeIfValueIsDifferent();
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
computed.fn = {
|
|
1995
|
+
equalityComparer: valuesArePrimitiveAndEqual,
|
|
1996
|
+
getDependenciesCount() {
|
|
1997
|
+
return this[computedState].dependenciesCount;
|
|
1998
|
+
},
|
|
1999
|
+
getDependencies() {
|
|
2000
|
+
const dependencyTracking = this[computedState].dependencyTracking;
|
|
2001
|
+
const dependentObservables = [];
|
|
2002
|
+
objectForEach(dependencyTracking, function(id, dependency) {
|
|
2003
|
+
dependentObservables[dependency._order] = dependency._target;
|
|
2004
|
+
});
|
|
2005
|
+
return dependentObservables;
|
|
2006
|
+
},
|
|
2007
|
+
addDependencyTracking(id, target, trackingObj) {
|
|
2008
|
+
if (this[computedState].pure && target === this) {
|
|
2009
|
+
throw Error("A 'pure' computed must not be called recursively");
|
|
2010
|
+
}
|
|
2011
|
+
this[computedState].dependencyTracking[id] = trackingObj;
|
|
2012
|
+
trackingObj._order = this[computedState].dependenciesCount++;
|
|
2013
|
+
trackingObj._version = target.getVersion();
|
|
2014
|
+
},
|
|
2015
|
+
haveDependenciesChanged() {
|
|
2016
|
+
var id, dependency, dependencyTracking = this[computedState].dependencyTracking;
|
|
2017
|
+
for (id in dependencyTracking) {
|
|
2018
|
+
if (hasOwnProperty(dependencyTracking, id)) {
|
|
2019
|
+
dependency = dependencyTracking[id];
|
|
2020
|
+
if (this._evalDelayed && dependency._target._notificationIsPending || dependency._target.hasChanged(dependency._version)) {
|
|
2021
|
+
return true;
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
},
|
|
2026
|
+
markDirty() {
|
|
2027
|
+
if (this._evalDelayed && !this[computedState].isBeingEvaluated) {
|
|
2028
|
+
this._evalDelayed(false);
|
|
2029
|
+
}
|
|
2030
|
+
},
|
|
2031
|
+
isActive() {
|
|
2032
|
+
const state = this[computedState];
|
|
2033
|
+
return state.isDirty || state.dependenciesCount > 0;
|
|
2034
|
+
},
|
|
2035
|
+
respondToChange() {
|
|
2036
|
+
if (!this._notificationIsPending) {
|
|
2037
|
+
this.evaluatePossiblyAsync();
|
|
2038
|
+
} else if (this[computedState].isDirty) {
|
|
2039
|
+
this[computedState].isStale = true;
|
|
2040
|
+
}
|
|
2041
|
+
},
|
|
2042
|
+
subscribeToDependency(target) {
|
|
2043
|
+
if (target._deferUpdates) {
|
|
2044
|
+
var dirtySub = target.subscribe(this.markDirty, this, "dirty"), changeSub = target.subscribe(this.respondToChange, this);
|
|
2045
|
+
return {
|
|
2046
|
+
_target: target,
|
|
2047
|
+
dispose() {
|
|
2048
|
+
dirtySub.dispose();
|
|
2049
|
+
changeSub.dispose();
|
|
2050
|
+
}
|
|
2051
|
+
};
|
|
2052
|
+
} else {
|
|
2053
|
+
return target.subscribe(this.evaluatePossiblyAsync, this);
|
|
2054
|
+
}
|
|
2055
|
+
},
|
|
2056
|
+
evaluatePossiblyAsync() {
|
|
2057
|
+
var computedObservable = this, throttleEvaluationTimeout = computedObservable.throttleEvaluation;
|
|
2058
|
+
if (throttleEvaluationTimeout && throttleEvaluationTimeout >= 0) {
|
|
2059
|
+
clearTimeout(this[computedState].evaluationTimeoutInstance);
|
|
2060
|
+
this[computedState].evaluationTimeoutInstance = safeSetTimeout(function() {
|
|
2061
|
+
computedObservable.evaluateImmediate(true);
|
|
2062
|
+
}, throttleEvaluationTimeout);
|
|
2063
|
+
} else if (computedObservable._evalDelayed) {
|
|
2064
|
+
computedObservable._evalDelayed(true);
|
|
2065
|
+
} else {
|
|
2066
|
+
computedObservable.evaluateImmediate(true);
|
|
2067
|
+
}
|
|
2068
|
+
},
|
|
2069
|
+
evaluateImmediate(notifyChange) {
|
|
2070
|
+
var computedObservable = this, state = computedObservable[computedState], disposeWhen = state.disposeWhen, changed = false;
|
|
2071
|
+
if (state.isBeingEvaluated) {
|
|
2072
|
+
return;
|
|
2073
|
+
}
|
|
2074
|
+
if (state.isDisposed) {
|
|
2075
|
+
return;
|
|
2076
|
+
}
|
|
2077
|
+
if (state.disposeWhenNodeIsRemoved && !domNodeIsAttachedToDocument(state.disposeWhenNodeIsRemoved) || disposeWhen && disposeWhen()) {
|
|
2078
|
+
if (!state.suppressDisposalUntilDisposeWhenReturnsFalse) {
|
|
2079
|
+
computedObservable.dispose();
|
|
2080
|
+
return;
|
|
2081
|
+
}
|
|
2082
|
+
} else {
|
|
2083
|
+
state.suppressDisposalUntilDisposeWhenReturnsFalse = false;
|
|
2084
|
+
}
|
|
2085
|
+
state.isBeingEvaluated = true;
|
|
2086
|
+
try {
|
|
2087
|
+
changed = this.evaluateImmediate_CallReadWithDependencyDetection(notifyChange);
|
|
2088
|
+
} finally {
|
|
2089
|
+
state.isBeingEvaluated = false;
|
|
2090
|
+
}
|
|
2091
|
+
return changed;
|
|
2092
|
+
},
|
|
2093
|
+
evaluateImmediate_CallReadWithDependencyDetection(notifyChange) {
|
|
2094
|
+
var computedObservable = this, state = computedObservable[computedState], changed = false;
|
|
2095
|
+
var isInitial2 = state.pure ? void 0 : !state.dependenciesCount, dependencyDetectionContext = {
|
|
2096
|
+
computedObservable,
|
|
2097
|
+
disposalCandidates: state.dependencyTracking,
|
|
2098
|
+
disposalCount: state.dependenciesCount
|
|
2099
|
+
};
|
|
2100
|
+
dependencyDetection_exports.begin({
|
|
2101
|
+
callbackTarget: dependencyDetectionContext,
|
|
2102
|
+
callback: computedBeginDependencyDetectionCallback,
|
|
2103
|
+
computed: computedObservable,
|
|
2104
|
+
isInitial: isInitial2
|
|
2105
|
+
});
|
|
2106
|
+
state.dependencyTracking = {};
|
|
2107
|
+
state.dependenciesCount = 0;
|
|
2108
|
+
var newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);
|
|
2109
|
+
if (!state.dependenciesCount) {
|
|
2110
|
+
computedObservable.dispose();
|
|
2111
|
+
changed = true;
|
|
2112
|
+
} else {
|
|
2113
|
+
changed = computedObservable.isDifferent(state.latestValue, newValue);
|
|
2114
|
+
}
|
|
2115
|
+
if (changed) {
|
|
2116
|
+
if (!state.isSleeping) {
|
|
2117
|
+
computedObservable.notifySubscribers(state.latestValue, "beforeChange");
|
|
2118
|
+
} else {
|
|
2119
|
+
computedObservable.updateVersion();
|
|
2120
|
+
}
|
|
2121
|
+
state.latestValue = newValue;
|
|
2122
|
+
if (options_default.debug) {
|
|
2123
|
+
computedObservable._latestValue = newValue;
|
|
2124
|
+
}
|
|
2125
|
+
computedObservable.notifySubscribers(state.latestValue, "spectate");
|
|
2126
|
+
if (!state.isSleeping && notifyChange) {
|
|
2127
|
+
computedObservable.notifySubscribers(state.latestValue);
|
|
2128
|
+
}
|
|
2129
|
+
if (computedObservable._recordUpdate) {
|
|
2130
|
+
computedObservable._recordUpdate();
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
if (isInitial2) {
|
|
2134
|
+
computedObservable.notifySubscribers(state.latestValue, "awake");
|
|
2135
|
+
}
|
|
2136
|
+
return changed;
|
|
2137
|
+
},
|
|
2138
|
+
evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext) {
|
|
2139
|
+
try {
|
|
2140
|
+
var readFunction = state.readFunction;
|
|
2141
|
+
return state.evaluatorFunctionTarget ? readFunction.call(state.evaluatorFunctionTarget) : readFunction();
|
|
2142
|
+
} finally {
|
|
2143
|
+
dependencyDetection_exports.end();
|
|
2144
|
+
if (dependencyDetectionContext.disposalCount && !state.isSleeping) {
|
|
2145
|
+
objectForEach(dependencyDetectionContext.disposalCandidates, computedDisposeDependencyCallback);
|
|
2146
|
+
}
|
|
2147
|
+
state.isStale = state.isDirty = false;
|
|
2148
|
+
}
|
|
2149
|
+
},
|
|
2150
|
+
peek(forceEvaluate) {
|
|
2151
|
+
const state = this[computedState];
|
|
2152
|
+
if (state.isDirty && (forceEvaluate || !state.dependenciesCount) || state.isSleeping && this.haveDependenciesChanged()) {
|
|
2153
|
+
this.evaluateImmediate();
|
|
2154
|
+
}
|
|
2155
|
+
return state.latestValue;
|
|
2156
|
+
},
|
|
2157
|
+
get [LATEST_VALUE]() {
|
|
2158
|
+
return this.peek();
|
|
2159
|
+
},
|
|
2160
|
+
limit(limitFunction) {
|
|
2161
|
+
const state = this[computedState];
|
|
2162
|
+
subscribable.fn.limit.call(this, limitFunction);
|
|
2163
|
+
Object.assign(this, {
|
|
2164
|
+
_evalIfChanged() {
|
|
2165
|
+
if (!this[computedState].isSleeping) {
|
|
2166
|
+
if (this[computedState].isStale) {
|
|
2167
|
+
this.evaluateImmediate();
|
|
2168
|
+
} else {
|
|
2169
|
+
this[computedState].isDirty = false;
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
return state.latestValue;
|
|
2173
|
+
},
|
|
2174
|
+
_evalDelayed(isChange) {
|
|
2175
|
+
this._limitBeforeChange(state.latestValue);
|
|
2176
|
+
state.isDirty = true;
|
|
2177
|
+
if (isChange) {
|
|
2178
|
+
state.isStale = true;
|
|
2179
|
+
}
|
|
2180
|
+
this._limitChange(this, !isChange);
|
|
2181
|
+
}
|
|
2182
|
+
});
|
|
2183
|
+
},
|
|
2184
|
+
dispose() {
|
|
2185
|
+
var state = this[computedState];
|
|
2186
|
+
if (!state.isSleeping && state.dependencyTracking) {
|
|
2187
|
+
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
2188
|
+
if (dependency.dispose) {
|
|
2189
|
+
dependency.dispose();
|
|
2190
|
+
}
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2193
|
+
if (state.disposeWhenNodeIsRemoved && state.domNodeDisposalCallback) {
|
|
2194
|
+
removeDisposeCallback(state.disposeWhenNodeIsRemoved, state.domNodeDisposalCallback);
|
|
2195
|
+
}
|
|
2196
|
+
Object.assign(state, DISPOSED_STATE);
|
|
2197
|
+
}
|
|
2198
|
+
};
|
|
2199
|
+
var pureComputedOverrides = {
|
|
2200
|
+
beforeSubscriptionAdd(event) {
|
|
2201
|
+
var computedObservable = this, state = computedObservable[computedState];
|
|
2202
|
+
if (!state.isDisposed && state.isSleeping && event === "change") {
|
|
2203
|
+
state.isSleeping = false;
|
|
2204
|
+
if (state.isStale || computedObservable.haveDependenciesChanged()) {
|
|
2205
|
+
state.dependencyTracking = null;
|
|
2206
|
+
state.dependenciesCount = 0;
|
|
2207
|
+
if (computedObservable.evaluateImmediate()) {
|
|
2208
|
+
computedObservable.updateVersion();
|
|
2209
|
+
}
|
|
2210
|
+
} else {
|
|
2211
|
+
var dependenciesOrder = [];
|
|
2212
|
+
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
2213
|
+
dependenciesOrder[dependency._order] = id;
|
|
2214
|
+
});
|
|
2215
|
+
arrayForEach(dependenciesOrder, function(id, order) {
|
|
2216
|
+
var dependency = state.dependencyTracking[id], subscription = computedObservable.subscribeToDependency(dependency._target);
|
|
2217
|
+
subscription._order = order;
|
|
2218
|
+
subscription._version = dependency._version;
|
|
2219
|
+
state.dependencyTracking[id] = subscription;
|
|
2220
|
+
});
|
|
2221
|
+
if (computedObservable.haveDependenciesChanged()) {
|
|
2222
|
+
if (computedObservable.evaluateImmediate()) {
|
|
2223
|
+
computedObservable.updateVersion();
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
if (!state.isDisposed) {
|
|
2228
|
+
computedObservable.notifySubscribers(state.latestValue, "awake");
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
},
|
|
2232
|
+
afterSubscriptionRemove(event) {
|
|
2233
|
+
var state = this[computedState];
|
|
2234
|
+
if (!state.isDisposed && event === "change" && !this.hasSubscriptionsForEvent("change")) {
|
|
2235
|
+
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
2236
|
+
if (dependency.dispose) {
|
|
2237
|
+
state.dependencyTracking[id] = {
|
|
2238
|
+
_target: dependency._target,
|
|
2239
|
+
_order: dependency._order,
|
|
2240
|
+
_version: dependency._version
|
|
2241
|
+
};
|
|
2242
|
+
dependency.dispose();
|
|
2243
|
+
}
|
|
2244
|
+
});
|
|
2245
|
+
state.isSleeping = true;
|
|
2246
|
+
this.notifySubscribers(void 0, "asleep");
|
|
2247
|
+
}
|
|
2248
|
+
},
|
|
2249
|
+
getVersion() {
|
|
2250
|
+
var state = this[computedState];
|
|
2251
|
+
if (state.isSleeping && (state.isStale || this.haveDependenciesChanged())) {
|
|
2252
|
+
this.evaluateImmediate();
|
|
2253
|
+
}
|
|
2254
|
+
return subscribable.fn.getVersion.call(this);
|
|
2255
|
+
}
|
|
2256
|
+
};
|
|
2257
|
+
var deferEvaluationOverrides = {
|
|
2258
|
+
beforeSubscriptionAdd(event) {
|
|
2259
|
+
if (event === "change" || event === "beforeChange") {
|
|
2260
|
+
this.peek();
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
};
|
|
2264
|
+
Object.setPrototypeOf(computed.fn, subscribable.fn);
|
|
2265
|
+
var protoProp = observable.protoProperty;
|
|
2266
|
+
computed.fn[protoProp] = computed;
|
|
2267
|
+
observable.observablePrototypes.add(computed);
|
|
2268
|
+
function pureComputed(evaluatorFunctionOrOptions, evaluatorFunctionTarget) {
|
|
2269
|
+
if (typeof evaluatorFunctionOrOptions === "function") {
|
|
2270
|
+
return computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, { "pure": true });
|
|
2271
|
+
} else {
|
|
2272
|
+
evaluatorFunctionOrOptions = extend({}, evaluatorFunctionOrOptions);
|
|
2273
|
+
evaluatorFunctionOrOptions.pure = true;
|
|
2274
|
+
return computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget);
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
// ../computed/dist/throttleExtender.js
|
|
2279
|
+
function throttleExtender(target, timeout) {
|
|
2280
|
+
target.throttleEvaluation = timeout;
|
|
2281
|
+
var writeTimeoutInstance = null;
|
|
2282
|
+
return computed({
|
|
2283
|
+
read: target,
|
|
2284
|
+
write: function(value2) {
|
|
2285
|
+
clearTimeout(writeTimeoutInstance);
|
|
2286
|
+
writeTimeoutInstance = setTimeout(function() {
|
|
2287
|
+
target(value2);
|
|
2288
|
+
}, timeout);
|
|
2289
|
+
}
|
|
2290
|
+
});
|
|
2291
|
+
}
|
|
2292
|
+
extenders.throttle = throttleExtender;
|
|
2293
|
+
|
|
2294
|
+
// ../computed/dist/proxy.js
|
|
2295
|
+
var PROXY_SYM = Symbol("Knockout Proxied Object");
|
|
2296
|
+
var MIRROR_SYM = Symbol("Knockout Proxied Observables");
|
|
2297
|
+
function makeComputed(proxy2, fn) {
|
|
2298
|
+
return computed({
|
|
2299
|
+
owner: proxy2,
|
|
2300
|
+
read: fn,
|
|
2301
|
+
write: fn,
|
|
2302
|
+
pure: "pure" in fn ? fn.pure : true,
|
|
2303
|
+
deferEvaluation: "deferEvaluation" in fn ? fn.deferEvaluation : true
|
|
2304
|
+
}).extend({ deferred: true });
|
|
2305
|
+
}
|
|
2306
|
+
function setOrCreate(mirror, prop, value2, proxy2) {
|
|
2307
|
+
if (!mirror[prop]) {
|
|
2308
|
+
const ctr = Array.isArray(value2) ? observableArray : typeof value2 === "function" ? makeComputed.bind(null, proxy2) : observable;
|
|
2309
|
+
mirror[prop] = ctr(value2);
|
|
2310
|
+
} else {
|
|
2311
|
+
mirror[prop](value2);
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
function assignOrUpdate(mirror, object2, proxy2) {
|
|
2315
|
+
for (const key of Object.keys(object2)) {
|
|
2316
|
+
setOrCreate(mirror, key, object2[key], proxy2);
|
|
2317
|
+
}
|
|
2318
|
+
return object2;
|
|
2319
|
+
}
|
|
2320
|
+
function proxy(object2) {
|
|
2321
|
+
const mirror = { [PROXY_SYM]: object2 };
|
|
2322
|
+
mirror[MIRROR_SYM] = mirror;
|
|
2323
|
+
const proxy2 = new Proxy(function() {
|
|
2324
|
+
}, {
|
|
2325
|
+
has(target, prop) {
|
|
2326
|
+
return prop in mirror;
|
|
2327
|
+
},
|
|
2328
|
+
get(target, prop) {
|
|
2329
|
+
return unwrap(mirror[prop]);
|
|
2330
|
+
},
|
|
2331
|
+
set(target, prop, value2, receiver) {
|
|
2332
|
+
setOrCreate(mirror, prop, value2, proxy2);
|
|
2333
|
+
object2[prop] = value2;
|
|
2334
|
+
return true;
|
|
2335
|
+
},
|
|
2336
|
+
deleteProperty(property) {
|
|
2337
|
+
delete mirror[property];
|
|
2338
|
+
return delete object2[property];
|
|
2339
|
+
},
|
|
2340
|
+
apply(target, thisArg, [props]) {
|
|
2341
|
+
if (props) {
|
|
2342
|
+
assignOrUpdate(mirror, props, proxy2);
|
|
2343
|
+
return Object.assign(object2, props);
|
|
2344
|
+
}
|
|
2345
|
+
return object2;
|
|
2346
|
+
},
|
|
2347
|
+
getPrototypeOf() {
|
|
2348
|
+
return Object.getPrototypeOf(object2);
|
|
2349
|
+
},
|
|
2350
|
+
setPrototypeOf(target, proto) {
|
|
2351
|
+
return Object.setPrototypeOf(object2, proto);
|
|
2352
|
+
},
|
|
2353
|
+
defineProperty(target, prop, desc) {
|
|
2354
|
+
return Object.defineProperty(object2, prop, desc);
|
|
2355
|
+
},
|
|
2356
|
+
preventExtensions() {
|
|
2357
|
+
return Object.preventExtensions(object2);
|
|
2358
|
+
},
|
|
2359
|
+
isExtensible() {
|
|
2360
|
+
return Object.isExtensible(object2);
|
|
2361
|
+
},
|
|
2362
|
+
ownKeys() {
|
|
2363
|
+
return [
|
|
2364
|
+
...Object.getOwnPropertyNames(object2),
|
|
2365
|
+
...Object.getOwnPropertySymbols(object2)
|
|
2366
|
+
];
|
|
2367
|
+
}
|
|
2368
|
+
});
|
|
2369
|
+
assignOrUpdate(mirror, object2, proxy2);
|
|
2370
|
+
return proxy2;
|
|
2371
|
+
}
|
|
2372
|
+
function getObservable(proxied, prop) {
|
|
2373
|
+
return proxied[MIRROR_SYM][prop];
|
|
2374
|
+
}
|
|
2375
|
+
function peek2(proxied, prop) {
|
|
2376
|
+
return getObservable(proxied, prop).peek();
|
|
2377
|
+
}
|
|
2378
|
+
function isProxied(proxied) {
|
|
2379
|
+
return PROXY_SYM in proxied;
|
|
2380
|
+
}
|
|
2381
|
+
Object.assign(proxy, { getObservable, peek: peek2, isProxied });
|
|
2382
|
+
|
|
2383
|
+
// src/checked.ts
|
|
2384
|
+
var checked = {
|
|
2385
|
+
after: ["value", "attr"],
|
|
2386
|
+
init: function(element, valueAccessor, allBindings) {
|
|
2387
|
+
var checkedValue2 = pureComputed(function() {
|
|
2388
|
+
if (allBindings.has("checkedValue")) {
|
|
2389
|
+
return unwrap(allBindings.get("checkedValue"));
|
|
2390
|
+
} else if (useElementValue) {
|
|
2391
|
+
if (allBindings.has("value")) {
|
|
2392
|
+
return unwrap(allBindings.get("value"));
|
|
2393
|
+
} else {
|
|
2394
|
+
return element.value;
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
});
|
|
2398
|
+
function updateModel() {
|
|
2399
|
+
var isChecked = element.checked, elemValue = checkedValue2();
|
|
2400
|
+
if (dependencyDetection_exports.isInitial()) {
|
|
2401
|
+
return;
|
|
2402
|
+
}
|
|
2403
|
+
if (!isChecked && (isRadio || dependencyDetection_exports.getDependenciesCount())) {
|
|
2404
|
+
return;
|
|
2405
|
+
}
|
|
2406
|
+
var modelValue = dependencyDetection_exports.ignore(valueAccessor);
|
|
2407
|
+
if (valueIsArray) {
|
|
2408
|
+
var writableValue = rawValueIsNonArrayObservable ? modelValue.peek() : modelValue, saveOldValue = oldElemValue;
|
|
2409
|
+
oldElemValue = elemValue;
|
|
2410
|
+
if (saveOldValue !== elemValue) {
|
|
2411
|
+
if (isChecked) {
|
|
2412
|
+
addOrRemoveItem(writableValue, elemValue, true);
|
|
2413
|
+
addOrRemoveItem(writableValue, saveOldValue, false);
|
|
2414
|
+
}
|
|
2415
|
+
oldElemValue = elemValue;
|
|
2416
|
+
} else {
|
|
2417
|
+
addOrRemoveItem(writableValue, elemValue, isChecked);
|
|
2418
|
+
}
|
|
2419
|
+
if (rawValueIsNonArrayObservable && isWriteableObservable(modelValue)) {
|
|
2420
|
+
modelValue(writableValue);
|
|
2421
|
+
}
|
|
2422
|
+
} else {
|
|
2423
|
+
if (isCheckbox) {
|
|
2424
|
+
if (elemValue === void 0) {
|
|
2425
|
+
elemValue = isChecked;
|
|
2426
|
+
} else if (!isChecked) {
|
|
2427
|
+
elemValue = void 0;
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
valueAccessor(elemValue, { onlyIfChanged: true });
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
;
|
|
2434
|
+
function updateView() {
|
|
2435
|
+
var modelValue = modelValue = unwrap(valueAccessor());
|
|
2436
|
+
var elemValue = checkedValue2();
|
|
2437
|
+
if (valueIsArray) {
|
|
2438
|
+
element.checked = arrayIndexOf(modelValue, elemValue) >= 0;
|
|
2439
|
+
oldElemValue = elemValue;
|
|
2440
|
+
} else if (isCheckbox && elemValue === void 0) {
|
|
2441
|
+
element.checked = !!modelValue;
|
|
2442
|
+
} else {
|
|
2443
|
+
element.checked = checkedValue2() === modelValue;
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
;
|
|
2447
|
+
var isCheckbox = element.type == "checkbox", isRadio = element.type == "radio";
|
|
2448
|
+
if (!isCheckbox && !isRadio) {
|
|
2449
|
+
return;
|
|
2450
|
+
}
|
|
2451
|
+
var rawValue = valueAccessor(), valueIsArray = isCheckbox && unwrap(rawValue) instanceof Array, rawValueIsNonArrayObservable = !(valueIsArray && rawValue.push && rawValue.splice), useElementValue = isRadio || valueIsArray, oldElemValue = valueIsArray ? checkedValue2() : void 0;
|
|
2452
|
+
computed(updateModel, null, { disposeWhenNodeIsRemoved: element });
|
|
2453
|
+
registerEventHandler(element, "click", updateModel);
|
|
2454
|
+
computed(updateView, null, { disposeWhenNodeIsRemoved: element });
|
|
2455
|
+
rawValue = void 0;
|
|
2456
|
+
}
|
|
2457
|
+
};
|
|
2458
|
+
var checkedValue = {
|
|
2459
|
+
update: function(element, valueAccessor) {
|
|
2460
|
+
element.value = unwrap(valueAccessor());
|
|
2461
|
+
}
|
|
2462
|
+
};
|
|
2463
|
+
|
|
2464
|
+
// src/event.ts
|
|
2465
|
+
function makeEventHandlerShortcut(eventName) {
|
|
2466
|
+
return {
|
|
2467
|
+
init: function(element, valueAccessor, allBindings, viewModel, bindingContext2) {
|
|
2468
|
+
var newValueAccessor = function() {
|
|
2469
|
+
var result = {};
|
|
2470
|
+
result[eventName] = valueAccessor();
|
|
2471
|
+
return result;
|
|
2472
|
+
};
|
|
2473
|
+
eventHandler.init.call(this, element, newValueAccessor, allBindings, viewModel, bindingContext2);
|
|
2474
|
+
}
|
|
2475
|
+
};
|
|
2476
|
+
}
|
|
2477
|
+
function makeDescriptor(handlerOrObject) {
|
|
2478
|
+
return typeof handlerOrObject === "function" ? { handler: handlerOrObject } : handlerOrObject || {};
|
|
2479
|
+
}
|
|
2480
|
+
var eventHandler = {
|
|
2481
|
+
init: function(element, valueAccessor, allBindings, viewModel, bindingContext2) {
|
|
2482
|
+
var eventsToHandle = valueAccessor() || {};
|
|
2483
|
+
objectForEach(eventsToHandle, function(eventName, descriptor) {
|
|
2484
|
+
const { passive, capture, once, debounce: debounce2, throttle: throttle2 } = makeDescriptor(descriptor);
|
|
2485
|
+
const eventOptions = (capture || passive || once) && { capture, passive, once };
|
|
2486
|
+
let eventHandlerFn = (event, ...more) => {
|
|
2487
|
+
var handlerReturnValue;
|
|
2488
|
+
const { handler: handler2, passive: passive2, bubble, preventDefault } = makeDescriptor(valueAccessor()[eventName]);
|
|
2489
|
+
try {
|
|
2490
|
+
if (handler2) {
|
|
2491
|
+
const possiblyUpdatedViewModel = bindingContext2.$data;
|
|
2492
|
+
const argsForHandler = [possiblyUpdatedViewModel, event, ...more];
|
|
2493
|
+
handlerReturnValue = handler2.apply(possiblyUpdatedViewModel, argsForHandler);
|
|
2494
|
+
}
|
|
2495
|
+
} finally {
|
|
2496
|
+
if (preventDefault !== void 0) {
|
|
2497
|
+
if (unwrap(preventDefault)) {
|
|
2498
|
+
event.preventDefault();
|
|
2499
|
+
}
|
|
2500
|
+
} else if (handlerReturnValue !== true) {
|
|
2501
|
+
if (!passive2) {
|
|
2502
|
+
event.preventDefault();
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
const bubbleMark = allBindings.get(eventName + "Bubble") !== false;
|
|
2507
|
+
if (bubble === false || !bubbleMark) {
|
|
2508
|
+
event.cancelBubble = true;
|
|
2509
|
+
if (event.stopPropagation) {
|
|
2510
|
+
event.stopPropagation();
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
};
|
|
2514
|
+
if (debounce2) {
|
|
2515
|
+
eventHandlerFn = debounce(eventHandlerFn, debounce2);
|
|
2516
|
+
}
|
|
2517
|
+
if (throttle2) {
|
|
2518
|
+
eventHandlerFn = throttle(eventHandlerFn, throttle2);
|
|
2519
|
+
}
|
|
2520
|
+
registerEventHandler(element, eventName, eventHandlerFn, eventOptions || false);
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2523
|
+
};
|
|
2524
|
+
var onHandler = {
|
|
2525
|
+
init: eventHandler.init,
|
|
2526
|
+
preprocess: function(value2, key, addBinding) {
|
|
2527
|
+
addBinding(key.replace("on.", ""), "=>" + value2);
|
|
2528
|
+
}
|
|
2529
|
+
};
|
|
2530
|
+
|
|
2531
|
+
// src/click.ts
|
|
2532
|
+
var click = makeEventHandlerShortcut("click");
|
|
2533
|
+
|
|
2534
|
+
// src/css.ts
|
|
2535
|
+
var css = {
|
|
2536
|
+
aliases: ["class"],
|
|
2537
|
+
update: function(element, valueAccessor) {
|
|
2538
|
+
var value2 = unwrap(valueAccessor());
|
|
2539
|
+
if (value2 !== null && typeof value2 === "object") {
|
|
2540
|
+
objectForEach(value2, function(className, shouldHaveClass) {
|
|
2541
|
+
shouldHaveClass = unwrap(shouldHaveClass);
|
|
2542
|
+
toggleDomNodeCssClass(element, className, shouldHaveClass);
|
|
2543
|
+
});
|
|
2544
|
+
} else {
|
|
2545
|
+
value2 = stringTrim(String(value2 || ""));
|
|
2546
|
+
toggleDomNodeCssClass(element, element[css.classesWrittenByBindingKey], false);
|
|
2547
|
+
element[css.classesWrittenByBindingKey] = value2;
|
|
2548
|
+
toggleDomNodeCssClass(element, value2, true);
|
|
2549
|
+
}
|
|
2550
|
+
},
|
|
2551
|
+
classesWrittenByBindingKey: createSymbolOrString("__ko__cssValue")
|
|
2552
|
+
};
|
|
2553
|
+
|
|
2554
|
+
// ../bind/dist/bindingEvent.js
|
|
2555
|
+
var contextAncestorBindingInfo = Symbol("_ancestorBindingInfo");
|
|
2556
|
+
var boundElementDomDataKey = data_exports.nextKey();
|
|
2557
|
+
var bindingEvent = {
|
|
2558
|
+
childrenComplete: "childrenComplete",
|
|
2559
|
+
descendantsComplete: "descendantsComplete",
|
|
2560
|
+
subscribe(node, event, callback, context) {
|
|
2561
|
+
const bindingInfo = data_exports.getOrSet(node, boundElementDomDataKey, {});
|
|
2562
|
+
if (!bindingInfo.eventSubscribable) {
|
|
2563
|
+
bindingInfo.eventSubscribable = new subscribable();
|
|
2564
|
+
}
|
|
2565
|
+
return bindingInfo.eventSubscribable.subscribe(callback, context, event);
|
|
2566
|
+
},
|
|
2567
|
+
notify(node, event) {
|
|
2568
|
+
const bindingInfo = data_exports.get(node, boundElementDomDataKey);
|
|
2569
|
+
if (bindingInfo) {
|
|
2570
|
+
if (bindingInfo.eventSubscribable) {
|
|
2571
|
+
bindingInfo.eventSubscribable.notifySubscribers(node, event);
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
};
|
|
2576
|
+
|
|
2577
|
+
// ../bind/dist/bindingContext.js
|
|
2578
|
+
var boundElementDomDataKey2 = data_exports.nextKey();
|
|
2579
|
+
var contextSubscribeSymbol = Symbol("Knockout Context Subscription");
|
|
2580
|
+
var inheritParentIndicator = Symbol("Knockout Parent Indicator");
|
|
2581
|
+
function bindingContext(dataItemOrAccessor, parentContext, dataItemAlias, extendCallback, settings) {
|
|
2582
|
+
const self = this;
|
|
2583
|
+
const shouldInheritData = dataItemOrAccessor === inheritParentIndicator;
|
|
2584
|
+
const realDataItemOrAccessor = shouldInheritData ? void 0 : dataItemOrAccessor;
|
|
2585
|
+
const isFunc = typeof realDataItemOrAccessor === "function" && !isObservable(realDataItemOrAccessor);
|
|
2586
|
+
self.ko = options_default.knockoutInstance;
|
|
2587
|
+
let nodes;
|
|
2588
|
+
let subscribable2;
|
|
2589
|
+
function updateContext() {
|
|
2590
|
+
const dataItemOrObservable = isFunc ? realDataItemOrAccessor() : realDataItemOrAccessor;
|
|
2591
|
+
let dataItem = unwrap(dataItemOrObservable);
|
|
2592
|
+
if (parentContext) {
|
|
2593
|
+
if (parentContext[contextSubscribeSymbol]) {
|
|
2594
|
+
parentContext[contextSubscribeSymbol]();
|
|
2595
|
+
}
|
|
2596
|
+
extend(self, parentContext);
|
|
2597
|
+
if (contextAncestorBindingInfo in parentContext) {
|
|
2598
|
+
self[contextAncestorBindingInfo] = parentContext[contextAncestorBindingInfo];
|
|
2599
|
+
}
|
|
2600
|
+
} else {
|
|
2601
|
+
self.$parents = [];
|
|
2602
|
+
self.$root = dataItem;
|
|
2603
|
+
}
|
|
2604
|
+
self[contextSubscribeSymbol] = subscribable2;
|
|
2605
|
+
if (shouldInheritData) {
|
|
2606
|
+
dataItem = self.$data;
|
|
2607
|
+
} else {
|
|
2608
|
+
self.$rawData = dataItemOrObservable;
|
|
2609
|
+
self.$data = dataItem;
|
|
2610
|
+
}
|
|
2611
|
+
if (dataItemAlias) {
|
|
2612
|
+
self[dataItemAlias] = dataItem;
|
|
2613
|
+
}
|
|
2614
|
+
if (extendCallback) {
|
|
2615
|
+
extendCallback(self, parentContext, dataItem);
|
|
2616
|
+
}
|
|
2617
|
+
return self.$data;
|
|
2618
|
+
}
|
|
2619
|
+
if (settings && settings.exportDependencies) {
|
|
2620
|
+
updateContext();
|
|
2621
|
+
} else {
|
|
2622
|
+
subscribable2 = pureComputed(updateContext);
|
|
2623
|
+
subscribable2.peek();
|
|
2624
|
+
if (subscribable2.isActive()) {
|
|
2625
|
+
self[contextSubscribeSymbol] = subscribable2;
|
|
2626
|
+
subscribable2["equalityComparer"] = null;
|
|
2627
|
+
} else {
|
|
2628
|
+
self[contextSubscribeSymbol] = void 0;
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
Object.assign(bindingContext.prototype, {
|
|
2633
|
+
lookup(token, globals, node) {
|
|
2634
|
+
switch (token) {
|
|
2635
|
+
case "$element":
|
|
2636
|
+
return node;
|
|
2637
|
+
case "$context":
|
|
2638
|
+
return this;
|
|
2639
|
+
case "this":
|
|
2640
|
+
case "$data":
|
|
2641
|
+
return this.$data;
|
|
2642
|
+
}
|
|
2643
|
+
const $data = this.$data;
|
|
2644
|
+
if (isObjectLike($data) && token in $data) {
|
|
2645
|
+
return $data[token];
|
|
2646
|
+
}
|
|
2647
|
+
if (token in this) {
|
|
2648
|
+
return this[token];
|
|
2649
|
+
}
|
|
2650
|
+
if (token in globals) {
|
|
2651
|
+
return globals[token];
|
|
2652
|
+
}
|
|
2653
|
+
throw new Error(`The variable "${token}" was not found on $data, $context, or globals.`);
|
|
2654
|
+
},
|
|
2655
|
+
createChildContext(dataItemOrAccessor, dataItemAlias, extendCallback, settings) {
|
|
2656
|
+
return new bindingContext(dataItemOrAccessor, this, dataItemAlias, function(self, parentContext) {
|
|
2657
|
+
self.$parentContext = parentContext;
|
|
2658
|
+
self.$parent = parentContext.$data;
|
|
2659
|
+
self.$parents = (parentContext.$parents || []).slice(0);
|
|
2660
|
+
self.$parents.unshift(self.$parent);
|
|
2661
|
+
if (extendCallback) {
|
|
2662
|
+
extendCallback(self);
|
|
2663
|
+
}
|
|
2664
|
+
}, settings);
|
|
2665
|
+
},
|
|
2666
|
+
extend(properties) {
|
|
2667
|
+
return new bindingContext(inheritParentIndicator, this, null, function(self, parentContext) {
|
|
2668
|
+
extend(self, typeof properties === "function" ? properties.call(self) : properties);
|
|
2669
|
+
});
|
|
2670
|
+
},
|
|
2671
|
+
createStaticChildContext(dataItemOrAccessor, dataItemAlias) {
|
|
2672
|
+
return this.createChildContext(dataItemOrAccessor, dataItemAlias, null, { "exportDependencies": true });
|
|
2673
|
+
}
|
|
2674
|
+
});
|
|
2675
|
+
function storedBindingContextForNode(node) {
|
|
2676
|
+
const bindingInfo = data_exports.get(node, boundElementDomDataKey2);
|
|
2677
|
+
return bindingInfo && bindingInfo.context;
|
|
2678
|
+
}
|
|
2679
|
+
function contextFor(node) {
|
|
2680
|
+
if (node && (node.nodeType === 1 || node.nodeType === 8)) {
|
|
2681
|
+
return storedBindingContextForNode(node);
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
function dataFor(node) {
|
|
2685
|
+
var context = contextFor(node);
|
|
2686
|
+
return context ? context.$data : void 0;
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
// ../bind/dist/BindingResult.js
|
|
2690
|
+
var __async = (__this, __arguments, generator) => {
|
|
2691
|
+
return new Promise((resolve, reject) => {
|
|
2692
|
+
var fulfilled = (value2) => {
|
|
2693
|
+
try {
|
|
2694
|
+
step(generator.next(value2));
|
|
2695
|
+
} catch (e) {
|
|
2696
|
+
reject(e);
|
|
2697
|
+
}
|
|
2698
|
+
};
|
|
2699
|
+
var rejected = (value2) => {
|
|
2700
|
+
try {
|
|
2701
|
+
step(generator.throw(value2));
|
|
2702
|
+
} catch (e) {
|
|
2703
|
+
reject(e);
|
|
2704
|
+
}
|
|
2705
|
+
};
|
|
2706
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2707
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
2708
|
+
});
|
|
2709
|
+
};
|
|
2710
|
+
var BindingResult = class {
|
|
2711
|
+
constructor({ asyncBindingsApplied, rootNode, bindingContext: bindingContext2 }) {
|
|
2712
|
+
Object.assign(this, {
|
|
2713
|
+
rootNode,
|
|
2714
|
+
bindingContext: bindingContext2,
|
|
2715
|
+
isSync: asyncBindingsApplied.size === 0,
|
|
2716
|
+
isComplete: this.isSync
|
|
2717
|
+
});
|
|
2718
|
+
if (!this.isSync) {
|
|
2719
|
+
this.completionPromise = this.completeWhenBindingsFinish(asyncBindingsApplied);
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
completeWhenBindingsFinish(asyncBindingsApplied) {
|
|
2723
|
+
return __async(this, null, function* () {
|
|
2724
|
+
yield Promise.all(asyncBindingsApplied);
|
|
2725
|
+
this.isComplete = true;
|
|
2726
|
+
return this;
|
|
2727
|
+
});
|
|
2728
|
+
}
|
|
2729
|
+
};
|
|
2730
|
+
|
|
2731
|
+
// ../lifecycle/dist/LifeCycle.js
|
|
2732
|
+
var SUBSCRIPTIONS = createSymbolOrString("LifeCycle Subscriptions List");
|
|
2733
|
+
var ANCHOR_NODE = createSymbolOrString("LifeCycle Anchor Node");
|
|
2734
|
+
var LifeCycle = class {
|
|
2735
|
+
static mixInto(Constructor) {
|
|
2736
|
+
const target = Constructor.prototype || Constructor;
|
|
2737
|
+
const mixin = LifeCycle.prototype;
|
|
2738
|
+
for (let prop of Object.getOwnPropertyNames(mixin)) {
|
|
2739
|
+
target[prop] = mixin[prop];
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
subscribe(observable2, action, subscriptionType) {
|
|
2743
|
+
if (typeof action === "string") {
|
|
2744
|
+
action = this[action];
|
|
2745
|
+
}
|
|
2746
|
+
this.addDisposable(observable2.subscribe(action, this, subscriptionType));
|
|
2747
|
+
}
|
|
2748
|
+
computed(params) {
|
|
2749
|
+
if (typeof params === "string") {
|
|
2750
|
+
params = { read: this[params], write: this[params] };
|
|
2751
|
+
}
|
|
2752
|
+
if (typeof params === "object") {
|
|
2753
|
+
params = Object.assign({ owner: this }, params);
|
|
2754
|
+
} else if (typeof params === "function") {
|
|
2755
|
+
const proto = Object.getPrototypeOf(this);
|
|
2756
|
+
if (proto && proto[params.name] === params) {
|
|
2757
|
+
params = params.bind(this);
|
|
2758
|
+
}
|
|
2759
|
+
params = { read: params, write: params };
|
|
2760
|
+
} else {
|
|
2761
|
+
throw new Error("LifeCycle::computed not given a valid type.");
|
|
2762
|
+
}
|
|
2763
|
+
params.disposeWhenNodeIsRemoved = this[ANCHOR_NODE];
|
|
2764
|
+
return this.addDisposable(computed(params));
|
|
2765
|
+
}
|
|
2766
|
+
addEventListener(...args) {
|
|
2767
|
+
const node = args[0].nodeType ? args.shift() : this[ANCHOR_NODE];
|
|
2768
|
+
const [type, act, options3] = args;
|
|
2769
|
+
const handler2 = typeof act === "string" ? this[act].bind(this) : act;
|
|
2770
|
+
this.__addEventListener(node, type, handler2, options3);
|
|
2771
|
+
}
|
|
2772
|
+
__addEventListener(node, eventType, handler2, options3) {
|
|
2773
|
+
node.addEventListener(eventType, handler2, options3);
|
|
2774
|
+
function dispose() {
|
|
2775
|
+
node.removeEventListener(eventType, handler2);
|
|
2776
|
+
}
|
|
2777
|
+
addDisposeCallback(node, dispose);
|
|
2778
|
+
this.addDisposable({ dispose });
|
|
2779
|
+
}
|
|
2780
|
+
anchorTo(nodeOrLifeCycle) {
|
|
2781
|
+
if ("addDisposable" in nodeOrLifeCycle) {
|
|
2782
|
+
nodeOrLifeCycle.addDisposable(this);
|
|
2783
|
+
this[ANCHOR_NODE] = null;
|
|
2784
|
+
} else {
|
|
2785
|
+
this[ANCHOR_NODE] = nodeOrLifeCycle;
|
|
2786
|
+
addDisposeCallback(nodeOrLifeCycle, () => this[ANCHOR_NODE] === nodeOrLifeCycle && this.dispose());
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
dispose() {
|
|
2790
|
+
const subscriptions = this[SUBSCRIPTIONS] || [];
|
|
2791
|
+
subscriptions.forEach((s) => s.dispose());
|
|
2792
|
+
this[SUBSCRIPTIONS] = [];
|
|
2793
|
+
this[ANCHOR_NODE] = null;
|
|
2794
|
+
}
|
|
2795
|
+
addDisposable(subscription) {
|
|
2796
|
+
const subscriptions = this[SUBSCRIPTIONS] || [];
|
|
2797
|
+
if (!this[SUBSCRIPTIONS]) {
|
|
2798
|
+
this[SUBSCRIPTIONS] = subscriptions;
|
|
2799
|
+
}
|
|
2800
|
+
if (typeof subscription.dispose !== "function") {
|
|
2801
|
+
throw new Error("Lifecycle::addDisposable argument missing `dispose`.");
|
|
2802
|
+
}
|
|
2803
|
+
subscriptions.push(subscription);
|
|
2804
|
+
return subscription;
|
|
2805
|
+
}
|
|
2806
|
+
};
|
|
2807
|
+
|
|
2808
|
+
// ../bind/dist/BindingHandler.js
|
|
2809
|
+
var BindingHandler = class extends LifeCycle {
|
|
2810
|
+
constructor(params) {
|
|
2811
|
+
super();
|
|
2812
|
+
const { $element, valueAccessor, allBindings, $context } = params;
|
|
2813
|
+
Object.assign(this, {
|
|
2814
|
+
valueAccessor,
|
|
2815
|
+
allBindings,
|
|
2816
|
+
$element,
|
|
2817
|
+
$context,
|
|
2818
|
+
$data: $context.$data
|
|
2819
|
+
});
|
|
2820
|
+
this.anchorTo($element);
|
|
2821
|
+
}
|
|
2822
|
+
get value() {
|
|
2823
|
+
return this.valueAccessor();
|
|
2824
|
+
}
|
|
2825
|
+
set value(v) {
|
|
2826
|
+
const va = this.valueAccessor();
|
|
2827
|
+
if (isWriteableObservable(va)) {
|
|
2828
|
+
va(v);
|
|
2829
|
+
} else {
|
|
2830
|
+
this.valueAccessor(v);
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
get controlsDescendants() {
|
|
2834
|
+
return false;
|
|
2835
|
+
}
|
|
2836
|
+
static get allowVirtualElements() {
|
|
2837
|
+
return false;
|
|
2838
|
+
}
|
|
2839
|
+
static get isBindingHandlerClass() {
|
|
2840
|
+
return true;
|
|
2841
|
+
}
|
|
2842
|
+
get bindingCompleted() {
|
|
2843
|
+
return true;
|
|
2844
|
+
}
|
|
2845
|
+
static registerAs(name, provider = options_default.bindingProviderInstance) {
|
|
2846
|
+
provider.bindingHandlers.set(name, this);
|
|
2847
|
+
}
|
|
2848
|
+
};
|
|
2849
|
+
var ResolveSymbol = Symbol("Async Binding Resolved");
|
|
2850
|
+
|
|
2851
|
+
// ../bind/dist/LegacyBindingHandler.js
|
|
2852
|
+
var PossibleWeakMap = options_default.global.WeakMap || Map;
|
|
2853
|
+
var legacyBindingMap = new PossibleWeakMap();
|
|
2854
|
+
var LegacyBindingHandler = class extends BindingHandler {
|
|
2855
|
+
constructor(params) {
|
|
2856
|
+
super(params);
|
|
2857
|
+
const handler2 = this.handler;
|
|
2858
|
+
this.onError = params.onError;
|
|
2859
|
+
if (typeof handler2.dispose === "function") {
|
|
2860
|
+
this.addDisposable(handler2);
|
|
2861
|
+
}
|
|
2862
|
+
try {
|
|
2863
|
+
this.initReturn = handler2.init && handler2.init(...this.legacyArgs);
|
|
2864
|
+
} catch (e) {
|
|
2865
|
+
params.onError("init", e);
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
onValueChange() {
|
|
2869
|
+
const handler2 = this.handler;
|
|
2870
|
+
if (typeof handler2.update !== "function") {
|
|
2871
|
+
return;
|
|
2872
|
+
}
|
|
2873
|
+
try {
|
|
2874
|
+
handler2.update(...this.legacyArgs);
|
|
2875
|
+
} catch (e) {
|
|
2876
|
+
this.onError("update", e);
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
get legacyArgs() {
|
|
2880
|
+
return [
|
|
2881
|
+
this.$element,
|
|
2882
|
+
this.valueAccessor,
|
|
2883
|
+
this.allBindings,
|
|
2884
|
+
this.$data,
|
|
2885
|
+
this.$context
|
|
2886
|
+
];
|
|
2887
|
+
}
|
|
2888
|
+
get controlsDescendants() {
|
|
2889
|
+
const objectToTest = this.initReturn || this.handler || {};
|
|
2890
|
+
return objectToTest.controlsDescendantBindings;
|
|
2891
|
+
}
|
|
2892
|
+
static getOrCreateFor(key, handler2) {
|
|
2893
|
+
if (legacyBindingMap.has(handler2)) {
|
|
2894
|
+
return legacyBindingMap.get(handler2);
|
|
2895
|
+
}
|
|
2896
|
+
const newLegacyHandler = this.createFor(key, handler2);
|
|
2897
|
+
legacyBindingMap.set(handler2, newLegacyHandler);
|
|
2898
|
+
return newLegacyHandler;
|
|
2899
|
+
}
|
|
2900
|
+
static createFor(key, handler2) {
|
|
2901
|
+
if (typeof handler2 === "function") {
|
|
2902
|
+
const [initFn, disposeFn] = [handler2, handler2.dispose];
|
|
2903
|
+
return class extends LegacyBindingHandler {
|
|
2904
|
+
get handler() {
|
|
2905
|
+
const init = initFn.bind(this);
|
|
2906
|
+
const dispose = disposeFn ? disposeFn.bind(this) : null;
|
|
2907
|
+
return { init, dispose };
|
|
2908
|
+
}
|
|
2909
|
+
static get after() {
|
|
2910
|
+
return handler2.after;
|
|
2911
|
+
}
|
|
2912
|
+
static get allowVirtualElements() {
|
|
2913
|
+
return handler2.allowVirtualElements || virtualElements_exports.allowedBindings[key];
|
|
2914
|
+
}
|
|
2915
|
+
};
|
|
2916
|
+
}
|
|
2917
|
+
if (typeof handler2 === "object") {
|
|
2918
|
+
return class extends LegacyBindingHandler {
|
|
2919
|
+
get handler() {
|
|
2920
|
+
return handler2;
|
|
2921
|
+
}
|
|
2922
|
+
static get after() {
|
|
2923
|
+
return handler2.after;
|
|
2924
|
+
}
|
|
2925
|
+
static get allowVirtualElements() {
|
|
2926
|
+
return handler2.allowVirtualElements || virtualElements_exports.allowedBindings[key];
|
|
2927
|
+
}
|
|
2928
|
+
};
|
|
2929
|
+
}
|
|
2930
|
+
throw new Error("The given handler is not an appropriate type.");
|
|
2931
|
+
}
|
|
2932
|
+
};
|
|
2933
|
+
|
|
2934
|
+
// ../bind/dist/applyBindings.js
|
|
2935
|
+
var bindingDoesNotRecurseIntoElementTypes = {
|
|
2936
|
+
"script": true,
|
|
2937
|
+
"textarea": true,
|
|
2938
|
+
"template": true
|
|
2939
|
+
};
|
|
2940
|
+
function getBindingProvider() {
|
|
2941
|
+
return options_default.bindingProviderInstance.instance || options_default.bindingProviderInstance;
|
|
2942
|
+
}
|
|
2943
|
+
function isProviderForNode(provider, node) {
|
|
2944
|
+
const nodeTypes = provider.FOR_NODE_TYPES || [1, 3, 8];
|
|
2945
|
+
return nodeTypes.includes(node.nodeType);
|
|
2946
|
+
}
|
|
2947
|
+
function asProperHandlerClass(handler2, bindingKey) {
|
|
2948
|
+
if (!handler2) {
|
|
2949
|
+
return;
|
|
2950
|
+
}
|
|
2951
|
+
return handler2.isBindingHandlerClass ? handler2 : LegacyBindingHandler.getOrCreateFor(bindingKey, handler2);
|
|
2952
|
+
}
|
|
2953
|
+
function getBindingHandlerFromComponent(bindingKey, $component) {
|
|
2954
|
+
if (!$component || typeof $component.getBindingHandler !== "function") {
|
|
2955
|
+
return;
|
|
2956
|
+
}
|
|
2957
|
+
return asProperHandlerClass($component.getBindingHandler(bindingKey));
|
|
2958
|
+
}
|
|
2959
|
+
function getBindingHandler(bindingKey) {
|
|
2960
|
+
const bindingDefinition = options_default.getBindingHandler(bindingKey) || getBindingProvider().bindingHandlers.get(bindingKey);
|
|
2961
|
+
return asProperHandlerClass(bindingDefinition, bindingKey);
|
|
2962
|
+
}
|
|
2963
|
+
function evaluateValueAccessor(valueAccessor) {
|
|
2964
|
+
return valueAccessor();
|
|
2965
|
+
}
|
|
2966
|
+
function applyBindingsToDescendantsInternal(bindingContext2, elementOrVirtualElement, asyncBindingsApplied) {
|
|
2967
|
+
let nextInQueue = virtualElements_exports.firstChild(elementOrVirtualElement);
|
|
2968
|
+
if (!nextInQueue) {
|
|
2969
|
+
return;
|
|
2970
|
+
}
|
|
2971
|
+
let currentChild;
|
|
2972
|
+
const provider = getBindingProvider();
|
|
2973
|
+
const preprocessNode = provider.preprocessNode;
|
|
2974
|
+
if (preprocessNode) {
|
|
2975
|
+
while (currentChild = nextInQueue) {
|
|
2976
|
+
nextInQueue = virtualElements_exports.nextSibling(currentChild);
|
|
2977
|
+
preprocessNode.call(provider, currentChild);
|
|
2978
|
+
}
|
|
2979
|
+
nextInQueue = virtualElements_exports.firstChild(elementOrVirtualElement);
|
|
2980
|
+
}
|
|
2981
|
+
while (currentChild = nextInQueue) {
|
|
2982
|
+
nextInQueue = virtualElements_exports.nextSibling(currentChild);
|
|
2983
|
+
applyBindingsToNodeAndDescendantsInternal(bindingContext2, currentChild, asyncBindingsApplied);
|
|
2984
|
+
}
|
|
2985
|
+
bindingEvent.notify(elementOrVirtualElement, bindingEvent.childrenComplete);
|
|
2986
|
+
}
|
|
2987
|
+
function hasBindings(node) {
|
|
2988
|
+
const provider = getBindingProvider();
|
|
2989
|
+
return isProviderForNode(provider, node) && provider.nodeHasBindings(node);
|
|
2990
|
+
}
|
|
2991
|
+
function nodeOrChildHasBindings(node) {
|
|
2992
|
+
return hasBindings(node) || [...node.childNodes].some((c) => nodeOrChildHasBindings(c));
|
|
2993
|
+
}
|
|
2994
|
+
function applyBindingsToNodeAndDescendantsInternal(bindingContext2, nodeVerified, asyncBindingsApplied) {
|
|
2995
|
+
var isElement = nodeVerified.nodeType === 1;
|
|
2996
|
+
if (isElement) {
|
|
2997
|
+
virtualElements_exports.normaliseVirtualElementDomStructure(nodeVerified);
|
|
2998
|
+
}
|
|
2999
|
+
let shouldApplyBindings = isElement || hasBindings(nodeVerified);
|
|
3000
|
+
const { shouldBindDescendants } = shouldApplyBindings ? applyBindingsToNodeInternal(nodeVerified, null, bindingContext2, asyncBindingsApplied) : { shouldBindDescendants: true };
|
|
3001
|
+
if (shouldBindDescendants && !bindingDoesNotRecurseIntoElementTypes[tagNameLower(nodeVerified)]) {
|
|
3002
|
+
applyBindingsToDescendantsInternal(bindingContext2, nodeVerified, asyncBindingsApplied);
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
function* topologicalSortBindings(bindings2, $component) {
|
|
3006
|
+
const results = [];
|
|
3007
|
+
const bindingsConsidered = {};
|
|
3008
|
+
const cyclicDependencyStack = [];
|
|
3009
|
+
objectForEach(bindings2, function pushBinding(bindingKey) {
|
|
3010
|
+
if (!bindingsConsidered[bindingKey]) {
|
|
3011
|
+
const binding = getBindingHandlerFromComponent(bindingKey, $component) || getBindingHandler(bindingKey);
|
|
3012
|
+
if (!binding) {
|
|
3013
|
+
return;
|
|
3014
|
+
}
|
|
3015
|
+
if (binding.after) {
|
|
3016
|
+
cyclicDependencyStack.push(bindingKey);
|
|
3017
|
+
arrayForEach(binding.after, function(bindingDependencyKey) {
|
|
3018
|
+
if (!bindings2[bindingDependencyKey]) {
|
|
3019
|
+
return;
|
|
3020
|
+
}
|
|
3021
|
+
if (arrayIndexOf(cyclicDependencyStack, bindingDependencyKey) !== -1) {
|
|
3022
|
+
throw Error("Cannot combine the following bindings, because they have a cyclic dependency: " + cyclicDependencyStack.join(", "));
|
|
3023
|
+
} else {
|
|
3024
|
+
pushBinding(bindingDependencyKey);
|
|
3025
|
+
}
|
|
3026
|
+
});
|
|
3027
|
+
cyclicDependencyStack.length--;
|
|
3028
|
+
}
|
|
3029
|
+
results.push([bindingKey, binding]);
|
|
3030
|
+
}
|
|
3031
|
+
bindingsConsidered[bindingKey] = true;
|
|
3032
|
+
});
|
|
3033
|
+
for (const result of results) {
|
|
3034
|
+
yield result;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyncBindingsApplied) {
|
|
3038
|
+
const bindingInfo = data_exports.getOrSet(node, boundElementDomDataKey2, {});
|
|
3039
|
+
const alreadyBound = bindingInfo.alreadyBound;
|
|
3040
|
+
if (!sourceBindings) {
|
|
3041
|
+
if (alreadyBound) {
|
|
3042
|
+
if (!nodeOrChildHasBindings(node)) {
|
|
3043
|
+
return false;
|
|
3044
|
+
}
|
|
3045
|
+
onBindingError({
|
|
3046
|
+
during: "apply",
|
|
3047
|
+
errorCaptured: new Error("You cannot apply bindings multiple times to the same element."),
|
|
3048
|
+
element: node,
|
|
3049
|
+
bindingContext: bindingContext2
|
|
3050
|
+
});
|
|
3051
|
+
return false;
|
|
3052
|
+
}
|
|
3053
|
+
bindingInfo.alreadyBound = true;
|
|
3054
|
+
}
|
|
3055
|
+
if (!alreadyBound) {
|
|
3056
|
+
bindingInfo.context = bindingContext2;
|
|
3057
|
+
}
|
|
3058
|
+
var bindings2;
|
|
3059
|
+
if (sourceBindings && typeof sourceBindings !== "function") {
|
|
3060
|
+
bindings2 = sourceBindings;
|
|
3061
|
+
} else {
|
|
3062
|
+
const provider = getBindingProvider();
|
|
3063
|
+
const getBindings = provider.getBindingAccessors;
|
|
3064
|
+
if (isProviderForNode(provider, node)) {
|
|
3065
|
+
var bindingsUpdater = computed(function() {
|
|
3066
|
+
bindings2 = sourceBindings ? sourceBindings(bindingContext2, node) : getBindings.call(provider, node, bindingContext2);
|
|
3067
|
+
if (bindings2 && bindingContext2[contextSubscribeSymbol]) {
|
|
3068
|
+
bindingContext2[contextSubscribeSymbol]();
|
|
3069
|
+
}
|
|
3070
|
+
return bindings2;
|
|
3071
|
+
}, null, { disposeWhenNodeIsRemoved: node });
|
|
3072
|
+
if (!bindings2 || !bindingsUpdater.isActive()) {
|
|
3073
|
+
bindingsUpdater = null;
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
var bindingHandlerThatControlsDescendantBindings;
|
|
3078
|
+
if (bindings2) {
|
|
3079
|
+
let allBindings = function() {
|
|
3080
|
+
return objectMap(bindingsUpdater ? bindingsUpdater() : bindings2, evaluateValueAccessor);
|
|
3081
|
+
};
|
|
3082
|
+
const $component = bindingContext2.$component || {};
|
|
3083
|
+
const allBindingHandlers = {};
|
|
3084
|
+
data_exports.set(node, "bindingHandlers", allBindingHandlers);
|
|
3085
|
+
const getValueAccessor = bindingsUpdater ? (bindingKey) => function(optionalValue) {
|
|
3086
|
+
const valueAccessor = bindingsUpdater()[bindingKey];
|
|
3087
|
+
if (arguments.length === 0) {
|
|
3088
|
+
return evaluateValueAccessor(valueAccessor);
|
|
3089
|
+
} else {
|
|
3090
|
+
return valueAccessor(optionalValue);
|
|
3091
|
+
}
|
|
3092
|
+
} : (bindingKey) => bindings2[bindingKey];
|
|
3093
|
+
allBindings.has = (key) => key in bindings2;
|
|
3094
|
+
allBindings.get = (key) => bindings2[key] && evaluateValueAccessor(getValueAccessor(key));
|
|
3095
|
+
if (bindingEvent.childrenComplete in bindings2) {
|
|
3096
|
+
bindingEvent.subscribe(node, bindingEvent.childrenComplete, () => {
|
|
3097
|
+
const callback = evaluateValueAccessor(bindings2[bindingEvent.childrenComplete]);
|
|
3098
|
+
if (!callback) {
|
|
3099
|
+
return;
|
|
3100
|
+
}
|
|
3101
|
+
const nodes = virtualElements_exports.childNodes(node);
|
|
3102
|
+
if (nodes.length) {
|
|
3103
|
+
callback(nodes, dataFor(nodes[0]));
|
|
3104
|
+
}
|
|
3105
|
+
});
|
|
3106
|
+
}
|
|
3107
|
+
const bindingsGenerated = topologicalSortBindings(bindings2, $component);
|
|
3108
|
+
const nodeAsyncBindingPromises = /* @__PURE__ */ new Set();
|
|
3109
|
+
for (const [key, BindingHandlerClass] of bindingsGenerated) {
|
|
3110
|
+
let reportBindingError = function(during, errorCaptured) {
|
|
3111
|
+
onBindingError({
|
|
3112
|
+
during,
|
|
3113
|
+
errorCaptured,
|
|
3114
|
+
bindings: bindings2,
|
|
3115
|
+
allBindings,
|
|
3116
|
+
bindingKey: key,
|
|
3117
|
+
bindingContext: bindingContext2,
|
|
3118
|
+
element: node,
|
|
3119
|
+
valueAccessor: getValueAccessor(key)
|
|
3120
|
+
});
|
|
3121
|
+
};
|
|
3122
|
+
if (node.nodeType === 8 && !BindingHandlerClass.allowVirtualElements) {
|
|
3123
|
+
throw new Error(`The binding '${key}' cannot be used with virtual elements`);
|
|
3124
|
+
}
|
|
3125
|
+
try {
|
|
3126
|
+
const bindingHandler = dependencyDetection_exports.ignore(() => new BindingHandlerClass({
|
|
3127
|
+
allBindings,
|
|
3128
|
+
$element: node,
|
|
3129
|
+
$context: bindingContext2,
|
|
3130
|
+
onError: reportBindingError,
|
|
3131
|
+
valueAccessor(...v) {
|
|
3132
|
+
return getValueAccessor(key)(...v);
|
|
3133
|
+
}
|
|
3134
|
+
}));
|
|
3135
|
+
if (bindingHandler.onValueChange) {
|
|
3136
|
+
dependencyDetection_exports.ignore(() => bindingHandler.computed("onValueChange"));
|
|
3137
|
+
}
|
|
3138
|
+
allBindingHandlers[key] = bindingHandler;
|
|
3139
|
+
if (bindingHandler.controlsDescendants) {
|
|
3140
|
+
if (bindingHandlerThatControlsDescendantBindings !== void 0) {
|
|
3141
|
+
throw new Error("Multiple bindings (" + bindingHandlerThatControlsDescendantBindings + " and " + key + ") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");
|
|
3142
|
+
}
|
|
3143
|
+
bindingHandlerThatControlsDescendantBindings = key;
|
|
3144
|
+
}
|
|
3145
|
+
if (bindingHandler.bindingCompleted instanceof Promise) {
|
|
3146
|
+
asyncBindingsApplied.add(bindingHandler.bindingCompleted);
|
|
3147
|
+
nodeAsyncBindingPromises.add(bindingHandler.bindingCompleted);
|
|
3148
|
+
}
|
|
3149
|
+
} catch (err) {
|
|
3150
|
+
reportBindingError("creation", err);
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
triggerDescendantsComplete(node, bindings2, nodeAsyncBindingPromises);
|
|
3154
|
+
}
|
|
3155
|
+
const shouldBindDescendants = bindingHandlerThatControlsDescendantBindings === void 0;
|
|
3156
|
+
return { shouldBindDescendants };
|
|
3157
|
+
}
|
|
3158
|
+
function triggerDescendantsComplete(node, bindings2, nodeAsyncBindingPromises) {
|
|
3159
|
+
const hasBindingHandler = bindingEvent.descendantsComplete in bindings2;
|
|
3160
|
+
const hasFirstChild = virtualElements_exports.firstChild(node);
|
|
3161
|
+
const accessor = hasBindingHandler && evaluateValueAccessor(bindings2[bindingEvent.descendantsComplete]);
|
|
3162
|
+
const callback = () => {
|
|
3163
|
+
bindingEvent.notify(node, bindingEvent.descendantsComplete);
|
|
3164
|
+
if (accessor && hasFirstChild) {
|
|
3165
|
+
accessor(node);
|
|
3166
|
+
}
|
|
3167
|
+
};
|
|
3168
|
+
if (nodeAsyncBindingPromises.size) {
|
|
3169
|
+
Promise.all(nodeAsyncBindingPromises).then(callback);
|
|
3170
|
+
} else {
|
|
3171
|
+
callback();
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
function getBindingContext(viewModelOrBindingContext, extendContextCallback) {
|
|
3175
|
+
return viewModelOrBindingContext && viewModelOrBindingContext instanceof bindingContext ? viewModelOrBindingContext : new bindingContext(viewModelOrBindingContext, void 0, void 0, extendContextCallback);
|
|
3176
|
+
}
|
|
3177
|
+
function applyBindingAccessorsToNode(node, bindings2, viewModelOrBindingContext, asyncBindingsApplied) {
|
|
3178
|
+
if (node.nodeType === 1) {
|
|
3179
|
+
virtualElements_exports.normaliseVirtualElementDomStructure(node);
|
|
3180
|
+
}
|
|
3181
|
+
return applyBindingsToNodeInternal(node, bindings2, getBindingContext(viewModelOrBindingContext), asyncBindingsApplied);
|
|
3182
|
+
}
|
|
3183
|
+
function applyBindingsToDescendants(viewModelOrBindingContext, rootNode) {
|
|
3184
|
+
const asyncBindingsApplied = /* @__PURE__ */ new Set();
|
|
3185
|
+
if (rootNode.nodeType === 1 || rootNode.nodeType === 8) {
|
|
3186
|
+
const bindingContext2 = getBindingContext(viewModelOrBindingContext);
|
|
3187
|
+
applyBindingsToDescendantsInternal(bindingContext2, rootNode, asyncBindingsApplied);
|
|
3188
|
+
return new BindingResult({ asyncBindingsApplied, rootNode, bindingContext: bindingContext2 });
|
|
3189
|
+
}
|
|
3190
|
+
return new BindingResult({ asyncBindingsApplied, rootNode });
|
|
3191
|
+
}
|
|
3192
|
+
function onBindingError(spec) {
|
|
3193
|
+
var error, bindingText;
|
|
3194
|
+
if (spec.bindingKey) {
|
|
3195
|
+
error = spec.errorCaptured;
|
|
3196
|
+
spec.message = 'Unable to process binding "' + spec.bindingKey + '" in binding "' + spec.bindingKey + '"\nMessage: ' + (error.message ? error.message : error);
|
|
3197
|
+
} else {
|
|
3198
|
+
error = spec.errorCaptured;
|
|
3199
|
+
}
|
|
3200
|
+
try {
|
|
3201
|
+
extend(error, spec);
|
|
3202
|
+
} catch (e) {
|
|
3203
|
+
spec.stack = error.stack;
|
|
3204
|
+
error = new Error(error.message ? error.message : error);
|
|
3205
|
+
extend(error, spec);
|
|
3206
|
+
}
|
|
3207
|
+
options_default.onError(error);
|
|
3208
|
+
}
|
|
3209
|
+
|
|
3210
|
+
// ../bind/dist/arrayToDomNodeChildren.js
|
|
3211
|
+
function mapNodeAndRefreshWhenChanged(containerNode, mapping, valueToMap, callbackAfterAddingNodes, index) {
|
|
3212
|
+
var mappedNodes = [];
|
|
3213
|
+
var dependentObservable = computed(function() {
|
|
3214
|
+
var newMappedNodes = mapping(valueToMap, index, fixUpContinuousNodeArray(mappedNodes, containerNode)) || [];
|
|
3215
|
+
if (mappedNodes.length > 0) {
|
|
3216
|
+
replaceDomNodes(mappedNodes, newMappedNodes);
|
|
3217
|
+
if (callbackAfterAddingNodes) {
|
|
3218
|
+
dependencyDetection_exports.ignore(callbackAfterAddingNodes, null, [valueToMap, newMappedNodes, index]);
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
mappedNodes.length = 0;
|
|
3222
|
+
arrayPushAll(mappedNodes, newMappedNodes);
|
|
3223
|
+
}, null, { disposeWhenNodeIsRemoved: containerNode, disposeWhen: function() {
|
|
3224
|
+
return !anyDomNodeIsAttachedToDocument(mappedNodes);
|
|
3225
|
+
} });
|
|
3226
|
+
return { mappedNodes, dependentObservable: dependentObservable.isActive() ? dependentObservable : void 0 };
|
|
3227
|
+
}
|
|
3228
|
+
var lastMappingResultDomDataKey = data_exports.nextKey();
|
|
3229
|
+
var deletedItemDummyValue = data_exports.nextKey();
|
|
3230
|
+
function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, callbackAfterAddingNodes, editScript) {
|
|
3231
|
+
array = array || [];
|
|
3232
|
+
if (typeof array.length === "undefined") {
|
|
3233
|
+
array = [array];
|
|
3234
|
+
}
|
|
3235
|
+
options3 = options3 || {};
|
|
3236
|
+
let lastMappingResult = data_exports.get(domNode, lastMappingResultDomDataKey);
|
|
3237
|
+
let isFirstExecution = !lastMappingResult;
|
|
3238
|
+
var newMappingResult = [];
|
|
3239
|
+
var lastMappingResultIndex = 0;
|
|
3240
|
+
var newMappingResultIndex = 0;
|
|
3241
|
+
var nodesToDelete = [];
|
|
3242
|
+
var itemsToProcess = [];
|
|
3243
|
+
var itemsForBeforeRemoveCallbacks = [];
|
|
3244
|
+
var itemsForMoveCallbacks = [];
|
|
3245
|
+
var itemsForAfterAddCallbacks = [];
|
|
3246
|
+
var mapData;
|
|
3247
|
+
let countWaitingForRemove = 0;
|
|
3248
|
+
function itemAdded(value2) {
|
|
3249
|
+
mapData = { arrayEntry: value2, indexObservable: observable(newMappingResultIndex++) };
|
|
3250
|
+
newMappingResult.push(mapData);
|
|
3251
|
+
itemsToProcess.push(mapData);
|
|
3252
|
+
if (!isFirstExecution) {
|
|
3253
|
+
itemsForAfterAddCallbacks.push(mapData);
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
function itemMovedOrRetained(oldPosition) {
|
|
3257
|
+
mapData = lastMappingResult[oldPosition];
|
|
3258
|
+
if (newMappingResultIndex !== oldPosition) {
|
|
3259
|
+
itemsForMoveCallbacks.push(mapData);
|
|
3260
|
+
}
|
|
3261
|
+
mapData.indexObservable(newMappingResultIndex++);
|
|
3262
|
+
fixUpContinuousNodeArray(mapData.mappedNodes, domNode);
|
|
3263
|
+
newMappingResult.push(mapData);
|
|
3264
|
+
itemsToProcess.push(mapData);
|
|
3265
|
+
}
|
|
3266
|
+
function callCallback(callback, items) {
|
|
3267
|
+
if (callback) {
|
|
3268
|
+
for (var i2 = 0, n = items.length; i2 < n; i2++) {
|
|
3269
|
+
arrayForEach(items[i2].mappedNodes, function(node2) {
|
|
3270
|
+
callback(node2, i2, items[i2].arrayEntry);
|
|
3271
|
+
});
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
if (isFirstExecution) {
|
|
3276
|
+
arrayForEach(array, itemAdded);
|
|
3277
|
+
} else {
|
|
3278
|
+
if (!editScript || lastMappingResult && lastMappingResult["_countWaitingForRemove"]) {
|
|
3279
|
+
var lastArray = isFirstExecution ? [] : arrayMap(lastMappingResult, function(x) {
|
|
3280
|
+
return x.arrayEntry;
|
|
3281
|
+
});
|
|
3282
|
+
var compareOptions = {
|
|
3283
|
+
"dontLimitMoves": options3["dontLimitMoves"],
|
|
3284
|
+
"sparse": true
|
|
3285
|
+
};
|
|
3286
|
+
editScript = compareArrays(lastArray, array, compareOptions);
|
|
3287
|
+
}
|
|
3288
|
+
for (var i = 0, editScriptItem, movedIndex, itemIndex; editScriptItem = editScript[i]; i++) {
|
|
3289
|
+
movedIndex = editScriptItem["moved"];
|
|
3290
|
+
itemIndex = editScriptItem["index"];
|
|
3291
|
+
switch (editScriptItem["status"]) {
|
|
3292
|
+
case "deleted":
|
|
3293
|
+
while (lastMappingResultIndex < itemIndex) {
|
|
3294
|
+
itemMovedOrRetained(lastMappingResultIndex++);
|
|
3295
|
+
}
|
|
3296
|
+
if (movedIndex === void 0) {
|
|
3297
|
+
mapData = lastMappingResult[lastMappingResultIndex];
|
|
3298
|
+
if (mapData.dependentObservable) {
|
|
3299
|
+
mapData.dependentObservable.dispose();
|
|
3300
|
+
mapData.dependentObservable = void 0;
|
|
3301
|
+
}
|
|
3302
|
+
if (fixUpContinuousNodeArray(mapData.mappedNodes, domNode).length) {
|
|
3303
|
+
if (options3["beforeRemove"]) {
|
|
3304
|
+
newMappingResult.push(mapData);
|
|
3305
|
+
itemsToProcess.push(mapData);
|
|
3306
|
+
countWaitingForRemove++;
|
|
3307
|
+
if (mapData.arrayEntry === deletedItemDummyValue) {
|
|
3308
|
+
mapData = null;
|
|
3309
|
+
} else {
|
|
3310
|
+
itemsForBeforeRemoveCallbacks.push(mapData);
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
if (mapData) {
|
|
3314
|
+
nodesToDelete.push.apply(nodesToDelete, mapData.mappedNodes);
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
lastMappingResultIndex++;
|
|
3319
|
+
break;
|
|
3320
|
+
case "added":
|
|
3321
|
+
while (newMappingResultIndex < itemIndex) {
|
|
3322
|
+
itemMovedOrRetained(lastMappingResultIndex++);
|
|
3323
|
+
}
|
|
3324
|
+
if (movedIndex !== void 0) {
|
|
3325
|
+
itemMovedOrRetained(movedIndex);
|
|
3326
|
+
} else {
|
|
3327
|
+
itemAdded(editScriptItem["value"]);
|
|
3328
|
+
}
|
|
3329
|
+
break;
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3332
|
+
while (newMappingResultIndex < array.length) {
|
|
3333
|
+
itemMovedOrRetained(lastMappingResultIndex++);
|
|
3334
|
+
}
|
|
3335
|
+
newMappingResult["_countWaitingForRemove"] = countWaitingForRemove;
|
|
3336
|
+
}
|
|
3337
|
+
data_exports.set(domNode, lastMappingResultDomDataKey, newMappingResult);
|
|
3338
|
+
callCallback(options3["beforeMove"], itemsForMoveCallbacks);
|
|
3339
|
+
arrayForEach(nodesToDelete, options3["beforeRemove"] ? cleanNode : removeNode);
|
|
3340
|
+
i = 0;
|
|
3341
|
+
for (var nextNode = virtualElements_exports.firstChild(domNode), lastNode, node; mapData = itemsToProcess[i]; i++) {
|
|
3342
|
+
if (!mapData.mappedNodes) {
|
|
3343
|
+
extend(mapData, mapNodeAndRefreshWhenChanged(domNode, mapping, mapData.arrayEntry, callbackAfterAddingNodes, mapData.indexObservable));
|
|
3344
|
+
}
|
|
3345
|
+
for (var j = 0; node = mapData.mappedNodes[j]; nextNode = node.nextSibling, lastNode = node, j++) {
|
|
3346
|
+
if (node !== nextNode) {
|
|
3347
|
+
virtualElements_exports.insertAfter(domNode, node, lastNode);
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
if (!mapData.initialized && callbackAfterAddingNodes) {
|
|
3351
|
+
callbackAfterAddingNodes(mapData.arrayEntry, mapData.mappedNodes, mapData.indexObservable);
|
|
3352
|
+
mapData.initialized = true;
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
callCallback(options3["beforeRemove"], itemsForBeforeRemoveCallbacks);
|
|
3356
|
+
for (i = 0; i < itemsForBeforeRemoveCallbacks.length; ++i) {
|
|
3357
|
+
itemsForBeforeRemoveCallbacks[i].arrayEntry = deletedItemDummyValue;
|
|
3358
|
+
}
|
|
3359
|
+
callCallback(options3["afterMove"], itemsForMoveCallbacks);
|
|
3360
|
+
callCallback(options3["afterAdd"], itemsForAfterAddCallbacks);
|
|
3361
|
+
}
|
|
3362
|
+
|
|
3363
|
+
// src/descendantsComplete.ts
|
|
3364
|
+
var DescendantsCompleteHandler = class extends BindingHandler {
|
|
3365
|
+
onDescendantsComplete() {
|
|
3366
|
+
if (typeof this.value === "function") {
|
|
3367
|
+
this.value(this.$element);
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
static get allowVirtualElements() {
|
|
3371
|
+
return true;
|
|
3372
|
+
}
|
|
3373
|
+
};
|
|
3374
|
+
|
|
3375
|
+
// src/enableDisable.ts
|
|
3376
|
+
var enable = {
|
|
3377
|
+
update: function(element, valueAccessor) {
|
|
3378
|
+
var value2 = unwrap(valueAccessor());
|
|
3379
|
+
if (value2 && element.disabled) {
|
|
3380
|
+
element.removeAttribute("disabled");
|
|
3381
|
+
} else if (!value2 && !element.disabled) {
|
|
3382
|
+
element.disabled = true;
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
};
|
|
3386
|
+
var disable = {
|
|
3387
|
+
update: function(element, valueAccessor) {
|
|
3388
|
+
enable.update(element, function() {
|
|
3389
|
+
return !unwrap(valueAccessor());
|
|
3390
|
+
});
|
|
3391
|
+
}
|
|
3392
|
+
};
|
|
3393
|
+
|
|
3394
|
+
// src/hasfocus.ts
|
|
3395
|
+
var hasfocusUpdatingProperty = createSymbolOrString("__ko_hasfocusUpdating");
|
|
3396
|
+
var hasfocusLastValue = createSymbolOrString("__ko_hasfocusLastValue");
|
|
3397
|
+
var hasfocus = {
|
|
3398
|
+
init: function(element, valueAccessor) {
|
|
3399
|
+
var handleElementFocusChange = function(isFocused) {
|
|
3400
|
+
element[hasfocusUpdatingProperty] = true;
|
|
3401
|
+
var ownerDoc = element.ownerDocument;
|
|
3402
|
+
if ("activeElement" in ownerDoc) {
|
|
3403
|
+
var active;
|
|
3404
|
+
try {
|
|
3405
|
+
active = ownerDoc.activeElement;
|
|
3406
|
+
} catch (e) {
|
|
3407
|
+
active = ownerDoc.body;
|
|
3408
|
+
}
|
|
3409
|
+
isFocused = active === element;
|
|
3410
|
+
}
|
|
3411
|
+
valueAccessor(isFocused, { onlyIfChanged: true });
|
|
3412
|
+
element[hasfocusLastValue] = isFocused;
|
|
3413
|
+
element[hasfocusUpdatingProperty] = false;
|
|
3414
|
+
};
|
|
3415
|
+
var handleElementFocusIn = handleElementFocusChange.bind(null, true);
|
|
3416
|
+
var handleElementFocusOut = handleElementFocusChange.bind(null, false);
|
|
3417
|
+
registerEventHandler(element, "focus", handleElementFocusIn);
|
|
3418
|
+
registerEventHandler(element, "focusin", handleElementFocusIn);
|
|
3419
|
+
registerEventHandler(element, "blur", handleElementFocusOut);
|
|
3420
|
+
registerEventHandler(element, "focusout", handleElementFocusOut);
|
|
3421
|
+
},
|
|
3422
|
+
update: function(element, valueAccessor) {
|
|
3423
|
+
var value2 = !!unwrap(valueAccessor());
|
|
3424
|
+
if (!element[hasfocusUpdatingProperty] && element[hasfocusLastValue] !== value2) {
|
|
3425
|
+
value2 ? element.focus() : element.blur();
|
|
3426
|
+
if (!value2 && element[hasfocusLastValue]) {
|
|
3427
|
+
element.ownerDocument.body.focus();
|
|
3428
|
+
}
|
|
3429
|
+
dependencyDetection_exports.ignore(triggerEvent, null, [element, value2 ? "focusin" : "focusout"]);
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
};
|
|
3433
|
+
|
|
3434
|
+
// src/html.ts
|
|
3435
|
+
var html = {
|
|
3436
|
+
init: function() {
|
|
3437
|
+
return {
|
|
3438
|
+
"controlsDescendantBindings": true
|
|
3439
|
+
};
|
|
3440
|
+
},
|
|
3441
|
+
update: function(element, valueAccessor) {
|
|
3442
|
+
setHtml(element, valueAccessor());
|
|
3443
|
+
},
|
|
3444
|
+
allowVirtualElements: true
|
|
3445
|
+
};
|
|
3446
|
+
|
|
3447
|
+
// src/let.ts
|
|
3448
|
+
var let_default = {
|
|
3449
|
+
init: function(element, valueAccessor, allBindings, viewModel, bindingContext2) {
|
|
3450
|
+
var innerContext = bindingContext2["extend"](valueAccessor);
|
|
3451
|
+
applyBindingsToDescendants(innerContext, element);
|
|
3452
|
+
return { "controlsDescendantBindings": true };
|
|
3453
|
+
},
|
|
3454
|
+
allowVirtualElements: true
|
|
3455
|
+
};
|
|
3456
|
+
|
|
3457
|
+
// src/options.ts
|
|
3458
|
+
var captionPlaceholder = {};
|
|
3459
|
+
var options2 = {
|
|
3460
|
+
init: function(element) {
|
|
3461
|
+
if (tagNameLower(element) !== "select") {
|
|
3462
|
+
throw new Error("options binding applies only to SELECT elements");
|
|
3463
|
+
}
|
|
3464
|
+
while (element.length > 0) {
|
|
3465
|
+
element.remove(0);
|
|
3466
|
+
}
|
|
3467
|
+
return { "controlsDescendantBindings": true };
|
|
3468
|
+
},
|
|
3469
|
+
update: function(element, valueAccessor, allBindings) {
|
|
3470
|
+
function selectedOptions2() {
|
|
3471
|
+
return arrayFilter(element.options, function(node) {
|
|
3472
|
+
return node.selected;
|
|
3473
|
+
});
|
|
3474
|
+
}
|
|
3475
|
+
var selectWasPreviouslyEmpty = element.length == 0, multiple = element.multiple, previousScrollTop = !selectWasPreviouslyEmpty && multiple ? element.scrollTop : null, unwrappedArray = unwrap(valueAccessor()), valueAllowUnset = allBindings.get("valueAllowUnset") && allBindings["has"]("value"), includeDestroyed = allBindings.get("optionsIncludeDestroyed"), arrayToDomNodeChildrenOptions = {}, captionValue, filteredArray, previousSelectedValues = [];
|
|
3476
|
+
if (!valueAllowUnset) {
|
|
3477
|
+
if (multiple) {
|
|
3478
|
+
previousSelectedValues = arrayMap(selectedOptions2(), selectExtensions.readValue);
|
|
3479
|
+
} else if (element.selectedIndex >= 0) {
|
|
3480
|
+
previousSelectedValues.push(selectExtensions.readValue(element.options[element.selectedIndex]));
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3483
|
+
if (unwrappedArray) {
|
|
3484
|
+
if (typeof unwrappedArray.length === "undefined") {
|
|
3485
|
+
unwrappedArray = [unwrappedArray];
|
|
3486
|
+
}
|
|
3487
|
+
filteredArray = arrayFilter(unwrappedArray, function(item) {
|
|
3488
|
+
return includeDestroyed || item === void 0 || item === null || !unwrap(item["_destroy"]);
|
|
3489
|
+
});
|
|
3490
|
+
if (allBindings["has"]("optionsCaption")) {
|
|
3491
|
+
captionValue = unwrap(allBindings.get("optionsCaption"));
|
|
3492
|
+
if (captionValue !== null && captionValue !== void 0) {
|
|
3493
|
+
filteredArray.unshift(captionPlaceholder);
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
} else {
|
|
3497
|
+
}
|
|
3498
|
+
function applyToObject(object2, predicate, defaultValue) {
|
|
3499
|
+
var predicateType = typeof predicate;
|
|
3500
|
+
if (predicateType === "function") {
|
|
3501
|
+
return predicate(object2);
|
|
3502
|
+
} else if (predicateType == "string") {
|
|
3503
|
+
return object2[predicate];
|
|
3504
|
+
} else {
|
|
3505
|
+
return defaultValue;
|
|
3506
|
+
}
|
|
3507
|
+
}
|
|
3508
|
+
var itemUpdate = false;
|
|
3509
|
+
function optionForArrayItem(arrayEntry, index, oldOptions) {
|
|
3510
|
+
if (oldOptions.length) {
|
|
3511
|
+
previousSelectedValues = !valueAllowUnset && oldOptions[0].selected ? [selectExtensions.readValue(oldOptions[0])] : [];
|
|
3512
|
+
itemUpdate = true;
|
|
3513
|
+
}
|
|
3514
|
+
var option = element.ownerDocument.createElement("option");
|
|
3515
|
+
if (arrayEntry === captionPlaceholder) {
|
|
3516
|
+
setTextContent(option, allBindings.get("optionsCaption"));
|
|
3517
|
+
selectExtensions.writeValue(option, void 0);
|
|
3518
|
+
} else {
|
|
3519
|
+
var optionValue = applyToObject(arrayEntry, allBindings.get("optionsValue"), arrayEntry);
|
|
3520
|
+
selectExtensions.writeValue(option, unwrap(optionValue));
|
|
3521
|
+
var optionText = applyToObject(arrayEntry, allBindings.get("optionsText"), optionValue);
|
|
3522
|
+
setTextContent(option, optionText);
|
|
3523
|
+
}
|
|
3524
|
+
return [option];
|
|
3525
|
+
}
|
|
3526
|
+
arrayToDomNodeChildrenOptions["beforeRemove"] = function(option) {
|
|
3527
|
+
element.removeChild(option);
|
|
3528
|
+
};
|
|
3529
|
+
function setSelectionCallback(arrayEntry, newOptions) {
|
|
3530
|
+
if (itemUpdate && valueAllowUnset) {
|
|
3531
|
+
selectExtensions.writeValue(element, unwrap(allBindings.get("value")), true);
|
|
3532
|
+
} else if (previousSelectedValues.length) {
|
|
3533
|
+
var isSelected = arrayIndexOf(previousSelectedValues, selectExtensions.readValue(newOptions[0])) >= 0;
|
|
3534
|
+
setOptionNodeSelectionState(newOptions[0], isSelected);
|
|
3535
|
+
if (itemUpdate && !isSelected) {
|
|
3536
|
+
dependencyDetection_exports.ignore(triggerEvent, null, [element, "change"]);
|
|
3537
|
+
}
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
var callback = setSelectionCallback;
|
|
3541
|
+
if (allBindings["has"]("optionsAfterRender") && typeof allBindings.get("optionsAfterRender") === "function") {
|
|
3542
|
+
callback = function(arrayEntry, newOptions) {
|
|
3543
|
+
setSelectionCallback(arrayEntry, newOptions);
|
|
3544
|
+
dependencyDetection_exports.ignore(allBindings.get("optionsAfterRender"), null, [newOptions[0], arrayEntry !== captionPlaceholder ? arrayEntry : void 0]);
|
|
3545
|
+
};
|
|
3546
|
+
}
|
|
3547
|
+
setDomNodeChildrenFromArrayMapping(element, filteredArray, optionForArrayItem, arrayToDomNodeChildrenOptions, callback);
|
|
3548
|
+
dependencyDetection_exports.ignore(function() {
|
|
3549
|
+
if (valueAllowUnset) {
|
|
3550
|
+
selectExtensions.writeValue(element, unwrap(allBindings.get("value")), true);
|
|
3551
|
+
} else {
|
|
3552
|
+
var selectionChanged;
|
|
3553
|
+
if (multiple) {
|
|
3554
|
+
selectionChanged = previousSelectedValues.length && selectedOptions2().length < previousSelectedValues.length;
|
|
3555
|
+
} else {
|
|
3556
|
+
selectionChanged = previousSelectedValues.length && element.selectedIndex >= 0 ? selectExtensions.readValue(element.options[element.selectedIndex]) !== previousSelectedValues[0] : previousSelectedValues.length || element.selectedIndex >= 0;
|
|
3557
|
+
}
|
|
3558
|
+
if (selectionChanged) {
|
|
3559
|
+
triggerEvent(element, "change");
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
});
|
|
3563
|
+
ensureSelectElementIsRenderedCorrectly(element);
|
|
3564
|
+
if (previousScrollTop && Math.abs(previousScrollTop - element.scrollTop) > 20) {
|
|
3565
|
+
element.scrollTop = previousScrollTop;
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
};
|
|
3569
|
+
|
|
3570
|
+
// src/selectedOptions.ts
|
|
3571
|
+
var selectedOptions = {
|
|
3572
|
+
after: ["options", "foreach"],
|
|
3573
|
+
init: function(element, valueAccessor, allBindings) {
|
|
3574
|
+
registerEventHandler(element, "change", function() {
|
|
3575
|
+
var value2 = valueAccessor(), valueToWrite = [];
|
|
3576
|
+
arrayForEach(element.getElementsByTagName("option"), function(node) {
|
|
3577
|
+
if (node.selected) {
|
|
3578
|
+
valueToWrite.push(selectExtensions.readValue(node));
|
|
3579
|
+
}
|
|
3580
|
+
});
|
|
3581
|
+
valueAccessor(valueToWrite);
|
|
3582
|
+
});
|
|
3583
|
+
},
|
|
3584
|
+
update: function(element, valueAccessor) {
|
|
3585
|
+
if (tagNameLower(element) != "select") {
|
|
3586
|
+
throw new Error("values binding applies only to SELECT elements");
|
|
3587
|
+
}
|
|
3588
|
+
var newValue = unwrap(valueAccessor()), previousScrollTop = element.scrollTop;
|
|
3589
|
+
if (newValue && typeof newValue.length === "number") {
|
|
3590
|
+
arrayForEach(element.getElementsByTagName("option"), function(node) {
|
|
3591
|
+
var isSelected = arrayIndexOf(newValue, selectExtensions.readValue(node)) >= 0;
|
|
3592
|
+
if (node.selected != isSelected) {
|
|
3593
|
+
setOptionNodeSelectionState(node, isSelected);
|
|
3594
|
+
}
|
|
3595
|
+
});
|
|
3596
|
+
}
|
|
3597
|
+
element.scrollTop = previousScrollTop;
|
|
3598
|
+
}
|
|
3599
|
+
};
|
|
3600
|
+
|
|
3601
|
+
// src/style.ts
|
|
3602
|
+
var { jQueryInstance: jQueryInstance2 } = options_default;
|
|
3603
|
+
var style = {
|
|
3604
|
+
update: function(element, valueAccessor) {
|
|
3605
|
+
var value2 = unwrap(valueAccessor() || {});
|
|
3606
|
+
objectForEach(value2, function(styleName, styleValue) {
|
|
3607
|
+
styleValue = unwrap(styleValue);
|
|
3608
|
+
if (styleValue === null || styleValue === void 0 || styleValue === false) {
|
|
3609
|
+
styleValue = "";
|
|
3610
|
+
}
|
|
3611
|
+
if (jQueryInstance2) {
|
|
3612
|
+
jQueryInstance2(element).css(styleName, styleValue);
|
|
3613
|
+
} else {
|
|
3614
|
+
styleName = styleName.replace(/-(\w)/g, (all, letter) => letter.toUpperCase());
|
|
3615
|
+
const previousStyle = element.style[styleName];
|
|
3616
|
+
element.style[styleName] = styleValue;
|
|
3617
|
+
if (styleValue !== previousStyle && element.style[styleName] === previousStyle && !isNaN(styleValue)) {
|
|
3618
|
+
element.style[styleName] = styleValue + "px";
|
|
3619
|
+
}
|
|
3620
|
+
}
|
|
3621
|
+
});
|
|
3622
|
+
}
|
|
3623
|
+
};
|
|
3624
|
+
|
|
3625
|
+
// src/submit.ts
|
|
3626
|
+
var submit = {
|
|
3627
|
+
init: function(element, valueAccessor, allBindings, viewModel, bindingContext2) {
|
|
3628
|
+
if (typeof valueAccessor() !== "function") {
|
|
3629
|
+
throw new Error("The value for a submit binding must be a function");
|
|
3630
|
+
}
|
|
3631
|
+
registerEventHandler(element, "submit", function(event) {
|
|
3632
|
+
var handlerReturnValue;
|
|
3633
|
+
var value2 = valueAccessor();
|
|
3634
|
+
try {
|
|
3635
|
+
handlerReturnValue = value2.call(bindingContext2["$data"], element);
|
|
3636
|
+
} finally {
|
|
3637
|
+
if (handlerReturnValue !== true) {
|
|
3638
|
+
if (event.preventDefault) {
|
|
3639
|
+
event.preventDefault();
|
|
3640
|
+
} else {
|
|
3641
|
+
event.returnValue = false;
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
});
|
|
3646
|
+
}
|
|
3647
|
+
};
|
|
3648
|
+
|
|
3649
|
+
// src/text.ts
|
|
3650
|
+
var text = {
|
|
3651
|
+
init: function() {
|
|
3652
|
+
return { controlsDescendantBindings: true };
|
|
3653
|
+
},
|
|
3654
|
+
update: function(element, valueAccessor) {
|
|
3655
|
+
setTextContent(element, valueAccessor());
|
|
3656
|
+
},
|
|
3657
|
+
allowVirtualElements: true
|
|
3658
|
+
};
|
|
3659
|
+
|
|
3660
|
+
// src/textInput.ts
|
|
3661
|
+
var operaVersion;
|
|
3662
|
+
var safariVersion;
|
|
3663
|
+
var firefoxVersion;
|
|
3664
|
+
var TextInput = class extends BindingHandler {
|
|
3665
|
+
get aliases() {
|
|
3666
|
+
return "textinput";
|
|
3667
|
+
}
|
|
3668
|
+
constructor(...args) {
|
|
3669
|
+
super(...args);
|
|
3670
|
+
this.previousElementValue = this.$element.value;
|
|
3671
|
+
if (options_default.debug && this.constructor._forceUpdateOn) {
|
|
3672
|
+
arrayForEach(this.constructor._forceUpdateOn, (eventName) => {
|
|
3673
|
+
if (eventName.slice(0, 5) === "after") {
|
|
3674
|
+
this.addEventListener(eventName.slice(5), "deferUpdateModel");
|
|
3675
|
+
} else {
|
|
3676
|
+
this.addEventListener(eventName, "updateModel");
|
|
3677
|
+
}
|
|
3678
|
+
});
|
|
3679
|
+
}
|
|
3680
|
+
for (const eventName of this.eventsIndicatingSyncValueChange()) {
|
|
3681
|
+
this.addEventListener(eventName, "updateModel");
|
|
3682
|
+
}
|
|
3683
|
+
for (const eventName of this.eventsIndicatingDeferValueChange()) {
|
|
3684
|
+
this.addEventListener(eventName, "deferUpdateModel");
|
|
3685
|
+
}
|
|
3686
|
+
this.computed("updateView");
|
|
3687
|
+
}
|
|
3688
|
+
eventsIndicatingSyncValueChange() {
|
|
3689
|
+
return ["input", "change", "blur"];
|
|
3690
|
+
}
|
|
3691
|
+
eventsIndicatingDeferValueChange() {
|
|
3692
|
+
return [];
|
|
3693
|
+
}
|
|
3694
|
+
updateModel(event) {
|
|
3695
|
+
const element = this.$element;
|
|
3696
|
+
clearTimeout(this.timeoutHandle);
|
|
3697
|
+
this.elementValueBeforeEvent = this.timeoutHandle = void 0;
|
|
3698
|
+
const elementValue = element.value;
|
|
3699
|
+
if (this.previousElementValue !== elementValue) {
|
|
3700
|
+
if (options_default.debug && event) {
|
|
3701
|
+
element._ko_textInputProcessedEvent = event.type;
|
|
3702
|
+
}
|
|
3703
|
+
this.previousElementValue = elementValue;
|
|
3704
|
+
this.value = elementValue;
|
|
3705
|
+
}
|
|
3706
|
+
}
|
|
3707
|
+
deferUpdateModel(event) {
|
|
3708
|
+
const element = this.$element;
|
|
3709
|
+
if (!this.timeoutHandle) {
|
|
3710
|
+
this.elementValueBeforeEvent = element.value;
|
|
3711
|
+
const handler2 = options_default.debug ? this.updateModel.bind(this, { type: event.type }) : this.updateModel;
|
|
3712
|
+
this.timeoutHandle = safeSetTimeout(handler2, 4);
|
|
3713
|
+
}
|
|
3714
|
+
}
|
|
3715
|
+
updateView() {
|
|
3716
|
+
let modelValue = unwrap(this.value);
|
|
3717
|
+
if (modelValue === null || modelValue === void 0) {
|
|
3718
|
+
modelValue = "";
|
|
3719
|
+
}
|
|
3720
|
+
if (this.elementValueBeforeEvent !== void 0 && modelValue === this.elementValueBeforeEvent) {
|
|
3721
|
+
setTimeout(this.updateView.bind(this), 4);
|
|
3722
|
+
} else if (this.$element.value !== modelValue) {
|
|
3723
|
+
this.previousElementValue = modelValue;
|
|
3724
|
+
this.$element.value = modelValue;
|
|
3725
|
+
this.previousElementValue = this.$element.value;
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
};
|
|
3729
|
+
var TextInputIE = class extends TextInput {
|
|
3730
|
+
constructor(...args) {
|
|
3731
|
+
super(...args);
|
|
3732
|
+
if (ieVersion < 11) {
|
|
3733
|
+
this.addEventListener("propertychange", (event) => event.propertyName === "value" && this.updateModel(event));
|
|
3734
|
+
}
|
|
3735
|
+
if (ieVersion >= 8 && ieVersion < 10) {
|
|
3736
|
+
this.watchForSelectionChangeEvent();
|
|
3737
|
+
this.addEventListener("dragend", "deferUpdateModel");
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3740
|
+
eventsIndicatingSyncValueChange() {
|
|
3741
|
+
return [...super.eventsIndicatingValueChange(), "keypress"];
|
|
3742
|
+
}
|
|
3743
|
+
selectionChangeHandler(event) {
|
|
3744
|
+
const target = this.activeElement;
|
|
3745
|
+
const handler2 = target && data_exports.get(target, selectionChangeHandlerName);
|
|
3746
|
+
if (handler2) {
|
|
3747
|
+
handler2(event);
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
watchForSelectionChangeEvent(element, ieUpdateModel) {
|
|
3751
|
+
const ownerDoc = element.ownerDocument;
|
|
3752
|
+
if (!data_exports.get(ownerDoc, selectionChangeRegisteredName)) {
|
|
3753
|
+
data_exports.set(ownerDoc, selectionChangeRegisteredName, true);
|
|
3754
|
+
registerEventHandler(ownerDoc, "selectionchange", this.selectionChangeHandler.bind(ownerDoc));
|
|
3755
|
+
}
|
|
3756
|
+
data_exports.set(element, selectionChangeHandlerName, handler);
|
|
3757
|
+
}
|
|
3758
|
+
};
|
|
3759
|
+
var TextInputIE9 = class extends TextInputIE {
|
|
3760
|
+
updateModel(...args) {
|
|
3761
|
+
this.deferUpdateModel(...args);
|
|
3762
|
+
}
|
|
3763
|
+
};
|
|
3764
|
+
var TextInputIE8 = class extends TextInputIE {
|
|
3765
|
+
eventsIndicatingValueChange() {
|
|
3766
|
+
return [...super.eventsIndicatingValueChange(), "keyup", "keydown"];
|
|
3767
|
+
}
|
|
3768
|
+
};
|
|
3769
|
+
var TextInputLegacySafari = class extends TextInput {
|
|
3770
|
+
eventsIndicatingDeferValueChange() {
|
|
3771
|
+
return ["keydown", "paste", "cut"];
|
|
3772
|
+
}
|
|
3773
|
+
};
|
|
3774
|
+
var TextInputLegacyOpera = class extends TextInput {
|
|
3775
|
+
eventsIndicatingDeferValueChange() {
|
|
3776
|
+
return ["keydown"];
|
|
3777
|
+
}
|
|
3778
|
+
};
|
|
3779
|
+
var TextInputLegacyFirefox = class extends TextInput {
|
|
3780
|
+
eventsIndicatingValueChange() {
|
|
3781
|
+
return [
|
|
3782
|
+
...super.eventsIndicatingSyncValueChange(),
|
|
3783
|
+
"DOMAutoComplete",
|
|
3784
|
+
"dragdrop",
|
|
3785
|
+
"drop"
|
|
3786
|
+
];
|
|
3787
|
+
}
|
|
3788
|
+
};
|
|
3789
|
+
var w2 = options_default.global;
|
|
3790
|
+
if (w2.navigator) {
|
|
3791
|
+
const parseVersion = (matches) => matches && parseFloat(matches[1]);
|
|
3792
|
+
const userAgent = w2.navigator.userAgent;
|
|
3793
|
+
const isChrome = userAgent.match(/Chrome\/([^ ]+)/);
|
|
3794
|
+
operaVersion = w2.opera && w2.opera.version && parseInt(w2.opera.version());
|
|
3795
|
+
safariVersion = parseVersion(userAgent.match(/Version\/([^ ]+) Safari/));
|
|
3796
|
+
firefoxVersion = parseVersion(userAgent.match(/Firefox\/([^ ]*)/));
|
|
3797
|
+
}
|
|
3798
|
+
var textInput = ieVersion === 8 ? TextInputIE8 : ieVersion === 9 ? TextInputIE9 : ieVersion ? TextInputIE : safariVersion && safariVersion < 5 ? TextInputLegacySafari : operaVersion < 11 ? TextInputLegacyOpera : firefoxVersion && firefoxVersion < 4 ? TextInputLegacyFirefox : TextInput;
|
|
3799
|
+
|
|
3800
|
+
// src/uniqueName.ts
|
|
3801
|
+
var uniqueName = {
|
|
3802
|
+
init: function(element, valueAccessor) {
|
|
3803
|
+
if (valueAccessor()) {
|
|
3804
|
+
var name = "ko_unique_" + ++uniqueName.currentIndex;
|
|
3805
|
+
setElementName(element, name);
|
|
3806
|
+
}
|
|
3807
|
+
},
|
|
3808
|
+
currentIndex: 0
|
|
3809
|
+
};
|
|
3810
|
+
|
|
3811
|
+
// src/value.ts
|
|
3812
|
+
var value = class extends BindingHandler {
|
|
3813
|
+
static get after() {
|
|
3814
|
+
return ["options", "foreach", "template"];
|
|
3815
|
+
}
|
|
3816
|
+
constructor(...args) {
|
|
3817
|
+
super(...args);
|
|
3818
|
+
if (this.isCheckboxOrRadio) {
|
|
3819
|
+
applyBindingAccessorsToNode(this.$element, { checkedValue: this.valueAccessor });
|
|
3820
|
+
return;
|
|
3821
|
+
}
|
|
3822
|
+
this.propertyChangedFired = false;
|
|
3823
|
+
this.elementValueBeforeEvent = null;
|
|
3824
|
+
if (this.ieAutoCompleteHackNeeded) {
|
|
3825
|
+
this.addEventListener("propertyChange", () => this.propertyChangedFired = true);
|
|
3826
|
+
this.addEventListener("focus", () => this.propertyChangedFired = false);
|
|
3827
|
+
this.addEventListener("blur", () => this.propertyChangeFired && this.valueUpdateHandler());
|
|
3828
|
+
}
|
|
3829
|
+
arrayForEach(this.eventsToCatch, (eventName) => this.registerEvent(eventName));
|
|
3830
|
+
if (this.isInput && this.$element.type === "file") {
|
|
3831
|
+
this.updateFromModel = this.updateFromModelForFile;
|
|
3832
|
+
} else {
|
|
3833
|
+
this.updateFromModel = this.updateFromModelForValue;
|
|
3834
|
+
}
|
|
3835
|
+
this.computed("updateFromModel");
|
|
3836
|
+
}
|
|
3837
|
+
get eventsToCatch() {
|
|
3838
|
+
const requestedEventsToCatch = this.allBindings.get("valueUpdate");
|
|
3839
|
+
const requestedEventsArray = typeof requestedEventsToCatch === "string" ? [requestedEventsToCatch] : requestedEventsToCatch || [];
|
|
3840
|
+
return [.../* @__PURE__ */ new Set(["change", ...requestedEventsArray])];
|
|
3841
|
+
}
|
|
3842
|
+
get isInput() {
|
|
3843
|
+
return tagNameLower(this.$element) === "input";
|
|
3844
|
+
}
|
|
3845
|
+
get isCheckboxOrRadio() {
|
|
3846
|
+
const e = this.$element;
|
|
3847
|
+
return this.isInput && (e.type == "checkbox" || e.type == "radio");
|
|
3848
|
+
}
|
|
3849
|
+
get ieAutoCompleteHackNeeded() {
|
|
3850
|
+
return ieVersion && isInputElement && this.$element.type == "text" && this.$element.autocomplete != "off" && (!this.$element.form || this.$element.form.autocomplete != "off");
|
|
3851
|
+
}
|
|
3852
|
+
valueUpdateHandler() {
|
|
3853
|
+
this.elementValueBeforeEvent = null;
|
|
3854
|
+
this.propertyChangedFired = false;
|
|
3855
|
+
this.value = selectExtensions.readValue(this.$element);
|
|
3856
|
+
}
|
|
3857
|
+
registerEvent(eventName) {
|
|
3858
|
+
var handler2 = this.valueUpdateHandler.bind(this);
|
|
3859
|
+
if (stringStartsWith(eventName, "after")) {
|
|
3860
|
+
handler2 = () => {
|
|
3861
|
+
this.elementValueBeforeEvent = selectExtensions.readValue(this.$element);
|
|
3862
|
+
safeSetTimeout(this.valueUpdateHandler.bind(this), 0);
|
|
3863
|
+
};
|
|
3864
|
+
eventName = eventName.substring(5);
|
|
3865
|
+
}
|
|
3866
|
+
this.addEventListener(eventName, handler2);
|
|
3867
|
+
}
|
|
3868
|
+
updateFromModelForFile() {
|
|
3869
|
+
var newValue = unwrap(this.value);
|
|
3870
|
+
if (newValue === null || newValue === void 0 || newValue === "") {
|
|
3871
|
+
this.$element.value = "";
|
|
3872
|
+
} else {
|
|
3873
|
+
dependencyDetection_exports.ignore(this.valueUpdateHandler, this);
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
updateFromModelForValue() {
|
|
3877
|
+
const element = this.$element;
|
|
3878
|
+
var newValue = unwrap(this.value);
|
|
3879
|
+
var elementValue = selectExtensions.readValue(element);
|
|
3880
|
+
if (this.elementValueBeforeEvent !== null && newValue === this.elementValueBeforeEvent) {
|
|
3881
|
+
safeSetTimeout(this.updateFromModel.bind(this), 0);
|
|
3882
|
+
return;
|
|
3883
|
+
}
|
|
3884
|
+
if (newValue === elementValue && elementValue !== void 0) {
|
|
3885
|
+
return;
|
|
3886
|
+
}
|
|
3887
|
+
if (tagNameLower(element) === "select") {
|
|
3888
|
+
const allowUnset = this.allBindings.get("valueAllowUnset");
|
|
3889
|
+
selectExtensions.writeValue(element, newValue, allowUnset);
|
|
3890
|
+
if (!allowUnset && newValue !== selectExtensions.readValue(element)) {
|
|
3891
|
+
dependencyDetection_exports.ignore(this.valueUpdateHandler, this);
|
|
3892
|
+
}
|
|
3893
|
+
} else {
|
|
3894
|
+
selectExtensions.writeValue(element, newValue);
|
|
3895
|
+
}
|
|
3896
|
+
}
|
|
3897
|
+
};
|
|
3898
|
+
|
|
3899
|
+
// src/visible.ts
|
|
3900
|
+
var visible = {
|
|
3901
|
+
update: function(element, valueAccessor) {
|
|
3902
|
+
var value2 = unwrap(valueAccessor());
|
|
3903
|
+
var isCurrentlyVisible = !(element.style.display === "none");
|
|
3904
|
+
if (value2 && !isCurrentlyVisible) {
|
|
3905
|
+
element.style.display = "";
|
|
3906
|
+
} else if (!value2 && isCurrentlyVisible) {
|
|
3907
|
+
element.style.display = "none";
|
|
3908
|
+
}
|
|
3909
|
+
}
|
|
3910
|
+
};
|
|
3911
|
+
var hidden = {
|
|
3912
|
+
update: function(element, valueAccessor) {
|
|
3913
|
+
visible.update.call(this, element, () => !unwrap(valueAccessor()));
|
|
3914
|
+
}
|
|
3915
|
+
};
|
|
3916
|
+
|
|
3917
|
+
// src/using.ts
|
|
3918
|
+
var using = {
|
|
3919
|
+
init: function(element, valueAccessor, allBindings, viewModel, bindingContext2) {
|
|
3920
|
+
var innerContext = bindingContext2.createChildContext(valueAccessor);
|
|
3921
|
+
applyBindingsToDescendants(innerContext, element);
|
|
3922
|
+
return { controlsDescendantBindings: true };
|
|
3923
|
+
},
|
|
3924
|
+
allowVirtualElements: true
|
|
3925
|
+
};
|
|
3926
|
+
|
|
3927
|
+
// src/index.ts
|
|
3928
|
+
var bindings = {
|
|
3929
|
+
attr,
|
|
3930
|
+
checked,
|
|
3931
|
+
checkedValue,
|
|
3932
|
+
click,
|
|
3933
|
+
css,
|
|
3934
|
+
"class": css,
|
|
3935
|
+
descendantsComplete: DescendantsCompleteHandler,
|
|
3936
|
+
enable,
|
|
3937
|
+
"event": eventHandler,
|
|
3938
|
+
disable,
|
|
3939
|
+
hasfocus,
|
|
3940
|
+
hasFocus: hasfocus,
|
|
3941
|
+
hidden,
|
|
3942
|
+
html,
|
|
3943
|
+
"let": let_default,
|
|
3944
|
+
on: onHandler,
|
|
3945
|
+
options: options2,
|
|
3946
|
+
selectedOptions,
|
|
3947
|
+
style,
|
|
3948
|
+
submit,
|
|
3949
|
+
text,
|
|
3950
|
+
textInput,
|
|
3951
|
+
textinput: textInput,
|
|
3952
|
+
uniqueName,
|
|
3953
|
+
using,
|
|
3954
|
+
value,
|
|
3955
|
+
visible
|
|
3956
|
+
};
|