@tko/binding.core 4.0.0-beta1.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attr.js +10 -14
- package/dist/attr.js.map +2 -2
- package/dist/checked.js +19 -28
- package/dist/checked.js.map +3 -3
- package/dist/click.js +4 -5
- package/dist/click.js.map +2 -2
- package/dist/css.js +6 -12
- package/dist/css.js.map +2 -2
- package/dist/descendantsComplete.js +3 -4
- package/dist/descendantsComplete.js.map +2 -2
- package/dist/enableDisable.js +6 -7
- package/dist/enableDisable.js.map +2 -2
- package/dist/event.js +7 -8
- package/dist/event.js.map +3 -3
- package/dist/hasfocus.js +23 -22
- package/dist/hasfocus.js.map +2 -2
- package/dist/html.js +8 -8
- package/dist/html.js.map +2 -2
- package/dist/index.cjs +1037 -863
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +6 -5
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +6 -5
- package/dist/index.mjs.map +2 -2
- package/dist/let.js +6 -7
- package/dist/let.js.map +2 -2
- package/dist/options.js +39 -26
- package/dist/options.js.map +2 -2
- package/dist/selectedOptions.js +8 -9
- package/dist/selectedOptions.js.map +2 -2
- package/dist/style.js +8 -13
- package/dist/style.js.map +2 -2
- package/dist/submit.js +7 -8
- package/dist/submit.js.map +2 -2
- package/dist/text.js +4 -5
- package/dist/text.js.map +2 -2
- package/dist/textInput.js +24 -59
- package/dist/textInput.js.map +2 -2
- package/dist/uniqueName.js +5 -7
- package/dist/uniqueName.js.map +2 -2
- package/dist/using.js +6 -7
- package/dist/using.js.map +2 -2
- package/dist/value.js +17 -23
- package/dist/value.js.map +2 -2
- package/dist/visible.js +7 -8
- package/dist/visible.js.map +2 -2
- package/package.json +6 -7
- package/LICENSE +0 -22
- package/dist/test-helper.js +0 -14
- package/dist/test-helper.js.map +0 -7
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 CommonJS
|
|
2
|
+
"use strict";
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
8
|
+
var __typeError = (msg) => {
|
|
9
|
+
throw TypeError(msg);
|
|
10
|
+
};
|
|
6
11
|
var __export = (target, all) => {
|
|
7
12
|
for (var name in all)
|
|
8
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,19 +21,71 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
21
|
return to;
|
|
17
22
|
};
|
|
18
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var __async = (__this, __arguments, generator) => {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
var fulfilled = (value2) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.next(value2));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var rejected = (value2) => {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.throw(value2));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __await = function(promise, isYieldStar) {
|
|
45
|
+
this[0] = promise;
|
|
46
|
+
this[1] = isYieldStar;
|
|
47
|
+
};
|
|
48
|
+
var __yieldStar = (value2) => {
|
|
49
|
+
var obj = value2[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
|
|
50
|
+
if (obj == null) {
|
|
51
|
+
obj = value2[__knownSymbol("iterator")]();
|
|
52
|
+
method = (k) => it[k] = (x) => obj[k](x);
|
|
53
|
+
} else {
|
|
54
|
+
obj = obj.call(value2);
|
|
55
|
+
method = (k) => it[k] = (v) => {
|
|
56
|
+
if (isAwait) {
|
|
57
|
+
isAwait = false;
|
|
58
|
+
if (k === "throw") throw v;
|
|
59
|
+
return v;
|
|
60
|
+
}
|
|
61
|
+
isAwait = true;
|
|
62
|
+
return {
|
|
63
|
+
done: false,
|
|
64
|
+
value: new __await(new Promise((resolve) => {
|
|
65
|
+
var x = obj[k](v);
|
|
66
|
+
if (!(x instanceof Object)) __typeError("Object expected");
|
|
67
|
+
resolve(x);
|
|
68
|
+
}), 1)
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
|
|
73
|
+
throw x;
|
|
74
|
+
}, "return" in obj && method("return"), it;
|
|
75
|
+
};
|
|
19
76
|
|
|
20
77
|
// index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
78
|
+
var index_exports = {};
|
|
79
|
+
__export(index_exports, {
|
|
23
80
|
bindings: () => bindings
|
|
24
81
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
82
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
83
|
|
|
27
84
|
// ../utils/dist/array.js
|
|
28
85
|
var { isArray } = Array;
|
|
29
|
-
function arrayForEach(array, action,
|
|
86
|
+
function arrayForEach(array, action, actionOwner) {
|
|
30
87
|
if (arguments.length > 2) {
|
|
31
|
-
action = action.bind(
|
|
88
|
+
action = action.bind(actionOwner);
|
|
32
89
|
}
|
|
33
90
|
for (let i = 0, j = array.length; i < j; ++i) {
|
|
34
91
|
action(array[i], i, array);
|
|
@@ -40,23 +97,23 @@ function arrayIndexOf(array, item) {
|
|
|
40
97
|
function arrayFirst(array, predicate, predicateOwner) {
|
|
41
98
|
return (isArray(array) ? array : [...array]).find(predicate, predicateOwner);
|
|
42
99
|
}
|
|
43
|
-
function arrayMap(array
|
|
100
|
+
function arrayMap(array, mapping, thisArg) {
|
|
44
101
|
if (arguments.length > 2) {
|
|
45
102
|
mapping = mapping.bind(thisArg);
|
|
46
103
|
}
|
|
47
104
|
return array === null ? [] : Array.from(array, mapping);
|
|
48
105
|
}
|
|
49
106
|
function arrayRemoveItem(array, itemToRemove) {
|
|
50
|
-
|
|
107
|
+
const index = arrayIndexOf(array, itemToRemove);
|
|
51
108
|
if (index > 0) {
|
|
52
109
|
array.splice(index, 1);
|
|
53
110
|
} else if (index === 0) {
|
|
54
111
|
array.shift();
|
|
55
112
|
}
|
|
56
113
|
}
|
|
57
|
-
function arrayFilter(array, predicate,
|
|
114
|
+
function arrayFilter(array, predicate, predicateOwner) {
|
|
58
115
|
if (arguments.length > 2) {
|
|
59
|
-
predicate = predicate.bind(
|
|
116
|
+
predicate = predicate.bind(predicateOwner);
|
|
60
117
|
}
|
|
61
118
|
return array === null ? [] : (isArray(array) ? array : [...array]).filter(predicate);
|
|
62
119
|
}
|
|
@@ -64,14 +121,14 @@ function arrayPushAll(array, valuesToPush) {
|
|
|
64
121
|
if (isArray(valuesToPush)) {
|
|
65
122
|
array.push.apply(array, valuesToPush);
|
|
66
123
|
} else {
|
|
67
|
-
for (
|
|
124
|
+
for (let i = 0, j = valuesToPush.length; i < j; i++) {
|
|
68
125
|
array.push(valuesToPush[i]);
|
|
69
126
|
}
|
|
70
127
|
}
|
|
71
128
|
return array;
|
|
72
129
|
}
|
|
73
130
|
function addOrRemoveItem(array, value2, included) {
|
|
74
|
-
|
|
131
|
+
const existingEntryIndex = arrayIndexOf(typeof array.peek === "function" ? array.peek() : array, value2);
|
|
75
132
|
if (existingEntryIndex < 0) {
|
|
76
133
|
if (included) {
|
|
77
134
|
array.push(value2);
|
|
@@ -87,7 +144,7 @@ function makeArray(arrayLikeObject) {
|
|
|
87
144
|
}
|
|
88
145
|
function findMovesInArrayComparison(left, right, limitFailedCompares) {
|
|
89
146
|
if (left.length && right.length) {
|
|
90
|
-
|
|
147
|
+
let failedCompares, l, r, leftItem, rightItem;
|
|
91
148
|
for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {
|
|
92
149
|
for (r = 0; rightItem = right[r]; ++r) {
|
|
93
150
|
if (leftItem.value === rightItem.value) {
|
|
@@ -115,10 +172,10 @@ function compareArrays(oldArray, newArray, options3) {
|
|
|
115
172
|
}
|
|
116
173
|
}
|
|
117
174
|
function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options3) {
|
|
118
|
-
|
|
175
|
+
let myMin = Math.min, myMax = Math.max, editDistanceMatrix = new Array(), smlIndex, smlIndexMax = smlArray.length, bigIndex, bigIndexMax = bigArray.length, compareRange = bigIndexMax - smlIndexMax || 1, maxDistance = smlIndexMax + bigIndexMax + 1, thisRow, lastRow, bigIndexMaxForRow, bigIndexMinForRow;
|
|
119
176
|
for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {
|
|
120
177
|
lastRow = thisRow;
|
|
121
|
-
editDistanceMatrix.push(thisRow =
|
|
178
|
+
editDistanceMatrix.push(thisRow = new Array());
|
|
122
179
|
bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);
|
|
123
180
|
bigIndexMinForRow = myMax(0, smlIndex - 1);
|
|
124
181
|
for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {
|
|
@@ -129,35 +186,38 @@ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusN
|
|
|
129
186
|
} else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1]) {
|
|
130
187
|
thisRow[bigIndex] = lastRow[bigIndex - 1];
|
|
131
188
|
} else {
|
|
132
|
-
|
|
133
|
-
|
|
189
|
+
const northDistance = lastRow[bigIndex] || maxDistance;
|
|
190
|
+
const westDistance = thisRow[bigIndex - 1] || maxDistance;
|
|
134
191
|
thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;
|
|
135
192
|
}
|
|
136
193
|
}
|
|
137
194
|
}
|
|
138
|
-
|
|
195
|
+
let editScript = new Array(), meMinusOne, notInSml = new Array(), notInBig = new Array();
|
|
139
196
|
for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex; ) {
|
|
140
197
|
meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;
|
|
141
198
|
if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {
|
|
142
|
-
notInSml.push(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
199
|
+
notInSml.push(
|
|
200
|
+
editScript[editScript.length] = {
|
|
201
|
+
// added
|
|
202
|
+
status: statusNotInSml,
|
|
203
|
+
value: bigArray[--bigIndex],
|
|
204
|
+
index: bigIndex
|
|
205
|
+
}
|
|
206
|
+
);
|
|
147
207
|
} else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {
|
|
148
|
-
notInBig.push(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
208
|
+
notInBig.push(
|
|
209
|
+
editScript[editScript.length] = {
|
|
210
|
+
// deleted
|
|
211
|
+
status: statusNotInBig,
|
|
212
|
+
value: smlArray[--smlIndex],
|
|
213
|
+
index: smlIndex
|
|
214
|
+
}
|
|
215
|
+
);
|
|
153
216
|
} else {
|
|
154
217
|
--bigIndex;
|
|
155
218
|
--smlIndex;
|
|
156
|
-
if (!options3.sparse) {
|
|
157
|
-
editScript.push({
|
|
158
|
-
"status": "retained",
|
|
159
|
-
"value": bigArray[bigIndex]
|
|
160
|
-
});
|
|
219
|
+
if (!(options3 == null ? void 0 : options3.sparse)) {
|
|
220
|
+
editScript.push({ status: "retained", value: bigArray[bigIndex] });
|
|
161
221
|
}
|
|
162
222
|
}
|
|
163
223
|
}
|
|
@@ -166,40 +226,79 @@ function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusN
|
|
|
166
226
|
}
|
|
167
227
|
|
|
168
228
|
// ../utils/dist/options.js
|
|
169
|
-
var
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
229
|
+
var Options = class {
|
|
230
|
+
constructor() {
|
|
231
|
+
this.bindingStringPreparsers = [];
|
|
232
|
+
this.knockoutInstance = null;
|
|
233
|
+
this.deferUpdates = false;
|
|
234
|
+
this.useOnlyNativeEvents = true;
|
|
235
|
+
this.useTemplateTag = true;
|
|
236
|
+
this.protoProperty = "__ko_proto__";
|
|
237
|
+
this.defaultBindingAttribute = "data-bind";
|
|
238
|
+
this.allowVirtualElements = true;
|
|
239
|
+
this.bindingGlobals = /* @__PURE__ */ Object.create(null);
|
|
240
|
+
this.createChildContextWithAs = false;
|
|
241
|
+
this.disableJQueryUsage = false;
|
|
242
|
+
this.Promise = globalThis.Promise;
|
|
243
|
+
this.taskScheduler = null;
|
|
244
|
+
this.debug = false;
|
|
245
|
+
this.templateSizeLimit = 4096;
|
|
246
|
+
this.allowScriptTagsInTemplates = false;
|
|
247
|
+
this._sanitizeWarningLogged = false;
|
|
248
|
+
this.global = globalThis;
|
|
249
|
+
this.document = globalThis.document;
|
|
250
|
+
this.filters = {};
|
|
251
|
+
this.includeDestroyed = false;
|
|
252
|
+
this.foreachHidesDestroyed = false;
|
|
253
|
+
}
|
|
254
|
+
get jQuery() {
|
|
255
|
+
var _a;
|
|
256
|
+
if (this.disableJQueryUsage) return;
|
|
257
|
+
return (_a = this._jQuery) != null ? _a : globalThis.jQuery;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Set jQuery manuall to be used by TKO.
|
|
261
|
+
* @param jQuery If jQuery set to undefined, TKO will not use jQuery and this.disableJQueryUsage to true.
|
|
262
|
+
*/
|
|
263
|
+
set jQuery(jQuery2) {
|
|
264
|
+
if (!jQuery2) {
|
|
265
|
+
this.disableJQueryUsage = true;
|
|
266
|
+
this._jQuery = void 0;
|
|
267
|
+
} else {
|
|
268
|
+
this._jQuery = jQuery2;
|
|
269
|
+
this.disableJQueryUsage = false;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Sanitize HTML templates before parsing them. Default is a no-op.
|
|
274
|
+
* Please configure something like DOMPurify or validator.js for your environment.
|
|
275
|
+
* @param html HTML string to be sanitized
|
|
276
|
+
* @returns Sanitized HTML string
|
|
277
|
+
*/
|
|
278
|
+
sanitizeHtmlTemplate(html2) {
|
|
279
|
+
if (!this._sanitizeWarningLogged) {
|
|
280
|
+
console.warn(
|
|
281
|
+
"WARNING -- You don't have a HTML sanitizer configured. Please configure options.sanitizeHtmlTemplate to avoid XSS vulnerabilities."
|
|
282
|
+
);
|
|
283
|
+
this._sanitizeWarningLogged = true;
|
|
284
|
+
}
|
|
285
|
+
return html2;
|
|
286
|
+
}
|
|
287
|
+
onError(e, throws = true) {
|
|
288
|
+
if (throws) throw e;
|
|
289
|
+
return e;
|
|
290
|
+
}
|
|
291
|
+
set(name, value2) {
|
|
292
|
+
this[name] = value2;
|
|
293
|
+
}
|
|
294
|
+
// Overload getBindingHandler to have a custom lookup function.
|
|
295
|
+
getBindingHandler(key) {
|
|
296
|
+
return null;
|
|
196
297
|
}
|
|
197
|
-
|
|
198
|
-
Object.defineProperty(options, "$", {
|
|
199
|
-
get: function() {
|
|
200
|
-
return options.jQuery;
|
|
298
|
+
cleanExternalData(node, callback) {
|
|
201
299
|
}
|
|
202
|
-
}
|
|
300
|
+
};
|
|
301
|
+
var options = new Options();
|
|
203
302
|
var options_default = options;
|
|
204
303
|
|
|
205
304
|
// ../utils/dist/error.js
|
|
@@ -220,13 +319,13 @@ function deferError(error) {
|
|
|
220
319
|
throw error;
|
|
221
320
|
}, 0);
|
|
222
321
|
}
|
|
223
|
-
function safeSetTimeout(
|
|
224
|
-
return setTimeout(catchFunctionErrors(
|
|
322
|
+
function safeSetTimeout(handler, timeout) {
|
|
323
|
+
return setTimeout(catchFunctionErrors(handler), timeout);
|
|
225
324
|
}
|
|
226
325
|
|
|
227
326
|
// ../utils/dist/async.js
|
|
228
327
|
function throttle(callback, timeout) {
|
|
229
|
-
|
|
328
|
+
let timeoutInstance;
|
|
230
329
|
return function(...args) {
|
|
231
330
|
if (!timeoutInstance) {
|
|
232
331
|
timeoutInstance = safeSetTimeout(function() {
|
|
@@ -237,25 +336,13 @@ function throttle(callback, timeout) {
|
|
|
237
336
|
};
|
|
238
337
|
}
|
|
239
338
|
function debounce(callback, timeout) {
|
|
240
|
-
|
|
339
|
+
let timeoutInstance;
|
|
241
340
|
return function(...args) {
|
|
242
341
|
clearTimeout(timeoutInstance);
|
|
243
342
|
timeoutInstance = safeSetTimeout(() => callback(...args), timeout);
|
|
244
343
|
};
|
|
245
344
|
}
|
|
246
345
|
|
|
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
346
|
// ../utils/dist/object.js
|
|
260
347
|
function hasOwnProperty(obj, propName) {
|
|
261
348
|
return Object.prototype.hasOwnProperty.call(obj, propName);
|
|
@@ -268,8 +355,9 @@ function isObjectLike(obj) {
|
|
|
268
355
|
}
|
|
269
356
|
function extend(target, source) {
|
|
270
357
|
if (source) {
|
|
271
|
-
for (
|
|
358
|
+
for (const prop of Object.keys(source)) {
|
|
272
359
|
if (hasOwnProperty(source, prop)) {
|
|
360
|
+
;
|
|
273
361
|
target[prop] = source[prop];
|
|
274
362
|
}
|
|
275
363
|
}
|
|
@@ -277,7 +365,7 @@ function extend(target, source) {
|
|
|
277
365
|
return target;
|
|
278
366
|
}
|
|
279
367
|
function objectForEach(obj, action) {
|
|
280
|
-
for (
|
|
368
|
+
for (const prop in obj) {
|
|
281
369
|
if (hasOwnProperty(obj, prop)) {
|
|
282
370
|
action(prop, obj[prop]);
|
|
283
371
|
}
|
|
@@ -290,8 +378,8 @@ function objectMap(source, mapping, thisArg) {
|
|
|
290
378
|
if (arguments.length > 2) {
|
|
291
379
|
mapping = mapping.bind(thisArg);
|
|
292
380
|
}
|
|
293
|
-
|
|
294
|
-
for (
|
|
381
|
+
const target = {};
|
|
382
|
+
for (const prop in source) {
|
|
295
383
|
if (hasOwnProperty(source, prop)) {
|
|
296
384
|
target[prop] = mapping(source[prop], prop, source);
|
|
297
385
|
}
|
|
@@ -337,7 +425,7 @@ function createSymbolOrString(identifier) {
|
|
|
337
425
|
// ../utils/dist/css.js
|
|
338
426
|
var cssClassNameRegex = /\S+/g;
|
|
339
427
|
function toggleDomNodeCssClass(node, classNames, shouldHaveClass) {
|
|
340
|
-
|
|
428
|
+
let addOrRemoveFn;
|
|
341
429
|
if (!classNames) {
|
|
342
430
|
return;
|
|
343
431
|
}
|
|
@@ -353,34 +441,32 @@ function toggleDomNodeCssClass(node, classNames, shouldHaveClass) {
|
|
|
353
441
|
}
|
|
354
442
|
}
|
|
355
443
|
function toggleObjectClassPropertyString(obj, prop, classNames, shouldHaveClass) {
|
|
356
|
-
|
|
444
|
+
const currentClassNames = obj[prop].match(cssClassNameRegex) || [];
|
|
357
445
|
arrayForEach(classNames.match(cssClassNameRegex), function(className) {
|
|
358
446
|
addOrRemoveItem(currentClassNames, className, shouldHaveClass);
|
|
359
447
|
});
|
|
360
448
|
obj[prop] = currentClassNames.join(" ");
|
|
361
449
|
}
|
|
362
450
|
|
|
363
|
-
// ../utils/dist/jquery.js
|
|
364
|
-
var jQueryInstance = options_default.global && options_default.global.jQuery;
|
|
365
|
-
|
|
366
451
|
// ../utils/dist/dom/info.js
|
|
367
452
|
function domNodeIsContainedBy(node, containedByNode) {
|
|
368
453
|
if (node === containedByNode) {
|
|
369
454
|
return true;
|
|
370
455
|
}
|
|
371
|
-
if (node.nodeType ===
|
|
456
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
|
372
457
|
return false;
|
|
373
458
|
}
|
|
374
459
|
if (containedByNode.contains) {
|
|
375
|
-
return containedByNode.contains(node.nodeType !==
|
|
460
|
+
return containedByNode.contains(node.nodeType !== Node.ELEMENT_NODE ? node.parentNode : node);
|
|
376
461
|
}
|
|
377
462
|
if (containedByNode.compareDocumentPosition) {
|
|
378
463
|
return (containedByNode.compareDocumentPosition(node) & 16) == 16;
|
|
379
464
|
}
|
|
380
|
-
|
|
381
|
-
|
|
465
|
+
let parentNode = node;
|
|
466
|
+
while (parentNode && parentNode != containedByNode) {
|
|
467
|
+
parentNode = parentNode.parentNode;
|
|
382
468
|
}
|
|
383
|
-
return !!
|
|
469
|
+
return !!parentNode;
|
|
384
470
|
}
|
|
385
471
|
function domNodeIsAttachedToDocument(node) {
|
|
386
472
|
return domNodeIsContainedBy(node, node.ownerDocument.documentElement);
|
|
@@ -392,6 +478,88 @@ function tagNameLower(element) {
|
|
|
392
478
|
return element && element.tagName && element.tagName.toLowerCase();
|
|
393
479
|
}
|
|
394
480
|
|
|
481
|
+
// ../utils/dist/dom/event.js
|
|
482
|
+
var knownEvents = {};
|
|
483
|
+
var knownEventTypesByEventName = {};
|
|
484
|
+
knownEvents["UIEvents"] = ["keyup", "keydown", "keypress"];
|
|
485
|
+
knownEvents["MouseEvents"] = [
|
|
486
|
+
"click",
|
|
487
|
+
"dblclick",
|
|
488
|
+
"mousedown",
|
|
489
|
+
"mouseup",
|
|
490
|
+
"mousemove",
|
|
491
|
+
"mouseover",
|
|
492
|
+
"mouseout",
|
|
493
|
+
"mouseenter",
|
|
494
|
+
"mouseleave"
|
|
495
|
+
];
|
|
496
|
+
objectForEach(knownEvents, function(eventType, knownEventsForType) {
|
|
497
|
+
if (knownEventsForType.length) {
|
|
498
|
+
for (let i = 0, j = knownEventsForType.length; i < j; i++) {
|
|
499
|
+
knownEventTypesByEventName[knownEventsForType[i]] = eventType;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
function isClickOnCheckableElement(element, eventType) {
|
|
504
|
+
if (tagNameLower(element) !== "input" || !element.type) return false;
|
|
505
|
+
if (eventType.toLowerCase() != "click") return false;
|
|
506
|
+
const inputType = element.type;
|
|
507
|
+
return inputType == "checkbox" || inputType == "radio";
|
|
508
|
+
}
|
|
509
|
+
function registerEventHandler(element, eventType, handler, eventOptions = false) {
|
|
510
|
+
const wrappedHandler = catchFunctionErrors(handler);
|
|
511
|
+
const mustUseNative = Boolean(eventOptions);
|
|
512
|
+
const jQuery2 = options_default.jQuery;
|
|
513
|
+
if (!options_default.useOnlyNativeEvents && !mustUseNative && jQuery2) {
|
|
514
|
+
jQuery2(element).on(eventType, wrappedHandler);
|
|
515
|
+
} else if (typeof element.addEventListener === "function") {
|
|
516
|
+
element.addEventListener(eventType, wrappedHandler, eventOptions);
|
|
517
|
+
} else {
|
|
518
|
+
throw new Error("Browser doesn't support addEventListener");
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
function hasClick(element) {
|
|
522
|
+
return typeof element.click === "function";
|
|
523
|
+
}
|
|
524
|
+
function triggerEvent(element, eventType) {
|
|
525
|
+
if (!(element && element.nodeType)) {
|
|
526
|
+
throw new Error("element must be a DOM node when calling triggerEvent");
|
|
527
|
+
}
|
|
528
|
+
const useClickWorkaround = isClickOnCheckableElement(element, eventType);
|
|
529
|
+
if (!options_default.useOnlyNativeEvents && options_default.jQuery && !useClickWorkaround) {
|
|
530
|
+
options_default.jQuery(element).trigger(eventType);
|
|
531
|
+
} else if (typeof document.createEvent === "function") {
|
|
532
|
+
if (typeof element.dispatchEvent === "function") {
|
|
533
|
+
const eventCategory = knownEventTypesByEventName[eventType] || "HTMLEvents";
|
|
534
|
+
const event = document.createEvent(eventCategory);
|
|
535
|
+
event.initEvent(
|
|
536
|
+
eventType,
|
|
537
|
+
true,
|
|
538
|
+
true,
|
|
539
|
+
options_default.global,
|
|
540
|
+
0,
|
|
541
|
+
0,
|
|
542
|
+
0,
|
|
543
|
+
0,
|
|
544
|
+
0,
|
|
545
|
+
false,
|
|
546
|
+
false,
|
|
547
|
+
false,
|
|
548
|
+
false,
|
|
549
|
+
0,
|
|
550
|
+
element
|
|
551
|
+
);
|
|
552
|
+
element.dispatchEvent(event);
|
|
553
|
+
} else {
|
|
554
|
+
throw new Error("The supplied element doesn't support dispatchEvent");
|
|
555
|
+
}
|
|
556
|
+
} else if (useClickWorkaround && hasClick(element)) {
|
|
557
|
+
element.click();
|
|
558
|
+
} else {
|
|
559
|
+
throw new Error("Browser doesn't support triggering events");
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
395
563
|
// ../utils/dist/dom/data.js
|
|
396
564
|
var data_exports = {};
|
|
397
565
|
__export(data_exports, {
|
|
@@ -401,64 +569,53 @@ __export(data_exports, {
|
|
|
401
569
|
nextKey: () => nextKey,
|
|
402
570
|
set: () => set
|
|
403
571
|
});
|
|
404
|
-
var datastoreTime = new Date().getTime();
|
|
572
|
+
var datastoreTime = (/* @__PURE__ */ new Date()).getTime();
|
|
405
573
|
var dataStoreKeyExpandoPropertyName = `__ko__${datastoreTime}`;
|
|
406
|
-
var dataStoreSymbol = Symbol("Knockout data");
|
|
407
|
-
var dataStore;
|
|
574
|
+
var dataStoreSymbol = /* @__PURE__ */ Symbol("Knockout data");
|
|
408
575
|
var uniqueId = 0;
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
},
|
|
417
|
-
clear(node) {
|
|
418
|
-
if (node[dataStoreSymbol]) {
|
|
419
|
-
delete node[dataStoreSymbol];
|
|
420
|
-
return true;
|
|
421
|
-
}
|
|
422
|
-
return false;
|
|
576
|
+
function isSafeKey(key) {
|
|
577
|
+
return key !== "__proto__" && key !== "constructor" && key !== "prototype";
|
|
578
|
+
}
|
|
579
|
+
function getDataForNode(node, createIfNotFound) {
|
|
580
|
+
let dataForNode = node[dataStoreSymbol];
|
|
581
|
+
if (!dataForNode && createIfNotFound) {
|
|
582
|
+
dataForNode = node[dataStoreSymbol] = {};
|
|
423
583
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
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;
|
|
584
|
+
return dataForNode;
|
|
585
|
+
}
|
|
586
|
+
function clear(node) {
|
|
587
|
+
if (node[dataStoreSymbol]) {
|
|
588
|
+
delete node[dataStoreSymbol];
|
|
589
|
+
return true;
|
|
446
590
|
}
|
|
447
|
-
|
|
448
|
-
|
|
591
|
+
return false;
|
|
592
|
+
}
|
|
449
593
|
function nextKey() {
|
|
450
594
|
return uniqueId++ + dataStoreKeyExpandoPropertyName;
|
|
451
595
|
}
|
|
452
596
|
function get(node, key) {
|
|
597
|
+
if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
|
|
453
598
|
const dataForNode = getDataForNode(node, false);
|
|
454
599
|
return dataForNode && dataForNode[key];
|
|
455
600
|
}
|
|
456
601
|
function set(node, key, value2) {
|
|
457
|
-
|
|
458
|
-
|
|
602
|
+
if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
|
|
603
|
+
const dataForNode = getDataForNode(
|
|
604
|
+
node,
|
|
605
|
+
value2 !== void 0
|
|
606
|
+
/* createIfNotFound */
|
|
607
|
+
);
|
|
608
|
+
if (dataForNode) {
|
|
609
|
+
dataForNode[key] = value2;
|
|
610
|
+
}
|
|
459
611
|
}
|
|
460
612
|
function getOrSet(node, key, value2) {
|
|
461
|
-
|
|
613
|
+
if (!isSafeKey(key)) throw new Error("Unsafe key for DOM data: " + key);
|
|
614
|
+
const dataForNode = getDataForNode(
|
|
615
|
+
node,
|
|
616
|
+
true
|
|
617
|
+
/* createIfNotFound */
|
|
618
|
+
);
|
|
462
619
|
return dataForNode[key] || (dataForNode[key] = value2);
|
|
463
620
|
}
|
|
464
621
|
|
|
@@ -467,9 +624,9 @@ var domDataKey = nextKey();
|
|
|
467
624
|
var cleanableNodeTypes = { 1: true, 8: true, 9: true };
|
|
468
625
|
var cleanableNodeTypesWithDescendants = { 1: true, 9: true };
|
|
469
626
|
function getDisposeCallbacksCollection(node, createIfNotFound) {
|
|
470
|
-
|
|
627
|
+
let allDisposeCallbacks = get(node, domDataKey);
|
|
471
628
|
if (allDisposeCallbacks === void 0 && createIfNotFound) {
|
|
472
|
-
allDisposeCallbacks =
|
|
629
|
+
allDisposeCallbacks = new Array();
|
|
473
630
|
set(node, domDataKey, allDisposeCallbacks);
|
|
474
631
|
}
|
|
475
632
|
return allDisposeCallbacks;
|
|
@@ -478,7 +635,7 @@ function destroyCallbacksCollection(node) {
|
|
|
478
635
|
set(node, domDataKey, void 0);
|
|
479
636
|
}
|
|
480
637
|
function cleanSingleNode(node) {
|
|
481
|
-
|
|
638
|
+
let callbacks = getDisposeCallbacksCollection(node, false);
|
|
482
639
|
if (callbacks) {
|
|
483
640
|
callbacks = callbacks.slice(0);
|
|
484
641
|
for (let i = 0; i < callbacks.length; i++) {
|
|
@@ -493,14 +650,18 @@ function cleanSingleNode(node) {
|
|
|
493
650
|
options_default.cleanExternalData(node);
|
|
494
651
|
}
|
|
495
652
|
if (cleanableNodeTypesWithDescendants[node.nodeType]) {
|
|
496
|
-
cleanNodesInList(
|
|
653
|
+
cleanNodesInList(
|
|
654
|
+
node.childNodes,
|
|
655
|
+
true
|
|
656
|
+
/* onlyComments */
|
|
657
|
+
);
|
|
497
658
|
}
|
|
498
659
|
}
|
|
499
660
|
function cleanNodesInList(nodeList, onlyComments) {
|
|
500
|
-
const cleanedNodes =
|
|
661
|
+
const cleanedNodes = new Array();
|
|
501
662
|
let lastCleanedNode;
|
|
502
|
-
for (
|
|
503
|
-
if (!onlyComments || nodeList[i].nodeType ===
|
|
663
|
+
for (let i = 0; i < nodeList.length; i++) {
|
|
664
|
+
if (!onlyComments || nodeList[i].nodeType === Node.COMMENT_NODE) {
|
|
504
665
|
cleanSingleNode(cleanedNodes[cleanedNodes.length] = lastCleanedNode = nodeList[i]);
|
|
505
666
|
if (nodeList[i] !== lastCleanedNode) {
|
|
506
667
|
while (i-- && arrayIndexOf(cleanedNodes, nodeList[i]) === -1) {
|
|
@@ -516,7 +677,7 @@ function addDisposeCallback(node, callback) {
|
|
|
516
677
|
getDisposeCallbacksCollection(node, true).push(callback);
|
|
517
678
|
}
|
|
518
679
|
function removeDisposeCallback(node, callback) {
|
|
519
|
-
|
|
680
|
+
const callbacksCollection = getDisposeCallbacksCollection(node, false);
|
|
520
681
|
if (callbacksCollection) {
|
|
521
682
|
arrayRemoveItem(callbacksCollection, callback);
|
|
522
683
|
if (callbacksCollection.length === 0) {
|
|
@@ -527,140 +688,52 @@ function removeDisposeCallback(node, callback) {
|
|
|
527
688
|
function cleanNode(node) {
|
|
528
689
|
if (cleanableNodeTypes[node.nodeType]) {
|
|
529
690
|
cleanSingleNode(node);
|
|
530
|
-
if (cleanableNodeTypesWithDescendants[node.nodeType]) {
|
|
691
|
+
if (cleanableNodeTypesWithDescendants[node.nodeType] && node instanceof Element) {
|
|
531
692
|
cleanNodesInList(node.getElementsByTagName("*"));
|
|
532
693
|
}
|
|
533
694
|
}
|
|
534
695
|
return node;
|
|
535
696
|
}
|
|
536
697
|
function removeNode(node) {
|
|
698
|
+
if (!node) {
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
537
701
|
cleanNode(node);
|
|
538
702
|
if (node.parentNode) {
|
|
539
703
|
node.parentNode.removeChild(node);
|
|
540
704
|
}
|
|
541
705
|
}
|
|
542
|
-
var otherNodeCleanerFunctions =
|
|
706
|
+
var otherNodeCleanerFunctions = new Array();
|
|
543
707
|
function cleanjQueryData(node) {
|
|
544
|
-
|
|
708
|
+
const jQueryCleanNodeFn = options_default.jQuery ? options_default.jQuery.cleanData : null;
|
|
545
709
|
if (jQueryCleanNodeFn) {
|
|
546
710
|
jQueryCleanNodeFn([node]);
|
|
547
711
|
}
|
|
548
712
|
}
|
|
549
713
|
otherNodeCleanerFunctions.push(cleanjQueryData);
|
|
550
714
|
|
|
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
715
|
// ../utils/dist/dom/manipulation.js
|
|
634
716
|
function setDomNodeChildren(domNode, childNodes2) {
|
|
635
717
|
emptyDomNode(domNode);
|
|
636
718
|
if (childNodes2) {
|
|
637
|
-
for (
|
|
719
|
+
for (let i = 0; i < childNodes2.length; i++) {
|
|
638
720
|
domNode.appendChild(childNodes2[i]);
|
|
639
721
|
}
|
|
640
722
|
}
|
|
641
723
|
}
|
|
642
724
|
function replaceDomNodes(nodeToReplaceOrNodeArray, newNodesArray) {
|
|
643
|
-
|
|
725
|
+
const nodesToReplaceArray = Array.isArray(nodeToReplaceOrNodeArray) ? nodeToReplaceOrNodeArray : [nodeToReplaceOrNodeArray];
|
|
644
726
|
if (nodesToReplaceArray.length > 0) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
for (
|
|
648
|
-
parent.insertBefore(newNodesArray[i], insertionPoint);
|
|
727
|
+
const insertionPoint = nodesToReplaceArray[0];
|
|
728
|
+
const parent = insertionPoint.parentNode;
|
|
729
|
+
for (let i = 0; i < newNodesArray.length; i++) {
|
|
730
|
+
parent == null ? void 0 : parent.insertBefore(newNodesArray[i], insertionPoint);
|
|
649
731
|
}
|
|
650
|
-
for (i = 0
|
|
732
|
+
for (let i = 0; i < nodesToReplaceArray.length; i++) {
|
|
651
733
|
removeNode(nodesToReplaceArray[i]);
|
|
652
734
|
}
|
|
653
735
|
}
|
|
654
736
|
}
|
|
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
737
|
function emptyDomNode(domNode) {
|
|
665
738
|
while (domNode.firstChild) {
|
|
666
739
|
removeNode(domNode.firstChild);
|
|
@@ -670,7 +743,7 @@ function emptyDomNode(domNode) {
|
|
|
670
743
|
// ../utils/dist/dom/fixes.js
|
|
671
744
|
function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {
|
|
672
745
|
if (continuousNodeArray.length) {
|
|
673
|
-
parentNode = parentNode.nodeType ===
|
|
746
|
+
parentNode = parentNode.nodeType === Node.COMMENT_NODE && parentNode.parentNode || parentNode;
|
|
674
747
|
while (continuousNodeArray.length && continuousNodeArray[0].parentNode !== parentNode) {
|
|
675
748
|
continuousNodeArray.splice(0, 1);
|
|
676
749
|
}
|
|
@@ -678,7 +751,7 @@ function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {
|
|
|
678
751
|
continuousNodeArray.length--;
|
|
679
752
|
}
|
|
680
753
|
if (continuousNodeArray.length > 1) {
|
|
681
|
-
|
|
754
|
+
let current = continuousNodeArray[0], last = continuousNodeArray[continuousNodeArray.length - 1];
|
|
682
755
|
continuousNodeArray.length = 0;
|
|
683
756
|
while (current !== last) {
|
|
684
757
|
continuousNodeArray.push(current);
|
|
@@ -690,26 +763,7 @@ function fixUpContinuousNodeArray(continuousNodeArray, parentNode) {
|
|
|
690
763
|
return continuousNodeArray;
|
|
691
764
|
}
|
|
692
765
|
function setOptionNodeSelectionState(optionNode, isSelected) {
|
|
693
|
-
|
|
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
|
-
}
|
|
766
|
+
optionNode.selected = isSelected;
|
|
713
767
|
}
|
|
714
768
|
|
|
715
769
|
// ../utils/dist/dom/virtualElements.js
|
|
@@ -734,24 +788,23 @@ __export(virtualElements_exports, {
|
|
|
734
788
|
startCommentRegex: () => startCommentRegex,
|
|
735
789
|
virtualNodeBindingValue: () => virtualNodeBindingValue
|
|
736
790
|
});
|
|
737
|
-
var
|
|
738
|
-
var
|
|
739
|
-
var
|
|
740
|
-
var htmlTagsWithOptionallyClosingChildren = { "ul": true, "ol": true };
|
|
791
|
+
var startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/;
|
|
792
|
+
var endCommentRegex = /^\s*\/ko\s*$/;
|
|
793
|
+
var htmlTagsWithOptionallyClosingChildren = { ul: true, ol: true };
|
|
741
794
|
function isStartComment(node) {
|
|
742
|
-
return node.nodeType
|
|
795
|
+
return node.nodeType === Node.COMMENT_NODE && startCommentRegex.test(node.nodeValue);
|
|
743
796
|
}
|
|
744
797
|
function isEndComment(node) {
|
|
745
|
-
return node.nodeType
|
|
798
|
+
return node.nodeType === Node.COMMENT_NODE && endCommentRegex.test(node.nodeValue);
|
|
746
799
|
}
|
|
747
800
|
function isUnmatchedEndComment(node) {
|
|
748
801
|
return isEndComment(node) && !get(node, matchedEndCommentDataKey);
|
|
749
802
|
}
|
|
750
803
|
var matchedEndCommentDataKey = "__ko_matchedEndComment__";
|
|
751
804
|
function getVirtualChildren(startComment, allowUnbalanced) {
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
805
|
+
let currentNode = startComment;
|
|
806
|
+
let depth = 1;
|
|
807
|
+
const children = new Array();
|
|
755
808
|
while (currentNode = currentNode.nextSibling) {
|
|
756
809
|
if (isEndComment(currentNode)) {
|
|
757
810
|
set(currentNode, matchedEndCommentDataKey, true);
|
|
@@ -771,7 +824,7 @@ function getVirtualChildren(startComment, allowUnbalanced) {
|
|
|
771
824
|
return null;
|
|
772
825
|
}
|
|
773
826
|
function getMatchingEndComment(startComment, allowUnbalanced) {
|
|
774
|
-
|
|
827
|
+
const allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);
|
|
775
828
|
if (allVirtualChildren) {
|
|
776
829
|
if (allVirtualChildren.length > 0) {
|
|
777
830
|
return allVirtualChildren[allVirtualChildren.length - 1].nextSibling;
|
|
@@ -782,13 +835,17 @@ function getMatchingEndComment(startComment, allowUnbalanced) {
|
|
|
782
835
|
}
|
|
783
836
|
}
|
|
784
837
|
function getUnbalancedChildTags(node) {
|
|
785
|
-
|
|
838
|
+
let childNode = node.firstChild, captureRemaining = null;
|
|
786
839
|
if (childNode) {
|
|
787
840
|
do {
|
|
788
841
|
if (captureRemaining) {
|
|
789
842
|
captureRemaining.push(childNode);
|
|
790
843
|
} else if (isStartComment(childNode)) {
|
|
791
|
-
|
|
844
|
+
const matchingEndComment = getMatchingEndComment(
|
|
845
|
+
childNode,
|
|
846
|
+
/* allowUnbalanced: */
|
|
847
|
+
true
|
|
848
|
+
);
|
|
792
849
|
if (matchingEndComment) {
|
|
793
850
|
childNode = matchingEndComment;
|
|
794
851
|
} else {
|
|
@@ -801,7 +858,7 @@ function getUnbalancedChildTags(node) {
|
|
|
801
858
|
}
|
|
802
859
|
return captureRemaining;
|
|
803
860
|
}
|
|
804
|
-
var allowedBindings =
|
|
861
|
+
var allowedBindings = /* @__PURE__ */ Object.create(null);
|
|
805
862
|
var hasBindingValue = isStartComment;
|
|
806
863
|
function childNodes(node) {
|
|
807
864
|
return isStartComment(node) ? getVirtualChildren(node) : node.childNodes;
|
|
@@ -810,8 +867,8 @@ function emptyNode(node) {
|
|
|
810
867
|
if (!isStartComment(node)) {
|
|
811
868
|
emptyDomNode(node);
|
|
812
869
|
} else {
|
|
813
|
-
|
|
814
|
-
for (
|
|
870
|
+
const virtualChildren = childNodes(node);
|
|
871
|
+
for (let i = 0, j = virtualChildren.length; i < j; i++) {
|
|
815
872
|
removeNode(virtualChildren[i]);
|
|
816
873
|
}
|
|
817
874
|
}
|
|
@@ -822,13 +879,16 @@ function setDomNodeChildren2(node, childNodes2) {
|
|
|
822
879
|
} else {
|
|
823
880
|
emptyNode(node);
|
|
824
881
|
const endCommentNode = node.nextSibling;
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
882
|
+
if (endCommentNode && endCommentNode.parentNode) {
|
|
883
|
+
const parentNode = endCommentNode.parentNode;
|
|
884
|
+
for (let i = 0, j = childNodes2.length; i < j; ++i) {
|
|
885
|
+
parentNode.insertBefore(childNodes2[i], endCommentNode);
|
|
886
|
+
}
|
|
828
887
|
}
|
|
829
888
|
}
|
|
830
889
|
}
|
|
831
890
|
function prepend(containerNode, nodeToPrepend) {
|
|
891
|
+
var _a;
|
|
832
892
|
if (!isStartComment(containerNode)) {
|
|
833
893
|
if (containerNode.firstChild) {
|
|
834
894
|
containerNode.insertBefore(nodeToPrepend, containerNode.firstChild);
|
|
@@ -836,10 +896,11 @@ function prepend(containerNode, nodeToPrepend) {
|
|
|
836
896
|
containerNode.appendChild(nodeToPrepend);
|
|
837
897
|
}
|
|
838
898
|
} else {
|
|
839
|
-
containerNode.parentNode.insertBefore(nodeToPrepend, containerNode.nextSibling);
|
|
899
|
+
(_a = containerNode.parentNode) == null ? void 0 : _a.insertBefore(nodeToPrepend, containerNode.nextSibling);
|
|
840
900
|
}
|
|
841
901
|
}
|
|
842
902
|
function insertAfter(containerNode, nodeToInsert, insertAfterNode) {
|
|
903
|
+
var _a;
|
|
843
904
|
if (!insertAfterNode) {
|
|
844
905
|
prepend(containerNode, nodeToInsert);
|
|
845
906
|
} else if (!isStartComment(containerNode)) {
|
|
@@ -849,7 +910,7 @@ function insertAfter(containerNode, nodeToInsert, insertAfterNode) {
|
|
|
849
910
|
containerNode.appendChild(nodeToInsert);
|
|
850
911
|
}
|
|
851
912
|
} else {
|
|
852
|
-
containerNode.parentNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
|
|
913
|
+
(_a = containerNode.parentNode) == null ? void 0 : _a.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
|
|
853
914
|
}
|
|
854
915
|
}
|
|
855
916
|
function firstChild(node) {
|
|
@@ -866,6 +927,7 @@ function firstChild(node) {
|
|
|
866
927
|
}
|
|
867
928
|
function lastChild(node) {
|
|
868
929
|
let nextChild = firstChild(node);
|
|
930
|
+
if (!nextChild) return null;
|
|
869
931
|
let lastChildNode;
|
|
870
932
|
do {
|
|
871
933
|
lastChildNode = nextChild;
|
|
@@ -878,7 +940,9 @@ function nextSibling(node) {
|
|
|
878
940
|
}
|
|
879
941
|
if (node.nextSibling && isEndComment(node.nextSibling)) {
|
|
880
942
|
if (isUnmatchedEndComment(node.nextSibling)) {
|
|
881
|
-
throw Error(
|
|
943
|
+
throw Error(
|
|
944
|
+
"Found end comment without a matching opening comment, as next sibling of " + node.outerHTML
|
|
945
|
+
);
|
|
882
946
|
}
|
|
883
947
|
return null;
|
|
884
948
|
} else {
|
|
@@ -886,9 +950,9 @@ function nextSibling(node) {
|
|
|
886
950
|
}
|
|
887
951
|
}
|
|
888
952
|
function previousSibling(node) {
|
|
889
|
-
|
|
953
|
+
let depth = 0;
|
|
890
954
|
do {
|
|
891
|
-
if (node.nodeType ===
|
|
955
|
+
if (node.nodeType === Node.COMMENT_NODE) {
|
|
892
956
|
if (isStartComment(node)) {
|
|
893
957
|
if (--depth === 0) {
|
|
894
958
|
return node;
|
|
@@ -904,21 +968,21 @@ function previousSibling(node) {
|
|
|
904
968
|
} while (node = node.previousSibling);
|
|
905
969
|
}
|
|
906
970
|
function virtualNodeBindingValue(node) {
|
|
907
|
-
|
|
971
|
+
const regexMatch = node.nodeValue.match(startCommentRegex);
|
|
908
972
|
return regexMatch ? regexMatch[1] : null;
|
|
909
973
|
}
|
|
910
974
|
function normaliseVirtualElementDomStructure(elementVerified) {
|
|
911
975
|
if (!htmlTagsWithOptionallyClosingChildren[tagNameLower(elementVerified)]) {
|
|
912
976
|
return;
|
|
913
977
|
}
|
|
914
|
-
|
|
978
|
+
let childNode = elementVerified.firstChild;
|
|
915
979
|
if (childNode) {
|
|
916
980
|
do {
|
|
917
|
-
if (childNode.nodeType ===
|
|
918
|
-
|
|
981
|
+
if (childNode.nodeType === Node.ELEMENT_NODE) {
|
|
982
|
+
const unbalancedTags = getUnbalancedChildTags(childNode);
|
|
919
983
|
if (unbalancedTags) {
|
|
920
|
-
|
|
921
|
-
for (
|
|
984
|
+
const nodeToInsertBefore = childNode.nextSibling;
|
|
985
|
+
for (let i = 0; i < unbalancedTags.length; i++) {
|
|
922
986
|
if (nodeToInsertBefore) {
|
|
923
987
|
elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore);
|
|
924
988
|
} else {
|
|
@@ -932,78 +996,48 @@ function normaliseVirtualElementDomStructure(elementVerified) {
|
|
|
932
996
|
}
|
|
933
997
|
|
|
934
998
|
// ../utils/dist/dom/html.js
|
|
935
|
-
var
|
|
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
|
-
}
|
|
999
|
+
var supportsTemplateTag = options_default.useTemplateTag && options_default.document && "content" in options_default.document.createElement("template");
|
|
965
1000
|
function simpleHtmlParse(html2, documentContext) {
|
|
966
|
-
|
|
967
|
-
|
|
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;
|
|
1001
|
+
if (!documentContext) {
|
|
1002
|
+
documentContext = document;
|
|
977
1003
|
}
|
|
978
|
-
|
|
1004
|
+
const div = documentContext.createElement("div");
|
|
1005
|
+
div.innerHTML = html2;
|
|
1006
|
+
return makeArray(div.childNodes);
|
|
979
1007
|
}
|
|
980
1008
|
function templateHtmlParse(html2, documentContext) {
|
|
981
1009
|
if (!documentContext) {
|
|
982
1010
|
documentContext = document;
|
|
983
1011
|
}
|
|
984
|
-
|
|
1012
|
+
const template = documentContext.createElement("template");
|
|
985
1013
|
template.innerHTML = html2;
|
|
986
1014
|
return makeArray(template.content.childNodes);
|
|
987
1015
|
}
|
|
988
1016
|
function jQueryHtmlParse(html2, documentContext) {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
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;
|
|
1017
|
+
const jQuery2 = options_default.jQuery;
|
|
1018
|
+
if (jQuery2) {
|
|
1019
|
+
return jQuery2.parseHTML(html2, documentContext) || [];
|
|
1003
1020
|
}
|
|
1021
|
+
return [];
|
|
1004
1022
|
}
|
|
1005
1023
|
function parseHtmlFragment(html2, documentContext) {
|
|
1006
|
-
|
|
1024
|
+
const saferHtml = validateHTMLInput(html2);
|
|
1025
|
+
if (supportsTemplateTag) return templateHtmlParse(saferHtml, documentContext);
|
|
1026
|
+
if (options_default.jQuery) {
|
|
1027
|
+
return jQueryHtmlParse(saferHtml, documentContext);
|
|
1028
|
+
}
|
|
1029
|
+
return simpleHtmlParse(saferHtml, documentContext);
|
|
1030
|
+
}
|
|
1031
|
+
var scriptTagPattern = /<script\b[^>]*>([\s\S]*?)<\/script[^>]*>/i;
|
|
1032
|
+
function validateHTMLInput(html2) {
|
|
1033
|
+
if (!html2) return "";
|
|
1034
|
+
if (options_default.templateSizeLimit > 0 && html2.length > options_default.templateSizeLimit) {
|
|
1035
|
+
throw new Error("Template is too long. Please configure the 'templateSizeLimit'");
|
|
1036
|
+
}
|
|
1037
|
+
if (!options_default.allowScriptTagsInTemplates && scriptTagPattern.test(html2)) {
|
|
1038
|
+
throw new Error("Script-tag in template detected.");
|
|
1039
|
+
}
|
|
1040
|
+
return options_default.sanitizeHtmlTemplate(html2);
|
|
1007
1041
|
}
|
|
1008
1042
|
function setHtml(node, html2) {
|
|
1009
1043
|
emptyDomNode(node);
|
|
@@ -1014,18 +1048,25 @@ function setHtml(node, html2) {
|
|
|
1014
1048
|
if (typeof html2 !== "string") {
|
|
1015
1049
|
html2 = html2.toString();
|
|
1016
1050
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1051
|
+
const jQuery2 = options_default.jQuery;
|
|
1052
|
+
if (jQuery2 && !supportsTemplateTag) {
|
|
1053
|
+
const saferHtml = validateHTMLInput(html2);
|
|
1054
|
+
jQuery2(node).html(saferHtml);
|
|
1019
1055
|
} else {
|
|
1020
|
-
|
|
1021
|
-
if (node.
|
|
1056
|
+
let parsedNodes;
|
|
1057
|
+
if (node.ownerDocument) {
|
|
1058
|
+
parsedNodes = parseHtmlFragment(html2, node.ownerDocument);
|
|
1059
|
+
} else {
|
|
1060
|
+
parsedNodes = parseHtmlFragment(html2);
|
|
1061
|
+
}
|
|
1062
|
+
if (node.nodeType === Node.COMMENT_NODE) {
|
|
1022
1063
|
if (html2 === null) {
|
|
1023
1064
|
emptyNode(node);
|
|
1024
1065
|
} else {
|
|
1025
1066
|
setDomNodeChildren2(node, parsedNodes);
|
|
1026
1067
|
}
|
|
1027
1068
|
} else {
|
|
1028
|
-
for (
|
|
1069
|
+
for (let i = 0; i < parsedNodes.length; i++) {
|
|
1029
1070
|
node.appendChild(parsedNodes[i]);
|
|
1030
1071
|
}
|
|
1031
1072
|
}
|
|
@@ -1033,32 +1074,35 @@ function setHtml(node, html2) {
|
|
|
1033
1074
|
}
|
|
1034
1075
|
}
|
|
1035
1076
|
function setTextContent(element, textContent) {
|
|
1036
|
-
|
|
1077
|
+
let value2 = typeof textContent === "function" ? textContent() : textContent;
|
|
1037
1078
|
if (value2 === null || value2 === void 0) {
|
|
1038
1079
|
value2 = "";
|
|
1039
1080
|
}
|
|
1040
|
-
|
|
1041
|
-
if (!innerTextNode || innerTextNode.nodeType
|
|
1081
|
+
const innerTextNode = firstChild(element);
|
|
1082
|
+
if (!innerTextNode || innerTextNode.nodeType !== Node.TEXT_NODE || nextSibling(innerTextNode)) {
|
|
1042
1083
|
setDomNodeChildren2(element, [element.ownerDocument.createTextNode(value2)]);
|
|
1043
1084
|
} else {
|
|
1085
|
+
;
|
|
1044
1086
|
innerTextNode.data = value2;
|
|
1045
1087
|
}
|
|
1046
|
-
forceRefresh(element);
|
|
1047
1088
|
}
|
|
1048
1089
|
|
|
1049
1090
|
// ../utils/dist/dom/selectExtensions.js
|
|
1050
|
-
var hasDomDataExpandoProperty = Symbol("Knockout selectExtensions hasDomDataProperty");
|
|
1091
|
+
var hasDomDataExpandoProperty = /* @__PURE__ */ Symbol("Knockout selectExtensions hasDomDataProperty");
|
|
1051
1092
|
var selectExtensions = {
|
|
1052
1093
|
optionValueDomDataKey: nextKey(),
|
|
1053
1094
|
readValue: function(element) {
|
|
1054
1095
|
switch (tagNameLower(element)) {
|
|
1055
|
-
case "option":
|
|
1096
|
+
case "option": {
|
|
1056
1097
|
if (element[hasDomDataExpandoProperty] === true) {
|
|
1057
1098
|
return get(element, selectExtensions.optionValueDomDataKey);
|
|
1058
1099
|
}
|
|
1059
1100
|
return element.value;
|
|
1060
|
-
|
|
1061
|
-
|
|
1101
|
+
}
|
|
1102
|
+
case "select": {
|
|
1103
|
+
const selectElement = element;
|
|
1104
|
+
return selectElement.selectedIndex >= 0 ? selectExtensions.readValue(selectElement.options[selectElement.selectedIndex]) : void 0;
|
|
1105
|
+
}
|
|
1062
1106
|
default:
|
|
1063
1107
|
return element.value;
|
|
1064
1108
|
}
|
|
@@ -1071,36 +1115,42 @@ var selectExtensions = {
|
|
|
1071
1115
|
if (hasDomDataExpandoProperty in element) {
|
|
1072
1116
|
delete element[hasDomDataExpandoProperty];
|
|
1073
1117
|
}
|
|
1118
|
+
;
|
|
1074
1119
|
element.value = value2;
|
|
1075
1120
|
} else {
|
|
1121
|
+
const el = element;
|
|
1076
1122
|
set(element, selectExtensions.optionValueDomDataKey, value2);
|
|
1077
|
-
|
|
1078
|
-
|
|
1123
|
+
el[hasDomDataExpandoProperty] = true;
|
|
1124
|
+
el.value = typeof value2 === "number" ? value2 : "";
|
|
1079
1125
|
}
|
|
1080
1126
|
break;
|
|
1081
1127
|
case "select":
|
|
1082
|
-
|
|
1083
|
-
value2
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1128
|
+
{
|
|
1129
|
+
if (value2 === "" || value2 === null) {
|
|
1130
|
+
value2 = void 0;
|
|
1131
|
+
}
|
|
1132
|
+
let selection = -1;
|
|
1133
|
+
const selectElement = element;
|
|
1134
|
+
for (let i = 0, n = selectElement.options.length, optionValue; i < n; ++i) {
|
|
1135
|
+
optionValue = selectExtensions.readValue(selectElement.options[i]);
|
|
1136
|
+
const strictEqual = optionValue === value2;
|
|
1137
|
+
const blankEqual = optionValue === "" && value2 === void 0;
|
|
1138
|
+
const numericEqual = typeof value2 === "number" && Number(optionValue) === value2;
|
|
1139
|
+
if (strictEqual || blankEqual || numericEqual) {
|
|
1140
|
+
selection = i;
|
|
1141
|
+
break;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
if (allowUnset || selection >= 0 || value2 === void 0 && selectElement.size > 1) {
|
|
1145
|
+
selectElement.selectedIndex = selection;
|
|
1094
1146
|
}
|
|
1095
|
-
}
|
|
1096
|
-
if (allowUnset || selection >= 0 || value2 === void 0 && element.size > 1) {
|
|
1097
|
-
element.selectedIndex = selection;
|
|
1098
1147
|
}
|
|
1099
1148
|
break;
|
|
1100
1149
|
default:
|
|
1101
1150
|
if (value2 === null || value2 === void 0) {
|
|
1102
1151
|
value2 = "";
|
|
1103
1152
|
}
|
|
1153
|
+
;
|
|
1104
1154
|
element.value = value2;
|
|
1105
1155
|
break;
|
|
1106
1156
|
}
|
|
@@ -1115,30 +1165,19 @@ __export(tasks_exports, {
|
|
|
1115
1165
|
runEarly: () => processTasks,
|
|
1116
1166
|
schedule: () => schedule
|
|
1117
1167
|
});
|
|
1118
|
-
var taskQueue =
|
|
1168
|
+
var taskQueue = new Array();
|
|
1119
1169
|
var taskQueueLength = 0;
|
|
1120
1170
|
var nextHandle = 1;
|
|
1121
1171
|
var nextIndexToProcess = 0;
|
|
1122
1172
|
var w = options_default.global;
|
|
1123
1173
|
if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
|
|
1124
|
-
options_default.taskScheduler = function(callback) {
|
|
1125
|
-
|
|
1174
|
+
options_default.taskScheduler = (function(callback) {
|
|
1175
|
+
const div = w.document.createElement("div");
|
|
1126
1176
|
new w.MutationObserver(callback).observe(div, { attributes: true });
|
|
1127
1177
|
return function() {
|
|
1128
1178
|
div.classList.toggle("foo");
|
|
1129
1179
|
};
|
|
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
|
-
};
|
|
1180
|
+
})(scheduledProcess);
|
|
1142
1181
|
} else {
|
|
1143
1182
|
options_default.taskScheduler = function(callback) {
|
|
1144
1183
|
setTimeout(callback, 0);
|
|
@@ -1146,8 +1185,8 @@ if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
|
|
|
1146
1185
|
}
|
|
1147
1186
|
function processTasks() {
|
|
1148
1187
|
if (taskQueueLength) {
|
|
1149
|
-
|
|
1150
|
-
for (
|
|
1188
|
+
let mark = taskQueueLength, countMarks = 0;
|
|
1189
|
+
for (let task; nextIndexToProcess < taskQueueLength; ) {
|
|
1151
1190
|
if (task = taskQueue[nextIndexToProcess++]) {
|
|
1152
1191
|
if (nextIndexToProcess > mark) {
|
|
1153
1192
|
if (++countMarks >= 5e3) {
|
|
@@ -1181,13 +1220,13 @@ function schedule(func) {
|
|
|
1181
1220
|
return nextHandle++;
|
|
1182
1221
|
}
|
|
1183
1222
|
function cancel(handle) {
|
|
1184
|
-
|
|
1223
|
+
const index = handle - (nextHandle - taskQueueLength);
|
|
1185
1224
|
if (index >= nextIndexToProcess && index < taskQueueLength) {
|
|
1186
1225
|
taskQueue[index] = null;
|
|
1187
1226
|
}
|
|
1188
1227
|
}
|
|
1189
1228
|
function resetForTesting() {
|
|
1190
|
-
|
|
1229
|
+
const length = taskQueueLength - nextIndexToProcess;
|
|
1191
1230
|
nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
|
|
1192
1231
|
return length;
|
|
1193
1232
|
}
|
|
@@ -1206,13 +1245,13 @@ __export(dependencyDetection_exports, {
|
|
|
1206
1245
|
});
|
|
1207
1246
|
|
|
1208
1247
|
// ../observable/dist/subscribableSymbol.js
|
|
1209
|
-
var SUBSCRIBABLE_SYM = Symbol("Knockout Subscribable");
|
|
1248
|
+
var SUBSCRIBABLE_SYM = /* @__PURE__ */ Symbol("Knockout Subscribable");
|
|
1210
1249
|
function isSubscribable(instance) {
|
|
1211
1250
|
return instance && instance[SUBSCRIBABLE_SYM] || false;
|
|
1212
1251
|
}
|
|
1213
1252
|
|
|
1214
1253
|
// ../observable/dist/dependencyDetection.js
|
|
1215
|
-
var outerFrames =
|
|
1254
|
+
var outerFrames = new Array();
|
|
1216
1255
|
var currentFrame;
|
|
1217
1256
|
var lastId = 0;
|
|
1218
1257
|
function getId() {
|
|
@@ -1230,7 +1269,11 @@ function registerDependency(subscribable2) {
|
|
|
1230
1269
|
if (!isSubscribable(subscribable2)) {
|
|
1231
1270
|
throw new Error("Only subscribable things can act as dependencies");
|
|
1232
1271
|
}
|
|
1233
|
-
currentFrame.callback.call(
|
|
1272
|
+
currentFrame.callback.call(
|
|
1273
|
+
currentFrame.callbackTarget,
|
|
1274
|
+
subscribable2,
|
|
1275
|
+
subscribable2._id || (subscribable2._id = getId())
|
|
1276
|
+
);
|
|
1234
1277
|
}
|
|
1235
1278
|
}
|
|
1236
1279
|
function ignore(callback, callbackTarget, callbackArgs) {
|
|
@@ -1245,16 +1288,19 @@ function getDependenciesCount() {
|
|
|
1245
1288
|
if (currentFrame) {
|
|
1246
1289
|
return currentFrame.computed.getDependenciesCount();
|
|
1247
1290
|
}
|
|
1291
|
+
return void 0;
|
|
1248
1292
|
}
|
|
1249
1293
|
function getDependencies() {
|
|
1250
1294
|
if (currentFrame) {
|
|
1251
1295
|
return currentFrame.computed.getDependencies();
|
|
1252
1296
|
}
|
|
1297
|
+
return void 0;
|
|
1253
1298
|
}
|
|
1254
1299
|
function isInitial() {
|
|
1255
1300
|
if (currentFrame) {
|
|
1256
1301
|
return currentFrame.isInitial;
|
|
1257
1302
|
}
|
|
1303
|
+
return void 0;
|
|
1258
1304
|
}
|
|
1259
1305
|
|
|
1260
1306
|
// ../observable/dist/defer.js
|
|
@@ -1301,6 +1347,7 @@ var Subscription = class {
|
|
|
1301
1347
|
this._node = node;
|
|
1302
1348
|
addDisposeCallback(node, this._domNodeDisposalCallback = this.dispose.bind(this));
|
|
1303
1349
|
}
|
|
1350
|
+
// TC39 Observable API
|
|
1304
1351
|
unsubscribe() {
|
|
1305
1352
|
this.dispose();
|
|
1306
1353
|
}
|
|
@@ -1310,21 +1357,16 @@ var Subscription = class {
|
|
|
1310
1357
|
};
|
|
1311
1358
|
|
|
1312
1359
|
// ../observable/dist/extenders.js
|
|
1313
|
-
var primitiveTypes = {
|
|
1314
|
-
"undefined": 1,
|
|
1315
|
-
"boolean": 1,
|
|
1316
|
-
"number": 1,
|
|
1317
|
-
"string": 1
|
|
1318
|
-
};
|
|
1360
|
+
var primitiveTypes = { undefined: 1, boolean: 1, number: 1, string: 1 };
|
|
1319
1361
|
function valuesArePrimitiveAndEqual(a, b) {
|
|
1320
|
-
|
|
1362
|
+
const oldValueIsPrimitive = a === null || typeof a in primitiveTypes;
|
|
1321
1363
|
return oldValueIsPrimitive ? a === b : false;
|
|
1322
1364
|
}
|
|
1323
1365
|
function applyExtenders(requestedExtenders) {
|
|
1324
|
-
|
|
1366
|
+
let target = this;
|
|
1325
1367
|
if (requestedExtenders) {
|
|
1326
1368
|
objectForEach(requestedExtenders, function(key, value2) {
|
|
1327
|
-
|
|
1369
|
+
const extenderHandler = extenders[key];
|
|
1328
1370
|
if (typeof extenderHandler === "function") {
|
|
1329
1371
|
target = extenderHandler(target, value2) || target;
|
|
1330
1372
|
} else {
|
|
@@ -1339,12 +1381,14 @@ function notify(target, notifyWhen) {
|
|
|
1339
1381
|
}
|
|
1340
1382
|
function deferred(target, option) {
|
|
1341
1383
|
if (option !== true) {
|
|
1342
|
-
throw new Error(
|
|
1384
|
+
throw new Error(
|
|
1385
|
+
"The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled."
|
|
1386
|
+
);
|
|
1343
1387
|
}
|
|
1344
1388
|
deferUpdates(target);
|
|
1345
1389
|
}
|
|
1346
1390
|
function rateLimit(target, options22) {
|
|
1347
|
-
|
|
1391
|
+
let timeout, method, limitFunction;
|
|
1348
1392
|
if (typeof options22 === "number") {
|
|
1349
1393
|
timeout = options22;
|
|
1350
1394
|
} else {
|
|
@@ -1357,21 +1401,17 @@ function rateLimit(target, options22) {
|
|
|
1357
1401
|
return limitFunction(callback, timeout);
|
|
1358
1402
|
});
|
|
1359
1403
|
}
|
|
1360
|
-
var extenders = {
|
|
1361
|
-
notify,
|
|
1362
|
-
deferred,
|
|
1363
|
-
rateLimit
|
|
1364
|
-
};
|
|
1404
|
+
var extenders = { notify, deferred, rateLimit };
|
|
1365
1405
|
|
|
1366
1406
|
// ../observable/dist/subscribable.js
|
|
1367
|
-
var LATEST_VALUE = Symbol("Knockout latest value");
|
|
1407
|
+
var LATEST_VALUE = /* @__PURE__ */ Symbol("Knockout latest value");
|
|
1368
1408
|
if (!Symbol.observable) {
|
|
1369
|
-
Symbol.observable = Symbol.for("@tko/Symbol.observable");
|
|
1409
|
+
Symbol.observable = /* @__PURE__ */ Symbol.for("@tko/Symbol.observable");
|
|
1370
1410
|
}
|
|
1371
|
-
function
|
|
1411
|
+
var subscribable = function subscribableFactory() {
|
|
1372
1412
|
Object.setPrototypeOf(this, ko_subscribable_fn);
|
|
1373
1413
|
ko_subscribable_fn.init(this);
|
|
1374
|
-
}
|
|
1414
|
+
};
|
|
1375
1415
|
var defaultEvent = "change";
|
|
1376
1416
|
var ko_subscribable_fn = {
|
|
1377
1417
|
[SUBSCRIBABLE_SYM]: true,
|
|
@@ -1385,9 +1425,7 @@ var ko_subscribable_fn = {
|
|
|
1385
1425
|
subscribe(callback, callbackTarget, event) {
|
|
1386
1426
|
const isTC39Callback = typeof callback === "object" && callback.next;
|
|
1387
1427
|
event = event || defaultEvent;
|
|
1388
|
-
const observer = isTC39Callback ? callback : {
|
|
1389
|
-
next: callbackTarget ? callback.bind(callbackTarget) : callback
|
|
1390
|
-
};
|
|
1428
|
+
const observer = isTC39Callback ? callback : { next: callbackTarget ? callback.bind(callbackTarget) : callback };
|
|
1391
1429
|
const subscriptionInstance = new Subscription(this, observer, () => {
|
|
1392
1430
|
arrayRemoveItem(this._subscriptions[event], subscriptionInstance);
|
|
1393
1431
|
if (this.afterSubscriptionRemove) {
|
|
@@ -1398,7 +1436,7 @@ var ko_subscribable_fn = {
|
|
|
1398
1436
|
this.beforeSubscriptionAdd(event);
|
|
1399
1437
|
}
|
|
1400
1438
|
if (!this._subscriptions[event]) {
|
|
1401
|
-
this._subscriptions[event] =
|
|
1439
|
+
this._subscriptions[event] = new Array();
|
|
1402
1440
|
}
|
|
1403
1441
|
this._subscriptions[event].push(subscriptionInstance);
|
|
1404
1442
|
if (isTC39Callback && LATEST_VALUE in this) {
|
|
@@ -1441,7 +1479,7 @@ var ko_subscribable_fn = {
|
|
|
1441
1479
|
if (event) {
|
|
1442
1480
|
return this._subscriptions[event] && this._subscriptions[event].length || 0;
|
|
1443
1481
|
} else {
|
|
1444
|
-
|
|
1482
|
+
let total = 0;
|
|
1445
1483
|
objectForEach(this._subscriptions, function(eventName, subscriptions) {
|
|
1446
1484
|
if (eventName !== "dirty") {
|
|
1447
1485
|
total += subscriptions.length;
|
|
@@ -1496,6 +1534,7 @@ function observable(initialValue) {
|
|
|
1496
1534
|
function Observable() {
|
|
1497
1535
|
if (arguments.length > 0) {
|
|
1498
1536
|
if (Observable.isDifferent(Observable[LATEST_VALUE], arguments[0])) {
|
|
1537
|
+
;
|
|
1499
1538
|
Observable.valueWillMutate();
|
|
1500
1539
|
Observable[LATEST_VALUE] = arguments[0];
|
|
1501
1540
|
Observable.valueHasMutated();
|
|
@@ -1516,20 +1555,43 @@ function observable(initialValue) {
|
|
|
1516
1555
|
return Observable;
|
|
1517
1556
|
}
|
|
1518
1557
|
observable.fn = {
|
|
1558
|
+
/**
|
|
1559
|
+
* Compares two values for equality.
|
|
1560
|
+
* @param a The first value.
|
|
1561
|
+
* @param b The second value.
|
|
1562
|
+
* @returns True if the values are equal, otherwise false.
|
|
1563
|
+
*/
|
|
1519
1564
|
equalityComparer: valuesArePrimitiveAndEqual,
|
|
1565
|
+
/**
|
|
1566
|
+
* Returns the current value of the observable without creating a dependency.
|
|
1567
|
+
* @returns The current value.
|
|
1568
|
+
*/
|
|
1520
1569
|
peek() {
|
|
1521
1570
|
return this[LATEST_VALUE];
|
|
1522
1571
|
},
|
|
1572
|
+
/**
|
|
1573
|
+
* Notifies subscribers that the value has changed.
|
|
1574
|
+
*/
|
|
1523
1575
|
valueHasMutated() {
|
|
1524
1576
|
this.notifySubscribers(this[LATEST_VALUE], "spectate");
|
|
1525
1577
|
this.notifySubscribers(this[LATEST_VALUE]);
|
|
1526
1578
|
},
|
|
1579
|
+
/**
|
|
1580
|
+
* Notifies subscribers that the value is about to change.
|
|
1581
|
+
*/
|
|
1527
1582
|
valueWillMutate() {
|
|
1528
1583
|
this.notifySubscribers(this[LATEST_VALUE], "beforeChange");
|
|
1529
1584
|
},
|
|
1585
|
+
/**
|
|
1586
|
+
* Modifies the value of the observable using a function.
|
|
1587
|
+
* @param fn The function to modify the value.
|
|
1588
|
+
* @param peek Whether to use the current value without creating a dependency.
|
|
1589
|
+
* @returns The modified observable.
|
|
1590
|
+
*/
|
|
1530
1591
|
modify(fn, peek22 = true) {
|
|
1531
|
-
|
|
1592
|
+
this(fn(peek22 ? this.peek() : this()));
|
|
1532
1593
|
},
|
|
1594
|
+
// Some observables may not always be writeable, notably computeds.
|
|
1533
1595
|
isWriteable: true
|
|
1534
1596
|
};
|
|
1535
1597
|
function limitNotifySubscribers(value2, event) {
|
|
@@ -1542,15 +1604,15 @@ function limitNotifySubscribers(value2, event) {
|
|
|
1542
1604
|
}
|
|
1543
1605
|
}
|
|
1544
1606
|
subscribable.fn.limit = function limit(limitFunction) {
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1607
|
+
const self = this;
|
|
1608
|
+
const selfIsObservable = isObservable(self);
|
|
1609
|
+
const beforeChange = "beforeChange";
|
|
1610
|
+
let ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate;
|
|
1549
1611
|
if (!self._origNotifySubscribers) {
|
|
1550
1612
|
self._origNotifySubscribers = self.notifySubscribers;
|
|
1551
1613
|
self.notifySubscribers = limitNotifySubscribers;
|
|
1552
1614
|
}
|
|
1553
|
-
|
|
1615
|
+
const finish = limitFunction(function() {
|
|
1554
1616
|
self._notificationIsPending = false;
|
|
1555
1617
|
if (selfIsObservable && pendingValue === self) {
|
|
1556
1618
|
pendingValue = self._evalIfChanged ? self._evalIfChanged() : self();
|
|
@@ -1578,7 +1640,10 @@ subscribable.fn.limit = function limit(limitFunction) {
|
|
|
1578
1640
|
}
|
|
1579
1641
|
},
|
|
1580
1642
|
_notifyNextChangeIfValueIsDifferent() {
|
|
1581
|
-
if (self.isDifferent(previousValue, self.peek(
|
|
1643
|
+
if (self.isDifferent(previousValue, self.peek(
|
|
1644
|
+
true
|
|
1645
|
+
/* evaluate */
|
|
1646
|
+
))) {
|
|
1582
1647
|
notifyNextChange = true;
|
|
1583
1648
|
}
|
|
1584
1649
|
},
|
|
@@ -1621,8 +1686,8 @@ function trackArrayChanges(target, options3) {
|
|
|
1621
1686
|
let arrayChangeSubscription;
|
|
1622
1687
|
let pendingNotifications = 0;
|
|
1623
1688
|
let underlyingNotifySubscribersFunction;
|
|
1624
|
-
|
|
1625
|
-
|
|
1689
|
+
const underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd;
|
|
1690
|
+
const underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;
|
|
1626
1691
|
target.beforeSubscriptionAdd = function(event) {
|
|
1627
1692
|
if (underlyingBeforeSubscriptionAddFunction) {
|
|
1628
1693
|
underlyingBeforeSubscriptionAddFunction.call(target, event);
|
|
@@ -1659,11 +1724,11 @@ function trackArrayChanges(target, options3) {
|
|
|
1659
1724
|
}
|
|
1660
1725
|
return underlyingNotifySubscribersFunction.apply(this, arguments);
|
|
1661
1726
|
};
|
|
1662
|
-
|
|
1727
|
+
let previousContents = new Array().concat(target.peek() === void 0 ? [] : target.peek());
|
|
1663
1728
|
cachedDiff = null;
|
|
1664
1729
|
arrayChangeSubscription = target.subscribe(function(currentContents) {
|
|
1665
1730
|
let changes;
|
|
1666
|
-
currentContents =
|
|
1731
|
+
currentContents = new Array().concat(currentContents || []);
|
|
1667
1732
|
if (target.hasSubscriptionsForEvent(arrayChangeEventName)) {
|
|
1668
1733
|
changes = getChanges(previousContents, currentContents);
|
|
1669
1734
|
}
|
|
@@ -1685,9 +1750,9 @@ function trackArrayChanges(target, options3) {
|
|
|
1685
1750
|
if (!trackingChanges || pendingNotifications) {
|
|
1686
1751
|
return;
|
|
1687
1752
|
}
|
|
1688
|
-
|
|
1753
|
+
let diff = new Array(), arrayLength = rawArray.length, argsLength = args.length, offset = 0;
|
|
1689
1754
|
function pushDiff(status, value2, index) {
|
|
1690
|
-
return diff[diff.length] = {
|
|
1755
|
+
return diff[diff.length] = { status, value: value2, index };
|
|
1691
1756
|
}
|
|
1692
1757
|
switch (operationName) {
|
|
1693
1758
|
case "push":
|
|
@@ -1705,16 +1770,18 @@ function trackArrayChanges(target, options3) {
|
|
|
1705
1770
|
}
|
|
1706
1771
|
break;
|
|
1707
1772
|
case "splice":
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1773
|
+
{
|
|
1774
|
+
const 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 = new Array(), deletions = new Array();
|
|
1775
|
+
for (let index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {
|
|
1776
|
+
if (index < endDeleteIndex) {
|
|
1777
|
+
deletions.push(pushDiff("deleted", rawArray[index], index));
|
|
1778
|
+
}
|
|
1779
|
+
if (index < endAddIndex) {
|
|
1780
|
+
additions.push(pushDiff("added", args[argsIndex], index));
|
|
1781
|
+
}
|
|
1715
1782
|
}
|
|
1783
|
+
findMovesInArrayComparison(deletions, additions);
|
|
1716
1784
|
}
|
|
1717
|
-
findMovesInArrayComparison(deletions, additions);
|
|
1718
1785
|
break;
|
|
1719
1786
|
default:
|
|
1720
1787
|
return;
|
|
@@ -1729,23 +1796,27 @@ extenders.trackArrayChanges = trackArrayChanges;
|
|
|
1729
1796
|
function observableArray(initialValues) {
|
|
1730
1797
|
initialValues = initialValues || [];
|
|
1731
1798
|
if (typeof initialValues !== "object" || !("length" in initialValues)) {
|
|
1732
|
-
throw new Error(
|
|
1799
|
+
throw new Error(
|
|
1800
|
+
"The argument passed when initializing an observable array must be an array, or null, or undefined."
|
|
1801
|
+
);
|
|
1733
1802
|
}
|
|
1734
|
-
|
|
1735
|
-
Object.setPrototypeOf(result, observableArray.fn);
|
|
1803
|
+
const result = Object.setPrototypeOf(observable(initialValues), observableArray.fn);
|
|
1736
1804
|
trackArrayChanges(result);
|
|
1737
|
-
overwriteLengthPropertyIfSupported(result, { get: () =>
|
|
1805
|
+
overwriteLengthPropertyIfSupported(result, { get: () => {
|
|
1806
|
+
var _a;
|
|
1807
|
+
return (_a = result()) == null ? void 0 : _a.length;
|
|
1808
|
+
} });
|
|
1738
1809
|
return result;
|
|
1739
1810
|
}
|
|
1740
1811
|
observableArray.fn = {
|
|
1741
1812
|
remove(valueOrPredicate) {
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
return
|
|
1813
|
+
const underlyingArray = this.peek();
|
|
1814
|
+
const removedValues = new Array();
|
|
1815
|
+
const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value2) {
|
|
1816
|
+
return value2 === valueOrPredicate;
|
|
1746
1817
|
};
|
|
1747
|
-
for (
|
|
1748
|
-
|
|
1818
|
+
for (let i = 0; i < underlyingArray.length; i++) {
|
|
1819
|
+
const value2 = underlyingArray[i];
|
|
1749
1820
|
if (predicate(value2)) {
|
|
1750
1821
|
if (removedValues.length === 0) {
|
|
1751
1822
|
this.valueWillMutate();
|
|
@@ -1765,8 +1836,8 @@ observableArray.fn = {
|
|
|
1765
1836
|
},
|
|
1766
1837
|
removeAll(arrayOfValues) {
|
|
1767
1838
|
if (arrayOfValues === void 0) {
|
|
1768
|
-
|
|
1769
|
-
|
|
1839
|
+
const underlyingArray = this.peek();
|
|
1840
|
+
const allValues = underlyingArray.slice(0);
|
|
1770
1841
|
this.valueWillMutate();
|
|
1771
1842
|
underlyingArray.splice(0, underlyingArray.length);
|
|
1772
1843
|
this.valueHasMutated();
|
|
@@ -1780,13 +1851,13 @@ observableArray.fn = {
|
|
|
1780
1851
|
});
|
|
1781
1852
|
},
|
|
1782
1853
|
destroy(valueOrPredicate) {
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
return
|
|
1854
|
+
const underlyingArray = this.peek();
|
|
1855
|
+
const predicate = typeof valueOrPredicate === "function" && !isObservable(valueOrPredicate) ? valueOrPredicate : function(value2) {
|
|
1856
|
+
return value2 === valueOrPredicate;
|
|
1786
1857
|
};
|
|
1787
1858
|
this.valueWillMutate();
|
|
1788
|
-
for (
|
|
1789
|
-
|
|
1859
|
+
for (let i = underlyingArray.length - 1; i >= 0; i--) {
|
|
1860
|
+
const value2 = underlyingArray[i];
|
|
1790
1861
|
if (predicate(value2)) {
|
|
1791
1862
|
value2["_destroy"] = true;
|
|
1792
1863
|
}
|
|
@@ -1810,7 +1881,7 @@ observableArray.fn = {
|
|
|
1810
1881
|
return arrayIndexOf(this(), item);
|
|
1811
1882
|
},
|
|
1812
1883
|
replace(oldItem, newItem) {
|
|
1813
|
-
|
|
1884
|
+
const index = this.indexOf(oldItem);
|
|
1814
1885
|
if (index >= 0) {
|
|
1815
1886
|
this.valueWillMutate();
|
|
1816
1887
|
this.peek()[index] = newItem;
|
|
@@ -1824,23 +1895,23 @@ observableArray.fn = {
|
|
|
1824
1895
|
return [...this()].reverse();
|
|
1825
1896
|
},
|
|
1826
1897
|
[Symbol.iterator]: function* () {
|
|
1827
|
-
yield* this();
|
|
1898
|
+
yield* __yieldStar(this());
|
|
1828
1899
|
}
|
|
1829
1900
|
};
|
|
1830
1901
|
Object.setPrototypeOf(observableArray.fn, observable.fn);
|
|
1831
1902
|
arrayForEach(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function(methodName) {
|
|
1832
1903
|
observableArray.fn[methodName] = function() {
|
|
1833
|
-
|
|
1904
|
+
const underlyingArray = this.peek();
|
|
1834
1905
|
this.valueWillMutate();
|
|
1835
1906
|
this.cacheDiffForKnownOperation(underlyingArray, methodName, arguments);
|
|
1836
|
-
|
|
1907
|
+
const methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);
|
|
1837
1908
|
this.valueHasMutated();
|
|
1838
1909
|
return methodCallResult === underlyingArray ? this : methodCallResult;
|
|
1839
1910
|
};
|
|
1840
1911
|
});
|
|
1841
1912
|
arrayForEach(["slice"], function(methodName) {
|
|
1842
1913
|
observableArray.fn[methodName] = function() {
|
|
1843
|
-
|
|
1914
|
+
const underlyingArray = this();
|
|
1844
1915
|
return underlyingArray[methodName].apply(underlyingArray, arguments);
|
|
1845
1916
|
};
|
|
1846
1917
|
});
|
|
@@ -1848,12 +1919,12 @@ observableArray.trackArrayChanges = trackArrayChanges;
|
|
|
1848
1919
|
|
|
1849
1920
|
// src/attr.ts
|
|
1850
1921
|
var attr = {
|
|
1851
|
-
update: function(element, valueAccessor,
|
|
1852
|
-
|
|
1922
|
+
update: function(element, valueAccessor, _allBindings) {
|
|
1923
|
+
const value2 = unwrap(valueAccessor()) || {};
|
|
1853
1924
|
objectForEach(value2, function(attrName, attrValue) {
|
|
1854
1925
|
attrValue = unwrap(attrValue);
|
|
1855
|
-
|
|
1856
|
-
|
|
1926
|
+
const prefixLen = attrName.indexOf(":");
|
|
1927
|
+
const namespace = prefixLen > 0 && element.lookupNamespaceURI(attrName.substr(0, prefixLen));
|
|
1857
1928
|
const toRemove = attrValue === false || attrValue === null || attrValue === void 0;
|
|
1858
1929
|
if (toRemove) {
|
|
1859
1930
|
if (namespace) {
|
|
@@ -1870,7 +1941,7 @@ var attr = {
|
|
|
1870
1941
|
}
|
|
1871
1942
|
}
|
|
1872
1943
|
if (attrName === "name") {
|
|
1873
|
-
|
|
1944
|
+
element.name = toRemove ? "" : attrValue;
|
|
1874
1945
|
}
|
|
1875
1946
|
});
|
|
1876
1947
|
}
|
|
@@ -1898,11 +1969,11 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options22
|
|
|
1898
1969
|
options22.read = evaluatorFunctionOrOptions;
|
|
1899
1970
|
}
|
|
1900
1971
|
}
|
|
1901
|
-
if (typeof options22.read !== "function") {
|
|
1972
|
+
if (typeof (options22 == null ? void 0 : options22.read) !== "function") {
|
|
1902
1973
|
throw Error("Pass a function that returns the value of the computed");
|
|
1903
1974
|
}
|
|
1904
|
-
|
|
1905
|
-
|
|
1975
|
+
const writeFunction = options22.write;
|
|
1976
|
+
const state = {
|
|
1906
1977
|
latestValue: void 0,
|
|
1907
1978
|
isStale: true,
|
|
1908
1979
|
isDirty: true,
|
|
@@ -1913,8 +1984,8 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options22
|
|
|
1913
1984
|
isSleeping: false,
|
|
1914
1985
|
readFunction: options22.read,
|
|
1915
1986
|
evaluatorFunctionTarget: evaluatorFunctionTarget || options22.owner,
|
|
1916
|
-
disposeWhenNodeIsRemoved: options22.disposeWhenNodeIsRemoved ||
|
|
1917
|
-
disposeWhen: options22.disposeWhen
|
|
1987
|
+
disposeWhenNodeIsRemoved: options22.disposeWhenNodeIsRemoved || null,
|
|
1988
|
+
disposeWhen: options22.disposeWhen,
|
|
1918
1989
|
domNodeDisposalCallback: null,
|
|
1919
1990
|
dependencyTracking: {},
|
|
1920
1991
|
dependenciesCount: 0,
|
|
@@ -1925,7 +1996,9 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options22
|
|
|
1925
1996
|
if (typeof writeFunction === "function") {
|
|
1926
1997
|
writeFunction.apply(state.evaluatorFunctionTarget, arguments);
|
|
1927
1998
|
} else {
|
|
1928
|
-
throw new Error(
|
|
1999
|
+
throw new Error(
|
|
2000
|
+
"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."
|
|
2001
|
+
);
|
|
1929
2002
|
}
|
|
1930
2003
|
return this;
|
|
1931
2004
|
} else {
|
|
@@ -1933,6 +2006,7 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options22
|
|
|
1933
2006
|
dependencyDetection_exports.registerDependency(computedObservable);
|
|
1934
2007
|
}
|
|
1935
2008
|
if (state.isDirty || state.isSleeping && computedObservable.haveDependenciesChanged()) {
|
|
2009
|
+
;
|
|
1936
2010
|
computedObservable.evaluateImmediate();
|
|
1937
2011
|
}
|
|
1938
2012
|
return state.latestValue;
|
|
@@ -1962,12 +2036,17 @@ function computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, options22
|
|
|
1962
2036
|
}
|
|
1963
2037
|
}
|
|
1964
2038
|
if (!state.isSleeping && !options22.deferEvaluation) {
|
|
2039
|
+
;
|
|
1965
2040
|
computedObservable.evaluateImmediate();
|
|
1966
2041
|
}
|
|
1967
2042
|
if (state.disposeWhenNodeIsRemoved && computedObservable.isActive()) {
|
|
1968
|
-
addDisposeCallback(
|
|
1969
|
-
|
|
1970
|
-
|
|
2043
|
+
addDisposeCallback(
|
|
2044
|
+
state.disposeWhenNodeIsRemoved,
|
|
2045
|
+
state.domNodeDisposalCallback = function() {
|
|
2046
|
+
;
|
|
2047
|
+
computedObservable.dispose();
|
|
2048
|
+
}
|
|
2049
|
+
);
|
|
1971
2050
|
}
|
|
1972
2051
|
return computedObservable;
|
|
1973
2052
|
}
|
|
@@ -1977,14 +2056,18 @@ function computedDisposeDependencyCallback(id, entryToDispose) {
|
|
|
1977
2056
|
}
|
|
1978
2057
|
}
|
|
1979
2058
|
function computedBeginDependencyDetectionCallback(subscribable2, id) {
|
|
1980
|
-
|
|
2059
|
+
const computedObservable = this.computedObservable, state = computedObservable[computedState];
|
|
1981
2060
|
if (!state.isDisposed) {
|
|
1982
2061
|
if (this.disposalCount && this.disposalCandidates[id]) {
|
|
1983
2062
|
computedObservable.addDependencyTracking(id, subscribable2, this.disposalCandidates[id]);
|
|
1984
2063
|
this.disposalCandidates[id] = null;
|
|
1985
2064
|
--this.disposalCount;
|
|
1986
2065
|
} else if (!state.dependencyTracking[id]) {
|
|
1987
|
-
computedObservable.addDependencyTracking(
|
|
2066
|
+
computedObservable.addDependencyTracking(
|
|
2067
|
+
id,
|
|
2068
|
+
subscribable2,
|
|
2069
|
+
state.isSleeping ? { _target: subscribable2 } : computedObservable.subscribeToDependency(subscribable2)
|
|
2070
|
+
);
|
|
1988
2071
|
}
|
|
1989
2072
|
if (subscribable2._notificationIsPending) {
|
|
1990
2073
|
subscribable2._notifyNextChangeIfValueIsDifferent();
|
|
@@ -1998,7 +2081,7 @@ computed.fn = {
|
|
|
1998
2081
|
},
|
|
1999
2082
|
getDependencies() {
|
|
2000
2083
|
const dependencyTracking = this[computedState].dependencyTracking;
|
|
2001
|
-
const dependentObservables =
|
|
2084
|
+
const dependentObservables = new Array();
|
|
2002
2085
|
objectForEach(dependencyTracking, function(id, dependency) {
|
|
2003
2086
|
dependentObservables[dependency._order] = dependency._target;
|
|
2004
2087
|
});
|
|
@@ -2013,7 +2096,7 @@ computed.fn = {
|
|
|
2013
2096
|
trackingObj._version = target.getVersion();
|
|
2014
2097
|
},
|
|
2015
2098
|
haveDependenciesChanged() {
|
|
2016
|
-
|
|
2099
|
+
let id, dependency, dependencyTracking = this[computedState].dependencyTracking;
|
|
2017
2100
|
for (id in dependencyTracking) {
|
|
2018
2101
|
if (hasOwnProperty(dependencyTracking, id)) {
|
|
2019
2102
|
dependency = dependencyTracking[id];
|
|
@@ -2022,10 +2105,14 @@ computed.fn = {
|
|
|
2022
2105
|
}
|
|
2023
2106
|
}
|
|
2024
2107
|
}
|
|
2108
|
+
return false;
|
|
2025
2109
|
},
|
|
2026
2110
|
markDirty() {
|
|
2027
2111
|
if (this._evalDelayed && !this[computedState].isBeingEvaluated) {
|
|
2028
|
-
this._evalDelayed(
|
|
2112
|
+
this._evalDelayed(
|
|
2113
|
+
false
|
|
2114
|
+
/* notifyChange */
|
|
2115
|
+
);
|
|
2029
2116
|
}
|
|
2030
2117
|
},
|
|
2031
2118
|
isActive() {
|
|
@@ -2041,7 +2128,7 @@ computed.fn = {
|
|
|
2041
2128
|
},
|
|
2042
2129
|
subscribeToDependency(target) {
|
|
2043
2130
|
if (target._deferUpdates) {
|
|
2044
|
-
|
|
2131
|
+
const dirtySub = target.subscribe(this.markDirty, this, "dirty"), changeSub = target.subscribe(this.respondToChange, this);
|
|
2045
2132
|
return {
|
|
2046
2133
|
_target: target,
|
|
2047
2134
|
dispose() {
|
|
@@ -2054,20 +2141,29 @@ computed.fn = {
|
|
|
2054
2141
|
}
|
|
2055
2142
|
},
|
|
2056
2143
|
evaluatePossiblyAsync() {
|
|
2057
|
-
|
|
2144
|
+
const computedObservable = this, throttleEvaluationTimeout = computedObservable.throttleEvaluation;
|
|
2058
2145
|
if (throttleEvaluationTimeout && throttleEvaluationTimeout >= 0) {
|
|
2059
2146
|
clearTimeout(this[computedState].evaluationTimeoutInstance);
|
|
2060
2147
|
this[computedState].evaluationTimeoutInstance = safeSetTimeout(function() {
|
|
2061
|
-
computedObservable.evaluateImmediate(
|
|
2148
|
+
computedObservable.evaluateImmediate(
|
|
2149
|
+
true
|
|
2150
|
+
/* notifyChange */
|
|
2151
|
+
);
|
|
2062
2152
|
}, throttleEvaluationTimeout);
|
|
2063
2153
|
} else if (computedObservable._evalDelayed) {
|
|
2064
|
-
computedObservable._evalDelayed(
|
|
2154
|
+
computedObservable._evalDelayed(
|
|
2155
|
+
true
|
|
2156
|
+
/* notifyChange */
|
|
2157
|
+
);
|
|
2065
2158
|
} else {
|
|
2066
|
-
computedObservable.evaluateImmediate(
|
|
2159
|
+
computedObservable.evaluateImmediate(
|
|
2160
|
+
true
|
|
2161
|
+
/* notifyChange */
|
|
2162
|
+
);
|
|
2067
2163
|
}
|
|
2068
2164
|
},
|
|
2069
2165
|
evaluateImmediate(notifyChange) {
|
|
2070
|
-
|
|
2166
|
+
let computedObservable = this, state = computedObservable[computedState], disposeWhen = state.disposeWhen, changed = false;
|
|
2071
2167
|
if (state.isBeingEvaluated) {
|
|
2072
2168
|
return;
|
|
2073
2169
|
}
|
|
@@ -2091,8 +2187,8 @@ computed.fn = {
|
|
|
2091
2187
|
return changed;
|
|
2092
2188
|
},
|
|
2093
2189
|
evaluateImmediate_CallReadWithDependencyDetection(notifyChange) {
|
|
2094
|
-
|
|
2095
|
-
|
|
2190
|
+
let computedObservable = this, state = computedObservable[computedState], changed = false;
|
|
2191
|
+
const isInitial2 = state.pure ? void 0 : !state.dependenciesCount, dependencyDetectionContext = {
|
|
2096
2192
|
computedObservable,
|
|
2097
2193
|
disposalCandidates: state.dependencyTracking,
|
|
2098
2194
|
disposalCount: state.dependenciesCount
|
|
@@ -2105,7 +2201,7 @@ computed.fn = {
|
|
|
2105
2201
|
});
|
|
2106
2202
|
state.dependencyTracking = {};
|
|
2107
2203
|
state.dependenciesCount = 0;
|
|
2108
|
-
|
|
2204
|
+
const newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);
|
|
2109
2205
|
if (!state.dependenciesCount) {
|
|
2110
2206
|
computedObservable.dispose();
|
|
2111
2207
|
changed = true;
|
|
@@ -2137,7 +2233,7 @@ computed.fn = {
|
|
|
2137
2233
|
},
|
|
2138
2234
|
evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext) {
|
|
2139
2235
|
try {
|
|
2140
|
-
|
|
2236
|
+
const readFunction = state.readFunction;
|
|
2141
2237
|
return state.evaluatorFunctionTarget ? readFunction.call(state.evaluatorFunctionTarget) : readFunction();
|
|
2142
2238
|
} finally {
|
|
2143
2239
|
dependencyDetection_exports.end();
|
|
@@ -2177,12 +2273,16 @@ computed.fn = {
|
|
|
2177
2273
|
if (isChange) {
|
|
2178
2274
|
state.isStale = true;
|
|
2179
2275
|
}
|
|
2180
|
-
this._limitChange(
|
|
2276
|
+
this._limitChange(
|
|
2277
|
+
this,
|
|
2278
|
+
!isChange
|
|
2279
|
+
/* isDirty */
|
|
2280
|
+
);
|
|
2181
2281
|
}
|
|
2182
2282
|
});
|
|
2183
2283
|
},
|
|
2184
2284
|
dispose() {
|
|
2185
|
-
|
|
2285
|
+
const state = this[computedState];
|
|
2186
2286
|
if (!state.isSleeping && state.dependencyTracking) {
|
|
2187
2287
|
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
2188
2288
|
if (dependency.dispose) {
|
|
@@ -2198,7 +2298,7 @@ computed.fn = {
|
|
|
2198
2298
|
};
|
|
2199
2299
|
var pureComputedOverrides = {
|
|
2200
2300
|
beforeSubscriptionAdd(event) {
|
|
2201
|
-
|
|
2301
|
+
const computedObservable = this, state = computedObservable[computedState];
|
|
2202
2302
|
if (!state.isDisposed && state.isSleeping && event === "change") {
|
|
2203
2303
|
state.isSleeping = false;
|
|
2204
2304
|
if (state.isStale || computedObservable.haveDependenciesChanged()) {
|
|
@@ -2208,12 +2308,12 @@ var pureComputedOverrides = {
|
|
|
2208
2308
|
computedObservable.updateVersion();
|
|
2209
2309
|
}
|
|
2210
2310
|
} else {
|
|
2211
|
-
|
|
2311
|
+
const dependenciesOrder = new Array();
|
|
2212
2312
|
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
2213
2313
|
dependenciesOrder[dependency._order] = id;
|
|
2214
2314
|
});
|
|
2215
2315
|
arrayForEach(dependenciesOrder, function(id, order) {
|
|
2216
|
-
|
|
2316
|
+
const dependency = state.dependencyTracking[id], subscription = computedObservable.subscribeToDependency(dependency._target);
|
|
2217
2317
|
subscription._order = order;
|
|
2218
2318
|
subscription._version = dependency._version;
|
|
2219
2319
|
state.dependencyTracking[id] = subscription;
|
|
@@ -2230,7 +2330,7 @@ var pureComputedOverrides = {
|
|
|
2230
2330
|
}
|
|
2231
2331
|
},
|
|
2232
2332
|
afterSubscriptionRemove(event) {
|
|
2233
|
-
|
|
2333
|
+
const state = this[computedState];
|
|
2234
2334
|
if (!state.isDisposed && event === "change" && !this.hasSubscriptionsForEvent("change")) {
|
|
2235
2335
|
objectForEach(state.dependencyTracking, function(id, dependency) {
|
|
2236
2336
|
if (dependency.dispose) {
|
|
@@ -2247,7 +2347,7 @@ var pureComputedOverrides = {
|
|
|
2247
2347
|
}
|
|
2248
2348
|
},
|
|
2249
2349
|
getVersion() {
|
|
2250
|
-
|
|
2350
|
+
const state = this[computedState];
|
|
2251
2351
|
if (state.isSleeping && (state.isStale || this.haveDependenciesChanged())) {
|
|
2252
2352
|
this.evaluateImmediate();
|
|
2253
2353
|
}
|
|
@@ -2267,18 +2367,20 @@ computed.fn[protoProp] = computed;
|
|
|
2267
2367
|
observable.observablePrototypes.add(computed);
|
|
2268
2368
|
function pureComputed(evaluatorFunctionOrOptions, evaluatorFunctionTarget) {
|
|
2269
2369
|
if (typeof evaluatorFunctionOrOptions === "function") {
|
|
2270
|
-
|
|
2370
|
+
const evaluator = evaluatorFunctionOrOptions;
|
|
2371
|
+
return computed(evaluator, evaluatorFunctionTarget, { pure: true });
|
|
2271
2372
|
} else {
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2373
|
+
let options22 = evaluatorFunctionOrOptions;
|
|
2374
|
+
options22 = extend({}, options22);
|
|
2375
|
+
options22.pure = true;
|
|
2376
|
+
return computed(options22, evaluatorFunctionTarget);
|
|
2275
2377
|
}
|
|
2276
2378
|
}
|
|
2277
2379
|
|
|
2278
2380
|
// ../computed/dist/throttleExtender.js
|
|
2279
2381
|
function throttleExtender(target, timeout) {
|
|
2280
2382
|
target.throttleEvaluation = timeout;
|
|
2281
|
-
|
|
2383
|
+
let writeTimeoutInstance = void 0;
|
|
2282
2384
|
return computed({
|
|
2283
2385
|
read: target,
|
|
2284
2386
|
write: function(value2) {
|
|
@@ -2289,11 +2391,12 @@ function throttleExtender(target, timeout) {
|
|
|
2289
2391
|
}
|
|
2290
2392
|
});
|
|
2291
2393
|
}
|
|
2292
|
-
|
|
2394
|
+
var extenders2 = extenders;
|
|
2395
|
+
extenders2.throttle = throttleExtender;
|
|
2293
2396
|
|
|
2294
2397
|
// ../computed/dist/proxy.js
|
|
2295
|
-
var PROXY_SYM = Symbol("Knockout Proxied Object");
|
|
2296
|
-
var MIRROR_SYM = Symbol("Knockout Proxied Observables");
|
|
2398
|
+
var PROXY_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Object");
|
|
2399
|
+
var MIRROR_SYM = /* @__PURE__ */ Symbol("Knockout Proxied Observables");
|
|
2297
2400
|
function makeComputed(proxy2, fn) {
|
|
2298
2401
|
return computed({
|
|
2299
2402
|
owner: proxy2,
|
|
@@ -2311,14 +2414,14 @@ function setOrCreate(mirror, prop, value2, proxy2) {
|
|
|
2311
2414
|
mirror[prop](value2);
|
|
2312
2415
|
}
|
|
2313
2416
|
}
|
|
2314
|
-
function assignOrUpdate(mirror,
|
|
2315
|
-
for (const key of Object.keys(
|
|
2316
|
-
setOrCreate(mirror, key,
|
|
2417
|
+
function assignOrUpdate(mirror, object, proxy2) {
|
|
2418
|
+
for (const key of Object.keys(object)) {
|
|
2419
|
+
setOrCreate(mirror, key, object[key], proxy2);
|
|
2317
2420
|
}
|
|
2318
|
-
return
|
|
2421
|
+
return object;
|
|
2319
2422
|
}
|
|
2320
|
-
function proxy(
|
|
2321
|
-
const mirror = { [PROXY_SYM]:
|
|
2423
|
+
function proxy(object) {
|
|
2424
|
+
const mirror = { [PROXY_SYM]: object };
|
|
2322
2425
|
mirror[MIRROR_SYM] = mirror;
|
|
2323
2426
|
const proxy2 = new Proxy(function() {
|
|
2324
2427
|
}, {
|
|
@@ -2330,43 +2433,40 @@ function proxy(object2) {
|
|
|
2330
2433
|
},
|
|
2331
2434
|
set(target, prop, value2, receiver) {
|
|
2332
2435
|
setOrCreate(mirror, prop, value2, proxy2);
|
|
2333
|
-
|
|
2436
|
+
object[prop] = value2;
|
|
2334
2437
|
return true;
|
|
2335
2438
|
},
|
|
2336
2439
|
deleteProperty(property) {
|
|
2337
2440
|
delete mirror[property];
|
|
2338
|
-
return delete
|
|
2441
|
+
return delete object[property];
|
|
2339
2442
|
},
|
|
2340
2443
|
apply(target, thisArg, [props]) {
|
|
2341
2444
|
if (props) {
|
|
2342
2445
|
assignOrUpdate(mirror, props, proxy2);
|
|
2343
|
-
return Object.assign(
|
|
2446
|
+
return Object.assign(object, props);
|
|
2344
2447
|
}
|
|
2345
|
-
return
|
|
2448
|
+
return object;
|
|
2346
2449
|
},
|
|
2347
2450
|
getPrototypeOf() {
|
|
2348
|
-
return Object.getPrototypeOf(
|
|
2451
|
+
return Object.getPrototypeOf(object);
|
|
2349
2452
|
},
|
|
2350
2453
|
setPrototypeOf(target, proto) {
|
|
2351
|
-
return Object.setPrototypeOf(
|
|
2454
|
+
return Object.setPrototypeOf(object, proto);
|
|
2352
2455
|
},
|
|
2353
2456
|
defineProperty(target, prop, desc) {
|
|
2354
|
-
return Object.defineProperty(
|
|
2457
|
+
return Object.defineProperty(object, prop, desc);
|
|
2355
2458
|
},
|
|
2356
2459
|
preventExtensions() {
|
|
2357
|
-
return Object.preventExtensions(
|
|
2460
|
+
return Object.preventExtensions(object);
|
|
2358
2461
|
},
|
|
2359
2462
|
isExtensible() {
|
|
2360
|
-
return Object.isExtensible(
|
|
2463
|
+
return Object.isExtensible(object);
|
|
2361
2464
|
},
|
|
2362
2465
|
ownKeys() {
|
|
2363
|
-
return [
|
|
2364
|
-
...Object.getOwnPropertyNames(object2),
|
|
2365
|
-
...Object.getOwnPropertySymbols(object2)
|
|
2366
|
-
];
|
|
2466
|
+
return [...Object.getOwnPropertyNames(object), ...Object.getOwnPropertySymbols(object)];
|
|
2367
2467
|
}
|
|
2368
2468
|
});
|
|
2369
|
-
assignOrUpdate(mirror,
|
|
2469
|
+
assignOrUpdate(mirror, object, proxy2);
|
|
2370
2470
|
return proxy2;
|
|
2371
2471
|
}
|
|
2372
2472
|
function getObservable(proxied, prop) {
|
|
@@ -2384,7 +2484,7 @@ Object.assign(proxy, { getObservable, peek: peek2, isProxied });
|
|
|
2384
2484
|
var checked = {
|
|
2385
2485
|
after: ["value", "attr"],
|
|
2386
2486
|
init: function(element, valueAccessor, allBindings) {
|
|
2387
|
-
|
|
2487
|
+
const checkedValue2 = pureComputed(function() {
|
|
2388
2488
|
if (allBindings.has("checkedValue")) {
|
|
2389
2489
|
return unwrap(allBindings.get("checkedValue"));
|
|
2390
2490
|
} else if (useElementValue) {
|
|
@@ -2396,16 +2496,16 @@ var checked = {
|
|
|
2396
2496
|
}
|
|
2397
2497
|
});
|
|
2398
2498
|
function updateModel() {
|
|
2399
|
-
|
|
2499
|
+
let isChecked = element.checked, elemValue = checkedValue2();
|
|
2400
2500
|
if (dependencyDetection_exports.isInitial()) {
|
|
2401
2501
|
return;
|
|
2402
2502
|
}
|
|
2403
2503
|
if (!isChecked && (isRadio || dependencyDetection_exports.getDependenciesCount())) {
|
|
2404
2504
|
return;
|
|
2405
2505
|
}
|
|
2406
|
-
|
|
2506
|
+
const modelValue = dependencyDetection_exports.ignore(valueAccessor);
|
|
2407
2507
|
if (valueIsArray) {
|
|
2408
|
-
|
|
2508
|
+
const writableValue = rawValueIsNonArrayObservable ? modelValue.peek() : modelValue, saveOldValue = oldElemValue;
|
|
2409
2509
|
oldElemValue = elemValue;
|
|
2410
2510
|
if (saveOldValue !== elemValue) {
|
|
2411
2511
|
if (isChecked) {
|
|
@@ -2427,13 +2527,15 @@ var checked = {
|
|
|
2427
2527
|
elemValue = void 0;
|
|
2428
2528
|
}
|
|
2429
2529
|
}
|
|
2430
|
-
valueAccessor(elemValue, { onlyIfChanged: true });
|
|
2530
|
+
const modelValue2 = valueAccessor(elemValue, { onlyIfChanged: true });
|
|
2531
|
+
if (isWriteableObservable(modelValue2) && modelValue2.peek() !== elemValue) {
|
|
2532
|
+
modelValue2(elemValue);
|
|
2533
|
+
}
|
|
2431
2534
|
}
|
|
2432
2535
|
}
|
|
2433
|
-
;
|
|
2434
2536
|
function updateView() {
|
|
2435
|
-
|
|
2436
|
-
|
|
2537
|
+
const modelValue = unwrap(valueAccessor());
|
|
2538
|
+
const elemValue = checkedValue2();
|
|
2437
2539
|
if (valueIsArray) {
|
|
2438
2540
|
element.checked = arrayIndexOf(modelValue, elemValue) >= 0;
|
|
2439
2541
|
oldElemValue = elemValue;
|
|
@@ -2443,12 +2545,11 @@ var checked = {
|
|
|
2443
2545
|
element.checked = checkedValue2() === modelValue;
|
|
2444
2546
|
}
|
|
2445
2547
|
}
|
|
2446
|
-
;
|
|
2447
|
-
var isCheckbox = element.type == "checkbox", isRadio = element.type == "radio";
|
|
2548
|
+
const isCheckbox = element.type == "checkbox", isRadio = element.type == "radio";
|
|
2448
2549
|
if (!isCheckbox && !isRadio) {
|
|
2449
2550
|
return;
|
|
2450
2551
|
}
|
|
2451
|
-
|
|
2552
|
+
let rawValue = valueAccessor(), valueIsArray = isCheckbox && unwrap(rawValue) instanceof Array, rawValueIsNonArrayObservable = !(valueIsArray && rawValue.push && rawValue.splice), useElementValue = isRadio || valueIsArray, oldElemValue = valueIsArray ? checkedValue2() : void 0;
|
|
2452
2553
|
computed(updateModel, null, { disposeWhenNodeIsRemoved: element });
|
|
2453
2554
|
registerEventHandler(element, "click", updateModel);
|
|
2454
2555
|
computed(updateView, null, { disposeWhenNodeIsRemoved: element });
|
|
@@ -2465,8 +2566,8 @@ var checkedValue = {
|
|
|
2465
2566
|
function makeEventHandlerShortcut(eventName) {
|
|
2466
2567
|
return {
|
|
2467
2568
|
init: function(element, valueAccessor, allBindings, viewModel, bindingContext2) {
|
|
2468
|
-
|
|
2469
|
-
|
|
2569
|
+
const newValueAccessor = function() {
|
|
2570
|
+
const result = {};
|
|
2470
2571
|
result[eventName] = valueAccessor();
|
|
2471
2572
|
return result;
|
|
2472
2573
|
};
|
|
@@ -2479,18 +2580,18 @@ function makeDescriptor(handlerOrObject) {
|
|
|
2479
2580
|
}
|
|
2480
2581
|
var eventHandler = {
|
|
2481
2582
|
init: function(element, valueAccessor, allBindings, viewModel, bindingContext2) {
|
|
2482
|
-
|
|
2583
|
+
const eventsToHandle = valueAccessor() || {};
|
|
2483
2584
|
objectForEach(eventsToHandle, function(eventName, descriptor) {
|
|
2484
2585
|
const { passive, capture, once, debounce: debounce2, throttle: throttle2 } = makeDescriptor(descriptor);
|
|
2485
2586
|
const eventOptions = (capture || passive || once) && { capture, passive, once };
|
|
2486
2587
|
let eventHandlerFn = (event, ...more) => {
|
|
2487
|
-
|
|
2488
|
-
const { handler
|
|
2588
|
+
let handlerReturnValue;
|
|
2589
|
+
const { handler, passive: passive2, bubble, preventDefault } = makeDescriptor(valueAccessor()[eventName]);
|
|
2489
2590
|
try {
|
|
2490
|
-
if (
|
|
2591
|
+
if (handler) {
|
|
2491
2592
|
const possiblyUpdatedViewModel = bindingContext2.$data;
|
|
2492
2593
|
const argsForHandler = [possiblyUpdatedViewModel, event, ...more];
|
|
2493
|
-
handlerReturnValue =
|
|
2594
|
+
handlerReturnValue = handler.apply(possiblyUpdatedViewModel, argsForHandler);
|
|
2494
2595
|
}
|
|
2495
2596
|
} finally {
|
|
2496
2597
|
if (preventDefault !== void 0) {
|
|
@@ -2535,7 +2636,7 @@ var click = makeEventHandlerShortcut("click");
|
|
|
2535
2636
|
var css = {
|
|
2536
2637
|
aliases: ["class"],
|
|
2537
2638
|
update: function(element, valueAccessor) {
|
|
2538
|
-
|
|
2639
|
+
let value2 = unwrap(valueAccessor());
|
|
2539
2640
|
if (value2 !== null && typeof value2 === "object") {
|
|
2540
2641
|
objectForEach(value2, function(className, shouldHaveClass) {
|
|
2541
2642
|
shouldHaveClass = unwrap(shouldHaveClass);
|
|
@@ -2552,22 +2653,24 @@ var css = {
|
|
|
2552
2653
|
};
|
|
2553
2654
|
|
|
2554
2655
|
// ../bind/dist/bindingEvent.js
|
|
2555
|
-
var contextAncestorBindingInfo = Symbol("_ancestorBindingInfo");
|
|
2656
|
+
var contextAncestorBindingInfo = /* @__PURE__ */ Symbol("_ancestorBindingInfo");
|
|
2556
2657
|
var boundElementDomDataKey = data_exports.nextKey();
|
|
2557
2658
|
var bindingEvent = {
|
|
2659
|
+
//TODO better: String-Enum "BindingEventEnum"
|
|
2558
2660
|
childrenComplete: "childrenComplete",
|
|
2559
2661
|
descendantsComplete: "descendantsComplete",
|
|
2560
|
-
subscribe(node, event, callback,
|
|
2662
|
+
subscribe(node, event, callback, callbackContext) {
|
|
2561
2663
|
const bindingInfo = data_exports.getOrSet(node, boundElementDomDataKey, {});
|
|
2562
2664
|
if (!bindingInfo.eventSubscribable) {
|
|
2563
2665
|
bindingInfo.eventSubscribable = new subscribable();
|
|
2564
2666
|
}
|
|
2565
|
-
return bindingInfo.eventSubscribable.subscribe(callback,
|
|
2667
|
+
return bindingInfo.eventSubscribable.subscribe(callback, callbackContext, event);
|
|
2566
2668
|
},
|
|
2567
2669
|
notify(node, event) {
|
|
2568
2670
|
const bindingInfo = data_exports.get(node, boundElementDomDataKey);
|
|
2569
2671
|
if (bindingInfo) {
|
|
2570
2672
|
if (bindingInfo.eventSubscribable) {
|
|
2673
|
+
;
|
|
2571
2674
|
bindingInfo.eventSubscribable.notifySubscribers(node, event);
|
|
2572
2675
|
}
|
|
2573
2676
|
}
|
|
@@ -2576,15 +2679,14 @@ var bindingEvent = {
|
|
|
2576
2679
|
|
|
2577
2680
|
// ../bind/dist/bindingContext.js
|
|
2578
2681
|
var boundElementDomDataKey2 = data_exports.nextKey();
|
|
2579
|
-
var contextSubscribeSymbol = Symbol("Knockout Context Subscription");
|
|
2580
|
-
var inheritParentIndicator = Symbol("Knockout Parent Indicator");
|
|
2581
|
-
function
|
|
2682
|
+
var contextSubscribeSymbol = /* @__PURE__ */ Symbol("Knockout Context Subscription");
|
|
2683
|
+
var inheritParentIndicator = /* @__PURE__ */ Symbol("Knockout Parent Indicator");
|
|
2684
|
+
var bindingContext = function bindingContextFactory(dataItemOrAccessor, parentContext, dataItemAlias, extendCallback, settings) {
|
|
2582
2685
|
const self = this;
|
|
2583
2686
|
const shouldInheritData = dataItemOrAccessor === inheritParentIndicator;
|
|
2584
2687
|
const realDataItemOrAccessor = shouldInheritData ? void 0 : dataItemOrAccessor;
|
|
2585
2688
|
const isFunc = typeof realDataItemOrAccessor === "function" && !isObservable(realDataItemOrAccessor);
|
|
2586
2689
|
self.ko = options_default.knockoutInstance;
|
|
2587
|
-
let nodes;
|
|
2588
2690
|
let subscribable2;
|
|
2589
2691
|
function updateContext() {
|
|
2590
2692
|
const dataItemOrObservable = isFunc ? realDataItemOrAccessor() : realDataItemOrAccessor;
|
|
@@ -2598,7 +2700,7 @@ function bindingContext(dataItemOrAccessor, parentContext, dataItemAlias, extend
|
|
|
2598
2700
|
self[contextAncestorBindingInfo] = parentContext[contextAncestorBindingInfo];
|
|
2599
2701
|
}
|
|
2600
2702
|
} else {
|
|
2601
|
-
self.$parents =
|
|
2703
|
+
self.$parents = new Array();
|
|
2602
2704
|
self.$root = dataItem;
|
|
2603
2705
|
}
|
|
2604
2706
|
self[contextSubscribeSymbol] = subscribable2;
|
|
@@ -2628,7 +2730,7 @@ function bindingContext(dataItemOrAccessor, parentContext, dataItemAlias, extend
|
|
|
2628
2730
|
self[contextSubscribeSymbol] = void 0;
|
|
2629
2731
|
}
|
|
2630
2732
|
}
|
|
2631
|
-
}
|
|
2733
|
+
};
|
|
2632
2734
|
Object.assign(bindingContext.prototype, {
|
|
2633
2735
|
lookup(token, globals, node) {
|
|
2634
2736
|
switch (token) {
|
|
@@ -2652,24 +2754,39 @@ Object.assign(bindingContext.prototype, {
|
|
|
2652
2754
|
}
|
|
2653
2755
|
throw new Error(`The variable "${token}" was not found on $data, $context, or globals.`);
|
|
2654
2756
|
},
|
|
2757
|
+
// Extend the binding context hierarchy with a new view model object. If the parent context is watching
|
|
2758
|
+
// any observables, the new child context will automatically get a dependency on the parent context.
|
|
2759
|
+
// But this does not mean that the $data value of the child context will also get updated. If the child
|
|
2760
|
+
// view model also depends on the parent view model, you must provide a function that returns the correct
|
|
2761
|
+
// view model on each update.
|
|
2655
2762
|
createChildContext(dataItemOrAccessor, dataItemAlias, extendCallback, settings) {
|
|
2656
|
-
return new bindingContext(
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2763
|
+
return new bindingContext(
|
|
2764
|
+
dataItemOrAccessor,
|
|
2765
|
+
this,
|
|
2766
|
+
dataItemAlias,
|
|
2767
|
+
function(self, parentContext) {
|
|
2768
|
+
var _a;
|
|
2769
|
+
self.$parentContext = parentContext;
|
|
2770
|
+
self.$parent = parentContext == null ? void 0 : parentContext.$data;
|
|
2771
|
+
self.$parents = ((_a = parentContext == null ? void 0 : parentContext.$parents) != null ? _a : []).slice(0);
|
|
2772
|
+
self.$parents.unshift(self.$parent);
|
|
2773
|
+
if (extendCallback) {
|
|
2774
|
+
extendCallback(self);
|
|
2775
|
+
}
|
|
2776
|
+
},
|
|
2777
|
+
settings
|
|
2778
|
+
);
|
|
2665
2779
|
},
|
|
2780
|
+
// Extend the binding context with new custom properties. This doesn't change the context hierarchy.
|
|
2781
|
+
// Similarly to "child" contexts, provide a function here to make sure that the correct values are set
|
|
2782
|
+
// when an observable view model is updated.
|
|
2666
2783
|
extend(properties) {
|
|
2667
|
-
return new bindingContext(inheritParentIndicator, this,
|
|
2784
|
+
return new bindingContext(inheritParentIndicator, this, void 0, function(self, parentContext) {
|
|
2668
2785
|
extend(self, typeof properties === "function" ? properties.call(self) : properties);
|
|
2669
2786
|
});
|
|
2670
2787
|
},
|
|
2671
2788
|
createStaticChildContext(dataItemOrAccessor, dataItemAlias) {
|
|
2672
|
-
return this.createChildContext(dataItemOrAccessor, dataItemAlias, null, {
|
|
2789
|
+
return this.createChildContext(dataItemOrAccessor, dataItemAlias, null, { exportDependencies: true });
|
|
2673
2790
|
}
|
|
2674
2791
|
});
|
|
2675
2792
|
function storedBindingContextForNode(node) {
|
|
@@ -2677,44 +2794,22 @@ function storedBindingContextForNode(node) {
|
|
|
2677
2794
|
return bindingInfo && bindingInfo.context;
|
|
2678
2795
|
}
|
|
2679
2796
|
function contextFor(node) {
|
|
2680
|
-
if (node && (node.nodeType ===
|
|
2797
|
+
if (node && (node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.COMMENT_NODE)) {
|
|
2681
2798
|
return storedBindingContextForNode(node);
|
|
2682
2799
|
}
|
|
2683
2800
|
}
|
|
2684
2801
|
function dataFor(node) {
|
|
2685
|
-
|
|
2802
|
+
const context = contextFor(node);
|
|
2686
2803
|
return context ? context.$data : void 0;
|
|
2687
2804
|
}
|
|
2688
2805
|
|
|
2689
2806
|
// ../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
2807
|
var BindingResult = class {
|
|
2711
2808
|
constructor({ asyncBindingsApplied, rootNode, bindingContext: bindingContext2 }) {
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
isComplete: this.isSync
|
|
2717
|
-
});
|
|
2809
|
+
this.rootNode = rootNode;
|
|
2810
|
+
this.bindingContext = bindingContext2;
|
|
2811
|
+
this.isSync = asyncBindingsApplied.size === 0;
|
|
2812
|
+
this.isComplete = this.isSync;
|
|
2718
2813
|
if (!this.isSync) {
|
|
2719
2814
|
this.completionPromise = this.completeWhenBindingsFinish(asyncBindingsApplied);
|
|
2720
2815
|
}
|
|
@@ -2731,11 +2826,18 @@ var BindingResult = class {
|
|
|
2731
2826
|
// ../lifecycle/dist/LifeCycle.js
|
|
2732
2827
|
var SUBSCRIPTIONS = createSymbolOrString("LifeCycle Subscriptions List");
|
|
2733
2828
|
var ANCHOR_NODE = createSymbolOrString("LifeCycle Anchor Node");
|
|
2734
|
-
var LifeCycle = class {
|
|
2829
|
+
var LifeCycle = class _LifeCycle {
|
|
2830
|
+
// NOTE: For more advanced integration as an ES6 mixin, see e.g.:
|
|
2831
|
+
// http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/
|
|
2832
|
+
/**
|
|
2833
|
+
* Copy the properties of the LifeCycle class to the target (or its prototype)
|
|
2834
|
+
*
|
|
2835
|
+
* NOTE: getOwnPropertyNames is needed to copy the non-enumerable properties.
|
|
2836
|
+
*/
|
|
2735
2837
|
static mixInto(Constructor) {
|
|
2736
2838
|
const target = Constructor.prototype || Constructor;
|
|
2737
|
-
const mixin =
|
|
2738
|
-
for (
|
|
2839
|
+
const mixin = _LifeCycle.prototype;
|
|
2840
|
+
for (const prop of Object.getOwnPropertyNames(mixin)) {
|
|
2739
2841
|
target[prop] = mixin[prop];
|
|
2740
2842
|
}
|
|
2741
2843
|
}
|
|
@@ -2763,16 +2865,23 @@ var LifeCycle = class {
|
|
|
2763
2865
|
params.disposeWhenNodeIsRemoved = this[ANCHOR_NODE];
|
|
2764
2866
|
return this.addDisposable(computed(params));
|
|
2765
2867
|
}
|
|
2868
|
+
/**
|
|
2869
|
+
* Add an event listener for the given or anchored node.
|
|
2870
|
+
* @param {node} [node] (optional) The target node (otherwise the anchored node)
|
|
2871
|
+
* @param {string} [type] Event type
|
|
2872
|
+
* @param {function|string} [action] Either call the given function or `this[action]`
|
|
2873
|
+
* @param {object} [options] (optional) Passed as `options` to `node.addEventListener`
|
|
2874
|
+
*/
|
|
2766
2875
|
addEventListener(...args) {
|
|
2767
2876
|
const node = args[0].nodeType ? args.shift() : this[ANCHOR_NODE];
|
|
2768
2877
|
const [type, act, options3] = args;
|
|
2769
|
-
const
|
|
2770
|
-
this.__addEventListener(node, type,
|
|
2878
|
+
const handler = typeof act === "string" ? this[act].bind(this) : act;
|
|
2879
|
+
this.__addEventListener(node, type, handler, options3);
|
|
2771
2880
|
}
|
|
2772
|
-
__addEventListener(node, eventType,
|
|
2773
|
-
node.addEventListener(eventType,
|
|
2881
|
+
__addEventListener(node, eventType, handler, options3) {
|
|
2882
|
+
node.addEventListener(eventType, handler, options3);
|
|
2774
2883
|
function dispose() {
|
|
2775
|
-
node.removeEventListener(eventType,
|
|
2884
|
+
node.removeEventListener(eventType, handler);
|
|
2776
2885
|
}
|
|
2777
2886
|
addDisposeCallback(node, dispose);
|
|
2778
2887
|
this.addDisposable({ dispose });
|
|
@@ -2789,7 +2898,7 @@ var LifeCycle = class {
|
|
|
2789
2898
|
dispose() {
|
|
2790
2899
|
const subscriptions = this[SUBSCRIPTIONS] || [];
|
|
2791
2900
|
subscriptions.forEach((s) => s.dispose());
|
|
2792
|
-
this[SUBSCRIPTIONS] =
|
|
2901
|
+
this[SUBSCRIPTIONS] = new Array();
|
|
2793
2902
|
this[ANCHOR_NODE] = null;
|
|
2794
2903
|
}
|
|
2795
2904
|
addDisposable(subscription) {
|
|
@@ -2810,13 +2919,11 @@ var BindingHandler = class extends LifeCycle {
|
|
|
2810
2919
|
constructor(params) {
|
|
2811
2920
|
super();
|
|
2812
2921
|
const { $element, valueAccessor, allBindings, $context } = params;
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
$data: $context.$data
|
|
2819
|
-
});
|
|
2922
|
+
this.$element = $element;
|
|
2923
|
+
this.valueAccessor = valueAccessor;
|
|
2924
|
+
this.allBindings = allBindings;
|
|
2925
|
+
this.$context = $context;
|
|
2926
|
+
this.$data = $context.$data;
|
|
2820
2927
|
this.anchorTo($element);
|
|
2821
2928
|
}
|
|
2822
2929
|
get value() {
|
|
@@ -2839,91 +2946,105 @@ var BindingHandler = class extends LifeCycle {
|
|
|
2839
2946
|
static get isBindingHandlerClass() {
|
|
2840
2947
|
return true;
|
|
2841
2948
|
}
|
|
2949
|
+
/* Overload this for asynchronous bindings or bindings that recursively
|
|
2950
|
+
apply bindings (e.g. components, foreach, template).
|
|
2951
|
+
|
|
2952
|
+
A binding should be complete when it has run through once, notably
|
|
2953
|
+
in server-side bindings for pre-rendering.
|
|
2954
|
+
*/
|
|
2842
2955
|
get bindingCompleted() {
|
|
2843
2956
|
return true;
|
|
2844
2957
|
}
|
|
2845
2958
|
static registerAs(name, provider = options_default.bindingProviderInstance) {
|
|
2846
2959
|
provider.bindingHandlers.set(name, this);
|
|
2847
2960
|
}
|
|
2961
|
+
static registerBindingHandler(handler, name, provider = options_default.bindingProviderInstance) {
|
|
2962
|
+
provider.bindingHandlers.set(name, handler);
|
|
2963
|
+
}
|
|
2848
2964
|
};
|
|
2849
|
-
var ResolveSymbol = Symbol("Async Binding Resolved");
|
|
2850
2965
|
|
|
2851
2966
|
// ../bind/dist/LegacyBindingHandler.js
|
|
2852
2967
|
var PossibleWeakMap = options_default.global.WeakMap || Map;
|
|
2853
2968
|
var legacyBindingMap = new PossibleWeakMap();
|
|
2854
|
-
var LegacyBindingHandler = class extends BindingHandler {
|
|
2969
|
+
var LegacyBindingHandler = class _LegacyBindingHandler extends BindingHandler {
|
|
2970
|
+
get handler() {
|
|
2971
|
+
return void 0;
|
|
2972
|
+
}
|
|
2855
2973
|
constructor(params) {
|
|
2856
2974
|
super(params);
|
|
2857
|
-
const
|
|
2975
|
+
const handler = this.handler;
|
|
2858
2976
|
this.onError = params.onError;
|
|
2859
|
-
if (typeof
|
|
2860
|
-
this.addDisposable(
|
|
2977
|
+
if (typeof handler.dispose === "function") {
|
|
2978
|
+
this.addDisposable(handler);
|
|
2861
2979
|
}
|
|
2862
2980
|
try {
|
|
2863
|
-
this.initReturn =
|
|
2981
|
+
this.initReturn = handler.init && handler.init(...this.legacyArgs);
|
|
2864
2982
|
} catch (e) {
|
|
2865
2983
|
params.onError("init", e);
|
|
2866
2984
|
}
|
|
2867
2985
|
}
|
|
2868
2986
|
onValueChange() {
|
|
2869
|
-
const
|
|
2870
|
-
if (typeof
|
|
2987
|
+
const handler = this.handler;
|
|
2988
|
+
if (typeof handler.update !== "function") {
|
|
2871
2989
|
return;
|
|
2872
2990
|
}
|
|
2873
2991
|
try {
|
|
2874
|
-
|
|
2992
|
+
handler.update(...this.legacyArgs);
|
|
2875
2993
|
} catch (e) {
|
|
2876
2994
|
this.onError("update", e);
|
|
2877
2995
|
}
|
|
2878
2996
|
}
|
|
2879
2997
|
get legacyArgs() {
|
|
2880
|
-
return [
|
|
2881
|
-
this.$element,
|
|
2882
|
-
this.valueAccessor,
|
|
2883
|
-
this.allBindings,
|
|
2884
|
-
this.$data,
|
|
2885
|
-
this.$context
|
|
2886
|
-
];
|
|
2998
|
+
return [this.$element, this.valueAccessor, this.allBindings, this.$data, this.$context];
|
|
2887
2999
|
}
|
|
2888
3000
|
get controlsDescendants() {
|
|
2889
3001
|
const objectToTest = this.initReturn || this.handler || {};
|
|
2890
3002
|
return objectToTest.controlsDescendantBindings;
|
|
2891
3003
|
}
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
3004
|
+
/**
|
|
3005
|
+
* Create a handler instance from the `origin`, which may be:
|
|
3006
|
+
*
|
|
3007
|
+
* 1. an object (becomes LegacyBindingHandler)
|
|
3008
|
+
* 2. a function (becomes LegacyBindingHandler with `init: function`)
|
|
3009
|
+
*
|
|
3010
|
+
* If given an object (the only kind supported in knockout 3.x and before), it
|
|
3011
|
+
* shall draw the `init`, `update`, and `allowVirtualElements` properties
|
|
3012
|
+
*/
|
|
3013
|
+
static getOrCreateFor(key, handler) {
|
|
3014
|
+
if (legacyBindingMap.has(handler)) {
|
|
3015
|
+
return legacyBindingMap.get(handler);
|
|
3016
|
+
}
|
|
3017
|
+
const newLegacyHandler = this.createFor(key, handler);
|
|
3018
|
+
legacyBindingMap.set(handler, newLegacyHandler);
|
|
2898
3019
|
return newLegacyHandler;
|
|
2899
3020
|
}
|
|
2900
|
-
static createFor(key,
|
|
2901
|
-
if (typeof
|
|
2902
|
-
const [initFn, disposeFn] = [
|
|
2903
|
-
return class extends
|
|
3021
|
+
static createFor(key, handler) {
|
|
3022
|
+
if (typeof handler === "function") {
|
|
3023
|
+
const [initFn, disposeFn] = [handler, handler.dispose];
|
|
3024
|
+
return class extends _LegacyBindingHandler {
|
|
2904
3025
|
get handler() {
|
|
2905
3026
|
const init = initFn.bind(this);
|
|
2906
3027
|
const dispose = disposeFn ? disposeFn.bind(this) : null;
|
|
2907
3028
|
return { init, dispose };
|
|
2908
3029
|
}
|
|
2909
3030
|
static get after() {
|
|
2910
|
-
return
|
|
3031
|
+
return handler.after;
|
|
2911
3032
|
}
|
|
2912
3033
|
static get allowVirtualElements() {
|
|
2913
|
-
return
|
|
3034
|
+
return handler.allowVirtualElements || virtualElements_exports.allowedBindings[key];
|
|
2914
3035
|
}
|
|
2915
3036
|
};
|
|
2916
3037
|
}
|
|
2917
|
-
if (typeof
|
|
2918
|
-
return class extends
|
|
3038
|
+
if (typeof handler === "object") {
|
|
3039
|
+
return class extends _LegacyBindingHandler {
|
|
2919
3040
|
get handler() {
|
|
2920
|
-
return
|
|
3041
|
+
return handler;
|
|
2921
3042
|
}
|
|
2922
3043
|
static get after() {
|
|
2923
|
-
return
|
|
3044
|
+
return handler.after;
|
|
2924
3045
|
}
|
|
2925
3046
|
static get allowVirtualElements() {
|
|
2926
|
-
return
|
|
3047
|
+
return handler.allowVirtualElements || virtualElements_exports.allowedBindings[key];
|
|
2927
3048
|
}
|
|
2928
3049
|
};
|
|
2929
3050
|
}
|
|
@@ -2933,22 +3054,27 @@ var LegacyBindingHandler = class extends BindingHandler {
|
|
|
2933
3054
|
|
|
2934
3055
|
// ../bind/dist/applyBindings.js
|
|
2935
3056
|
var bindingDoesNotRecurseIntoElementTypes = {
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
3057
|
+
// Don't want bindings that operate on text nodes to mutate <script> and <textarea> contents,
|
|
3058
|
+
// because it's unexpected and a potential XSS issue.
|
|
3059
|
+
// Also bindings should not operate on <template> elements since this breaks in Internet Explorer
|
|
3060
|
+
// and because such elements' contents are always intended to be bound in a different context
|
|
3061
|
+
// from where they appear in the document.
|
|
3062
|
+
script: true,
|
|
3063
|
+
textarea: true,
|
|
3064
|
+
template: true
|
|
2939
3065
|
};
|
|
2940
3066
|
function getBindingProvider() {
|
|
2941
3067
|
return options_default.bindingProviderInstance.instance || options_default.bindingProviderInstance;
|
|
2942
3068
|
}
|
|
2943
3069
|
function isProviderForNode(provider, node) {
|
|
2944
|
-
const nodeTypes = provider.FOR_NODE_TYPES || [
|
|
3070
|
+
const nodeTypes = provider.FOR_NODE_TYPES || [Node.ELEMENT_NODE, Node.TEXT_NODE, Node.COMMENT_NODE];
|
|
2945
3071
|
return nodeTypes.includes(node.nodeType);
|
|
2946
3072
|
}
|
|
2947
|
-
function asProperHandlerClass(
|
|
2948
|
-
if (!
|
|
3073
|
+
function asProperHandlerClass(handler, bindingKey) {
|
|
3074
|
+
if (!handler) {
|
|
2949
3075
|
return;
|
|
2950
3076
|
}
|
|
2951
|
-
return
|
|
3077
|
+
return handler.isBindingHandlerClass ? handler : LegacyBindingHandler.getOrCreateFor(bindingKey, handler);
|
|
2952
3078
|
}
|
|
2953
3079
|
function getBindingHandlerFromComponent(bindingKey, $component) {
|
|
2954
3080
|
if (!$component || typeof $component.getBindingHandler !== "function") {
|
|
@@ -2992,11 +3118,11 @@ function nodeOrChildHasBindings(node) {
|
|
|
2992
3118
|
return hasBindings(node) || [...node.childNodes].some((c) => nodeOrChildHasBindings(c));
|
|
2993
3119
|
}
|
|
2994
3120
|
function applyBindingsToNodeAndDescendantsInternal(bindingContext2, nodeVerified, asyncBindingsApplied) {
|
|
2995
|
-
|
|
3121
|
+
const isElement = nodeVerified.nodeType === Node.ELEMENT_NODE;
|
|
2996
3122
|
if (isElement) {
|
|
2997
3123
|
virtualElements_exports.normaliseVirtualElementDomStructure(nodeVerified);
|
|
2998
3124
|
}
|
|
2999
|
-
|
|
3125
|
+
const shouldApplyBindings = isElement || hasBindings(nodeVerified);
|
|
3000
3126
|
const { shouldBindDescendants } = shouldApplyBindings ? applyBindingsToNodeInternal(nodeVerified, null, bindingContext2, asyncBindingsApplied) : { shouldBindDescendants: true };
|
|
3001
3127
|
if (shouldBindDescendants && !bindingDoesNotRecurseIntoElementTypes[tagNameLower(nodeVerified)]) {
|
|
3002
3128
|
applyBindingsToDescendantsInternal(bindingContext2, nodeVerified, asyncBindingsApplied);
|
|
@@ -3005,7 +3131,7 @@ function applyBindingsToNodeAndDescendantsInternal(bindingContext2, nodeVerified
|
|
|
3005
3131
|
function* topologicalSortBindings(bindings2, $component) {
|
|
3006
3132
|
const results = [];
|
|
3007
3133
|
const bindingsConsidered = {};
|
|
3008
|
-
const cyclicDependencyStack =
|
|
3134
|
+
const cyclicDependencyStack = new Array();
|
|
3009
3135
|
objectForEach(bindings2, function pushBinding(bindingKey) {
|
|
3010
3136
|
if (!bindingsConsidered[bindingKey]) {
|
|
3011
3137
|
const binding = getBindingHandlerFromComponent(bindingKey, $component) || getBindingHandler(bindingKey);
|
|
@@ -3019,7 +3145,9 @@ function* topologicalSortBindings(bindings2, $component) {
|
|
|
3019
3145
|
return;
|
|
3020
3146
|
}
|
|
3021
3147
|
if (arrayIndexOf(cyclicDependencyStack, bindingDependencyKey) !== -1) {
|
|
3022
|
-
throw Error(
|
|
3148
|
+
throw Error(
|
|
3149
|
+
"Cannot combine the following bindings, because they have a cyclic dependency: " + cyclicDependencyStack.join(", ")
|
|
3150
|
+
);
|
|
3023
3151
|
} else {
|
|
3024
3152
|
pushBinding(bindingDependencyKey);
|
|
3025
3153
|
}
|
|
@@ -3055,30 +3183,32 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
|
|
|
3055
3183
|
if (!alreadyBound) {
|
|
3056
3184
|
bindingInfo.context = bindingContext2;
|
|
3057
3185
|
}
|
|
3058
|
-
|
|
3186
|
+
let bindings2 = null;
|
|
3187
|
+
let bindingsUpdater = null;
|
|
3059
3188
|
if (sourceBindings && typeof sourceBindings !== "function") {
|
|
3060
3189
|
bindings2 = sourceBindings;
|
|
3061
3190
|
} else {
|
|
3062
3191
|
const provider = getBindingProvider();
|
|
3063
3192
|
const getBindings = provider.getBindingAccessors;
|
|
3064
3193
|
if (isProviderForNode(provider, node)) {
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
bindingContext2[contextSubscribeSymbol]
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3194
|
+
bindingsUpdater = computed(
|
|
3195
|
+
function() {
|
|
3196
|
+
bindings2 = sourceBindings ? sourceBindings(bindingContext2, node) : getBindings.call(provider, node, bindingContext2);
|
|
3197
|
+
if (bindings2 && bindingContext2[contextSubscribeSymbol]) {
|
|
3198
|
+
bindingContext2[contextSubscribeSymbol]();
|
|
3199
|
+
}
|
|
3200
|
+
return bindings2;
|
|
3201
|
+
},
|
|
3202
|
+
null,
|
|
3203
|
+
{ disposeWhenNodeIsRemoved: node }
|
|
3204
|
+
);
|
|
3072
3205
|
if (!bindings2 || !bindingsUpdater.isActive()) {
|
|
3073
3206
|
bindingsUpdater = null;
|
|
3074
3207
|
}
|
|
3075
3208
|
}
|
|
3076
3209
|
}
|
|
3077
|
-
|
|
3210
|
+
let bindingHandlerThatControlsDescendantBindings;
|
|
3078
3211
|
if (bindings2) {
|
|
3079
|
-
let allBindings = function() {
|
|
3080
|
-
return objectMap(bindingsUpdater ? bindingsUpdater() : bindings2, evaluateValueAccessor);
|
|
3081
|
-
};
|
|
3082
3212
|
const $component = bindingContext2.$component || {};
|
|
3083
3213
|
const allBindingHandlers = {};
|
|
3084
3214
|
data_exports.set(node, "bindingHandlers", allBindingHandlers);
|
|
@@ -3090,24 +3220,32 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
|
|
|
3090
3220
|
return valueAccessor(optionalValue);
|
|
3091
3221
|
}
|
|
3092
3222
|
} : (bindingKey) => bindings2[bindingKey];
|
|
3223
|
+
const allBindings = function() {
|
|
3224
|
+
return objectMap(bindingsUpdater ? bindingsUpdater() : bindings2, evaluateValueAccessor);
|
|
3225
|
+
};
|
|
3093
3226
|
allBindings.has = (key) => key in bindings2;
|
|
3094
3227
|
allBindings.get = (key) => bindings2[key] && evaluateValueAccessor(getValueAccessor(key));
|
|
3095
3228
|
if (bindingEvent.childrenComplete in bindings2) {
|
|
3096
|
-
bindingEvent.subscribe(
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3229
|
+
bindingEvent.subscribe(
|
|
3230
|
+
node,
|
|
3231
|
+
bindingEvent.childrenComplete,
|
|
3232
|
+
() => {
|
|
3233
|
+
const callback = evaluateValueAccessor(bindings2[bindingEvent.childrenComplete]);
|
|
3234
|
+
if (!callback) {
|
|
3235
|
+
return;
|
|
3236
|
+
}
|
|
3237
|
+
const nodes = virtualElements_exports.childNodes(node);
|
|
3238
|
+
if (nodes.length) {
|
|
3239
|
+
callback(nodes, dataFor(nodes[0]));
|
|
3240
|
+
}
|
|
3241
|
+
},
|
|
3242
|
+
null
|
|
3243
|
+
);
|
|
3106
3244
|
}
|
|
3107
3245
|
const bindingsGenerated = topologicalSortBindings(bindings2, $component);
|
|
3108
3246
|
const nodeAsyncBindingPromises = /* @__PURE__ */ new Set();
|
|
3109
3247
|
for (const [key, BindingHandlerClass] of bindingsGenerated) {
|
|
3110
|
-
|
|
3248
|
+
const reportBindingError = function(during, errorCaptured) {
|
|
3111
3249
|
onBindingError({
|
|
3112
3250
|
during,
|
|
3113
3251
|
errorCaptured,
|
|
@@ -3119,26 +3257,30 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
|
|
|
3119
3257
|
valueAccessor: getValueAccessor(key)
|
|
3120
3258
|
});
|
|
3121
3259
|
};
|
|
3122
|
-
if (node.nodeType ===
|
|
3260
|
+
if (node.nodeType === Node.COMMENT_NODE && !BindingHandlerClass.allowVirtualElements) {
|
|
3123
3261
|
throw new Error(`The binding '${key}' cannot be used with virtual elements`);
|
|
3124
3262
|
}
|
|
3125
3263
|
try {
|
|
3126
|
-
const bindingHandler = dependencyDetection_exports.ignore(
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3264
|
+
const bindingHandler = dependencyDetection_exports.ignore(
|
|
3265
|
+
() => new BindingHandlerClass({
|
|
3266
|
+
allBindings,
|
|
3267
|
+
$element: node,
|
|
3268
|
+
$context: bindingContext2,
|
|
3269
|
+
onError: reportBindingError,
|
|
3270
|
+
valueAccessor(...v) {
|
|
3271
|
+
return getValueAccessor(key)(...v);
|
|
3272
|
+
}
|
|
3273
|
+
})
|
|
3274
|
+
);
|
|
3135
3275
|
if (bindingHandler.onValueChange) {
|
|
3136
3276
|
dependencyDetection_exports.ignore(() => bindingHandler.computed("onValueChange"));
|
|
3137
3277
|
}
|
|
3138
3278
|
allBindingHandlers[key] = bindingHandler;
|
|
3139
3279
|
if (bindingHandler.controlsDescendants) {
|
|
3140
3280
|
if (bindingHandlerThatControlsDescendantBindings !== void 0) {
|
|
3141
|
-
throw new Error(
|
|
3281
|
+
throw new Error(
|
|
3282
|
+
"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."
|
|
3283
|
+
);
|
|
3142
3284
|
}
|
|
3143
3285
|
bindingHandlerThatControlsDescendantBindings = key;
|
|
3144
3286
|
}
|
|
@@ -3147,7 +3289,8 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext2, asyn
|
|
|
3147
3289
|
nodeAsyncBindingPromises.add(bindingHandler.bindingCompleted);
|
|
3148
3290
|
}
|
|
3149
3291
|
} catch (err) {
|
|
3150
|
-
|
|
3292
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
3293
|
+
reportBindingError("creation", error);
|
|
3151
3294
|
}
|
|
3152
3295
|
}
|
|
3153
3296
|
triggerDescendantsComplete(node, bindings2, nodeAsyncBindingPromises);
|
|
@@ -3175,22 +3318,27 @@ function getBindingContext(viewModelOrBindingContext, extendContextCallback) {
|
|
|
3175
3318
|
return viewModelOrBindingContext && viewModelOrBindingContext instanceof bindingContext ? viewModelOrBindingContext : new bindingContext(viewModelOrBindingContext, void 0, void 0, extendContextCallback);
|
|
3176
3319
|
}
|
|
3177
3320
|
function applyBindingAccessorsToNode(node, bindings2, viewModelOrBindingContext, asyncBindingsApplied) {
|
|
3178
|
-
if (node.nodeType ===
|
|
3321
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
3179
3322
|
virtualElements_exports.normaliseVirtualElementDomStructure(node);
|
|
3180
3323
|
}
|
|
3181
|
-
return applyBindingsToNodeInternal(
|
|
3324
|
+
return applyBindingsToNodeInternal(
|
|
3325
|
+
node,
|
|
3326
|
+
bindings2,
|
|
3327
|
+
getBindingContext(viewModelOrBindingContext),
|
|
3328
|
+
asyncBindingsApplied
|
|
3329
|
+
);
|
|
3182
3330
|
}
|
|
3183
3331
|
function applyBindingsToDescendants(viewModelOrBindingContext, rootNode) {
|
|
3184
3332
|
const asyncBindingsApplied = /* @__PURE__ */ new Set();
|
|
3185
|
-
|
|
3186
|
-
|
|
3333
|
+
const bindingContext2 = getBindingContext(viewModelOrBindingContext);
|
|
3334
|
+
if (rootNode.nodeType === Node.ELEMENT_NODE || rootNode.nodeType === Node.COMMENT_NODE) {
|
|
3187
3335
|
applyBindingsToDescendantsInternal(bindingContext2, rootNode, asyncBindingsApplied);
|
|
3188
3336
|
return new BindingResult({ asyncBindingsApplied, rootNode, bindingContext: bindingContext2 });
|
|
3189
3337
|
}
|
|
3190
|
-
return new BindingResult({ asyncBindingsApplied, rootNode });
|
|
3338
|
+
return new BindingResult({ asyncBindingsApplied, rootNode, bindingContext: bindingContext2 });
|
|
3191
3339
|
}
|
|
3192
3340
|
function onBindingError(spec) {
|
|
3193
|
-
|
|
3341
|
+
let error;
|
|
3194
3342
|
if (spec.bindingKey) {
|
|
3195
3343
|
error = spec.errorCaptured;
|
|
3196
3344
|
spec.message = 'Unable to process binding "' + spec.bindingKey + '" in binding "' + spec.bindingKey + '"\nMessage: ' + (error.message ? error.message : error);
|
|
@@ -3201,7 +3349,12 @@ function onBindingError(spec) {
|
|
|
3201
3349
|
extend(error, spec);
|
|
3202
3350
|
} catch (e) {
|
|
3203
3351
|
spec.stack = error.stack;
|
|
3204
|
-
|
|
3352
|
+
const message = error.message || String(error);
|
|
3353
|
+
const originalName = error.name;
|
|
3354
|
+
error = new Error(message);
|
|
3355
|
+
if (originalName && originalName !== "Error") {
|
|
3356
|
+
error.name = originalName;
|
|
3357
|
+
}
|
|
3205
3358
|
extend(error, spec);
|
|
3206
3359
|
}
|
|
3207
3360
|
options_default.onError(error);
|
|
@@ -3209,21 +3362,31 @@ function onBindingError(spec) {
|
|
|
3209
3362
|
|
|
3210
3363
|
// ../bind/dist/arrayToDomNodeChildren.js
|
|
3211
3364
|
function mapNodeAndRefreshWhenChanged(containerNode, mapping, valueToMap, callbackAfterAddingNodes, index) {
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3365
|
+
const mappedNodes = [];
|
|
3366
|
+
const dependentObservable = computed(
|
|
3367
|
+
function() {
|
|
3368
|
+
const newMappedNodes = mapping(valueToMap, index, fixUpContinuousNodeArray(mappedNodes, containerNode)) || [];
|
|
3369
|
+
if (mappedNodes.length > 0) {
|
|
3370
|
+
replaceDomNodes(mappedNodes, newMappedNodes);
|
|
3371
|
+
if (callbackAfterAddingNodes) {
|
|
3372
|
+
dependencyDetection_exports.ignore(callbackAfterAddingNodes, null, [valueToMap, newMappedNodes, index]);
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
mappedNodes.length = 0;
|
|
3376
|
+
arrayPushAll(mappedNodes, newMappedNodes);
|
|
3377
|
+
},
|
|
3378
|
+
null,
|
|
3379
|
+
{
|
|
3380
|
+
disposeWhenNodeIsRemoved: containerNode,
|
|
3381
|
+
disposeWhen: function() {
|
|
3382
|
+
return !anyDomNodeIsAttachedToDocument(mappedNodes);
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
);
|
|
3386
|
+
return {
|
|
3387
|
+
mappedNodes,
|
|
3388
|
+
dependentObservable: dependentObservable.isActive() ? dependentObservable : void 0
|
|
3389
|
+
};
|
|
3227
3390
|
}
|
|
3228
3391
|
var lastMappingResultDomDataKey = data_exports.nextKey();
|
|
3229
3392
|
var deletedItemDummyValue = data_exports.nextKey();
|
|
@@ -3233,17 +3396,17 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, c
|
|
|
3233
3396
|
array = [array];
|
|
3234
3397
|
}
|
|
3235
3398
|
options3 = options3 || {};
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3399
|
+
const lastMappingResult = data_exports.get(domNode, lastMappingResultDomDataKey);
|
|
3400
|
+
const isFirstExecution = !lastMappingResult;
|
|
3401
|
+
const newMappingResult = new Array();
|
|
3402
|
+
let lastMappingResultIndex = 0;
|
|
3403
|
+
let newMappingResultIndex = 0;
|
|
3404
|
+
const nodesToDelete = [];
|
|
3405
|
+
const itemsToProcess = [];
|
|
3406
|
+
const itemsForBeforeRemoveCallbacks = [];
|
|
3407
|
+
const itemsForMoveCallbacks = [];
|
|
3408
|
+
const itemsForAfterAddCallbacks = [];
|
|
3409
|
+
let mapData;
|
|
3247
3410
|
let countWaitingForRemove = 0;
|
|
3248
3411
|
function itemAdded(value2) {
|
|
3249
3412
|
mapData = { arrayEntry: value2, indexObservable: observable(newMappingResultIndex++) };
|
|
@@ -3265,9 +3428,9 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, c
|
|
|
3265
3428
|
}
|
|
3266
3429
|
function callCallback(callback, items) {
|
|
3267
3430
|
if (callback) {
|
|
3268
|
-
for (
|
|
3269
|
-
arrayForEach(items[
|
|
3270
|
-
callback(
|
|
3431
|
+
for (let i = 0, n = items.length; i < n; i++) {
|
|
3432
|
+
arrayForEach(items[i].mappedNodes, function(node) {
|
|
3433
|
+
callback(node, i, items[i].arrayEntry);
|
|
3271
3434
|
});
|
|
3272
3435
|
}
|
|
3273
3436
|
}
|
|
@@ -3276,16 +3439,13 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, c
|
|
|
3276
3439
|
arrayForEach(array, itemAdded);
|
|
3277
3440
|
} else {
|
|
3278
3441
|
if (!editScript || lastMappingResult && lastMappingResult["_countWaitingForRemove"]) {
|
|
3279
|
-
|
|
3442
|
+
const lastArray = arrayMap(lastMappingResult, function(x) {
|
|
3280
3443
|
return x.arrayEntry;
|
|
3281
3444
|
});
|
|
3282
|
-
|
|
3283
|
-
"dontLimitMoves": options3["dontLimitMoves"],
|
|
3284
|
-
"sparse": true
|
|
3285
|
-
};
|
|
3445
|
+
const compareOptions = { dontLimitMoves: options3.dontLimitMoves, sparse: true };
|
|
3286
3446
|
editScript = compareArrays(lastArray, array, compareOptions);
|
|
3287
3447
|
}
|
|
3288
|
-
for (
|
|
3448
|
+
for (let i = 0, editScriptItem, movedIndex, itemIndex; editScriptItem = editScript[i]; i++) {
|
|
3289
3449
|
movedIndex = editScriptItem["moved"];
|
|
3290
3450
|
itemIndex = editScriptItem["index"];
|
|
3291
3451
|
switch (editScriptItem["status"]) {
|
|
@@ -3300,7 +3460,7 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, c
|
|
|
3300
3460
|
mapData.dependentObservable = void 0;
|
|
3301
3461
|
}
|
|
3302
3462
|
if (fixUpContinuousNodeArray(mapData.mappedNodes, domNode).length) {
|
|
3303
|
-
if (options3
|
|
3463
|
+
if (options3.beforeRemove) {
|
|
3304
3464
|
newMappingResult.push(mapData);
|
|
3305
3465
|
itemsToProcess.push(mapData);
|
|
3306
3466
|
countWaitingForRemove++;
|
|
@@ -3310,7 +3470,7 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, c
|
|
|
3310
3470
|
itemsForBeforeRemoveCallbacks.push(mapData);
|
|
3311
3471
|
}
|
|
3312
3472
|
}
|
|
3313
|
-
if (mapData) {
|
|
3473
|
+
if (mapData == null ? void 0 : mapData.mappedNodes) {
|
|
3314
3474
|
nodesToDelete.push.apply(nodesToDelete, mapData.mappedNodes);
|
|
3315
3475
|
}
|
|
3316
3476
|
}
|
|
@@ -3335,14 +3495,22 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, c
|
|
|
3335
3495
|
newMappingResult["_countWaitingForRemove"] = countWaitingForRemove;
|
|
3336
3496
|
}
|
|
3337
3497
|
data_exports.set(domNode, lastMappingResultDomDataKey, newMappingResult);
|
|
3338
|
-
callCallback(options3
|
|
3339
|
-
arrayForEach(nodesToDelete, options3
|
|
3340
|
-
|
|
3341
|
-
for (var nextNode = virtualElements_exports.firstChild(domNode), lastNode, node; mapData = itemsToProcess[i]; i++) {
|
|
3498
|
+
callCallback(options3.beforeMove, itemsForMoveCallbacks);
|
|
3499
|
+
arrayForEach(nodesToDelete, options3.beforeRemove ? cleanNode : removeNode);
|
|
3500
|
+
for (let k = 0, nextNode = virtualElements_exports.firstChild(domNode), lastNode, node; mapData = itemsToProcess[k]; k++) {
|
|
3342
3501
|
if (!mapData.mappedNodes) {
|
|
3343
|
-
extend(
|
|
3344
|
-
|
|
3345
|
-
|
|
3502
|
+
extend(
|
|
3503
|
+
mapData,
|
|
3504
|
+
mapNodeAndRefreshWhenChanged(
|
|
3505
|
+
domNode,
|
|
3506
|
+
mapping,
|
|
3507
|
+
mapData.arrayEntry,
|
|
3508
|
+
callbackAfterAddingNodes,
|
|
3509
|
+
mapData.indexObservable
|
|
3510
|
+
)
|
|
3511
|
+
);
|
|
3512
|
+
}
|
|
3513
|
+
for (let j = 0; node = mapData.mappedNodes[j]; nextNode = node.nextSibling, lastNode = node, j++) {
|
|
3346
3514
|
if (node !== nextNode) {
|
|
3347
3515
|
virtualElements_exports.insertAfter(domNode, node, lastNode);
|
|
3348
3516
|
}
|
|
@@ -3352,12 +3520,12 @@ function setDomNodeChildrenFromArrayMapping(domNode, array, mapping, options3, c
|
|
|
3352
3520
|
mapData.initialized = true;
|
|
3353
3521
|
}
|
|
3354
3522
|
}
|
|
3355
|
-
callCallback(options3
|
|
3356
|
-
for (
|
|
3357
|
-
itemsForBeforeRemoveCallbacks[
|
|
3523
|
+
callCallback(options3.beforeRemove, itemsForBeforeRemoveCallbacks);
|
|
3524
|
+
for (let x = 0; x < itemsForBeforeRemoveCallbacks.length; ++x) {
|
|
3525
|
+
itemsForBeforeRemoveCallbacks[x].arrayEntry = deletedItemDummyValue;
|
|
3358
3526
|
}
|
|
3359
|
-
callCallback(options3
|
|
3360
|
-
callCallback(options3
|
|
3527
|
+
callCallback(options3.afterMove, itemsForMoveCallbacks);
|
|
3528
|
+
callCallback(options3.afterAdd, itemsForAfterAddCallbacks);
|
|
3361
3529
|
}
|
|
3362
3530
|
|
|
3363
3531
|
// src/descendantsComplete.ts
|
|
@@ -3375,7 +3543,7 @@ var DescendantsCompleteHandler = class extends BindingHandler {
|
|
|
3375
3543
|
// src/enableDisable.ts
|
|
3376
3544
|
var enable = {
|
|
3377
3545
|
update: function(element, valueAccessor) {
|
|
3378
|
-
|
|
3546
|
+
const value2 = unwrap(valueAccessor());
|
|
3379
3547
|
if (value2 && element.disabled) {
|
|
3380
3548
|
element.removeAttribute("disabled");
|
|
3381
3549
|
} else if (!value2 && !element.disabled) {
|
|
@@ -3395,12 +3563,12 @@ var disable = {
|
|
|
3395
3563
|
var hasfocusUpdatingProperty = createSymbolOrString("__ko_hasfocusUpdating");
|
|
3396
3564
|
var hasfocusLastValue = createSymbolOrString("__ko_hasfocusLastValue");
|
|
3397
3565
|
var hasfocus = {
|
|
3398
|
-
init: function(element, valueAccessor) {
|
|
3399
|
-
|
|
3566
|
+
init: function(element, valueAccessor, _allBindings) {
|
|
3567
|
+
const handleElementFocusChange = function(isFocused) {
|
|
3400
3568
|
element[hasfocusUpdatingProperty] = true;
|
|
3401
|
-
|
|
3569
|
+
const ownerDoc = element.ownerDocument;
|
|
3402
3570
|
if ("activeElement" in ownerDoc) {
|
|
3403
|
-
|
|
3571
|
+
let active;
|
|
3404
3572
|
try {
|
|
3405
3573
|
active = ownerDoc.activeElement;
|
|
3406
3574
|
} catch (e) {
|
|
@@ -3408,21 +3576,28 @@ var hasfocus = {
|
|
|
3408
3576
|
}
|
|
3409
3577
|
isFocused = active === element;
|
|
3410
3578
|
}
|
|
3411
|
-
valueAccessor(isFocused, { onlyIfChanged: true });
|
|
3579
|
+
const modelValue = valueAccessor(isFocused, { onlyIfChanged: true });
|
|
3580
|
+
if (isWriteableObservable(modelValue) && modelValue.peek() !== isFocused) {
|
|
3581
|
+
modelValue(isFocused);
|
|
3582
|
+
}
|
|
3412
3583
|
element[hasfocusLastValue] = isFocused;
|
|
3413
3584
|
element[hasfocusUpdatingProperty] = false;
|
|
3414
3585
|
};
|
|
3415
|
-
|
|
3416
|
-
|
|
3586
|
+
const handleElementFocusIn = handleElementFocusChange.bind(null, true);
|
|
3587
|
+
const handleElementFocusOut = handleElementFocusChange.bind(null, false);
|
|
3417
3588
|
registerEventHandler(element, "focus", handleElementFocusIn);
|
|
3418
3589
|
registerEventHandler(element, "focusin", handleElementFocusIn);
|
|
3419
3590
|
registerEventHandler(element, "blur", handleElementFocusOut);
|
|
3420
3591
|
registerEventHandler(element, "focusout", handleElementFocusOut);
|
|
3421
3592
|
},
|
|
3422
3593
|
update: function(element, valueAccessor) {
|
|
3423
|
-
|
|
3594
|
+
const value2 = !!unwrap(valueAccessor());
|
|
3424
3595
|
if (!element[hasfocusUpdatingProperty] && element[hasfocusLastValue] !== value2) {
|
|
3425
|
-
|
|
3596
|
+
if (value2) {
|
|
3597
|
+
element.focus();
|
|
3598
|
+
} else {
|
|
3599
|
+
element.blur();
|
|
3600
|
+
}
|
|
3426
3601
|
if (!value2 && element[hasfocusLastValue]) {
|
|
3427
3602
|
element.ownerDocument.body.focus();
|
|
3428
3603
|
}
|
|
@@ -3434,10 +3609,11 @@ var hasfocus = {
|
|
|
3434
3609
|
// src/html.ts
|
|
3435
3610
|
var html = {
|
|
3436
3611
|
init: function() {
|
|
3437
|
-
return {
|
|
3438
|
-
"controlsDescendantBindings": true
|
|
3439
|
-
};
|
|
3612
|
+
return { controlsDescendantBindings: true };
|
|
3440
3613
|
},
|
|
3614
|
+
//
|
|
3615
|
+
// Modify internal, per ko.punches and :
|
|
3616
|
+
// http://stackoverflow.com/a/15348139
|
|
3441
3617
|
update: function(element, valueAccessor) {
|
|
3442
3618
|
setHtml(element, valueAccessor());
|
|
3443
3619
|
},
|
|
@@ -3446,10 +3622,10 @@ var html = {
|
|
|
3446
3622
|
|
|
3447
3623
|
// src/let.ts
|
|
3448
3624
|
var let_default = {
|
|
3449
|
-
init: function(element, valueAccessor,
|
|
3450
|
-
|
|
3625
|
+
init: function(element, valueAccessor, _allBindings, _viewModel, bindingContext2) {
|
|
3626
|
+
const innerContext = bindingContext2["extend"](valueAccessor);
|
|
3451
3627
|
applyBindingsToDescendants(innerContext, element);
|
|
3452
|
-
return {
|
|
3628
|
+
return { controlsDescendantBindings: true };
|
|
3453
3629
|
},
|
|
3454
3630
|
allowVirtualElements: true
|
|
3455
3631
|
};
|
|
@@ -3464,7 +3640,7 @@ var options2 = {
|
|
|
3464
3640
|
while (element.length > 0) {
|
|
3465
3641
|
element.remove(0);
|
|
3466
3642
|
}
|
|
3467
|
-
return {
|
|
3643
|
+
return { controlsDescendantBindings: true };
|
|
3468
3644
|
},
|
|
3469
3645
|
update: function(element, valueAccessor, allBindings) {
|
|
3470
3646
|
function selectedOptions2() {
|
|
@@ -3472,7 +3648,7 @@ var options2 = {
|
|
|
3472
3648
|
return node.selected;
|
|
3473
3649
|
});
|
|
3474
3650
|
}
|
|
3475
|
-
|
|
3651
|
+
let 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 = new Array();
|
|
3476
3652
|
if (!valueAllowUnset) {
|
|
3477
3653
|
if (multiple) {
|
|
3478
3654
|
previousSelectedValues = arrayMap(selectedOptions2(), selectExtensions.readValue);
|
|
@@ -3495,30 +3671,30 @@ var options2 = {
|
|
|
3495
3671
|
}
|
|
3496
3672
|
} else {
|
|
3497
3673
|
}
|
|
3498
|
-
function applyToObject(
|
|
3499
|
-
|
|
3674
|
+
function applyToObject(object, predicate, defaultValue) {
|
|
3675
|
+
const predicateType = typeof predicate;
|
|
3500
3676
|
if (predicateType === "function") {
|
|
3501
|
-
return predicate(
|
|
3677
|
+
return predicate(object);
|
|
3502
3678
|
} else if (predicateType == "string") {
|
|
3503
|
-
return
|
|
3679
|
+
return object[predicate];
|
|
3504
3680
|
} else {
|
|
3505
3681
|
return defaultValue;
|
|
3506
3682
|
}
|
|
3507
3683
|
}
|
|
3508
|
-
|
|
3684
|
+
let itemUpdate = false;
|
|
3509
3685
|
function optionForArrayItem(arrayEntry, index, oldOptions) {
|
|
3510
3686
|
if (oldOptions.length) {
|
|
3511
3687
|
previousSelectedValues = !valueAllowUnset && oldOptions[0].selected ? [selectExtensions.readValue(oldOptions[0])] : [];
|
|
3512
3688
|
itemUpdate = true;
|
|
3513
3689
|
}
|
|
3514
|
-
|
|
3690
|
+
const option = element.ownerDocument.createElement("option");
|
|
3515
3691
|
if (arrayEntry === captionPlaceholder) {
|
|
3516
3692
|
setTextContent(option, allBindings.get("optionsCaption"));
|
|
3517
3693
|
selectExtensions.writeValue(option, void 0);
|
|
3518
3694
|
} else {
|
|
3519
|
-
|
|
3695
|
+
const optionValue = applyToObject(arrayEntry, allBindings.get("optionsValue"), arrayEntry);
|
|
3520
3696
|
selectExtensions.writeValue(option, unwrap(optionValue));
|
|
3521
|
-
|
|
3697
|
+
const optionText = applyToObject(arrayEntry, allBindings.get("optionsText"), optionValue);
|
|
3522
3698
|
setTextContent(option, optionText);
|
|
3523
3699
|
}
|
|
3524
3700
|
return [option];
|
|
@@ -3528,28 +3704,47 @@ var options2 = {
|
|
|
3528
3704
|
};
|
|
3529
3705
|
function setSelectionCallback(arrayEntry, newOptions) {
|
|
3530
3706
|
if (itemUpdate && valueAllowUnset) {
|
|
3531
|
-
selectExtensions.writeValue(
|
|
3707
|
+
selectExtensions.writeValue(
|
|
3708
|
+
element,
|
|
3709
|
+
unwrap(allBindings.get("value")),
|
|
3710
|
+
true
|
|
3711
|
+
/* allowUnset */
|
|
3712
|
+
);
|
|
3532
3713
|
} else if (previousSelectedValues.length) {
|
|
3533
|
-
|
|
3714
|
+
const isSelected = arrayIndexOf(previousSelectedValues, selectExtensions.readValue(newOptions[0])) >= 0;
|
|
3534
3715
|
setOptionNodeSelectionState(newOptions[0], isSelected);
|
|
3535
3716
|
if (itemUpdate && !isSelected) {
|
|
3536
3717
|
dependencyDetection_exports.ignore(triggerEvent, null, [element, "change"]);
|
|
3537
3718
|
}
|
|
3538
3719
|
}
|
|
3539
3720
|
}
|
|
3540
|
-
|
|
3721
|
+
let callback = setSelectionCallback;
|
|
3541
3722
|
if (allBindings["has"]("optionsAfterRender") && typeof allBindings.get("optionsAfterRender") === "function") {
|
|
3542
3723
|
callback = function(arrayEntry, newOptions) {
|
|
3543
3724
|
setSelectionCallback(arrayEntry, newOptions);
|
|
3544
|
-
dependencyDetection_exports.ignore(allBindings.get("optionsAfterRender"), null, [
|
|
3725
|
+
dependencyDetection_exports.ignore(allBindings.get("optionsAfterRender"), null, [
|
|
3726
|
+
newOptions[0],
|
|
3727
|
+
arrayEntry !== captionPlaceholder ? arrayEntry : void 0
|
|
3728
|
+
]);
|
|
3545
3729
|
};
|
|
3546
3730
|
}
|
|
3547
|
-
setDomNodeChildrenFromArrayMapping(
|
|
3731
|
+
setDomNodeChildrenFromArrayMapping(
|
|
3732
|
+
element,
|
|
3733
|
+
filteredArray,
|
|
3734
|
+
optionForArrayItem,
|
|
3735
|
+
arrayToDomNodeChildrenOptions,
|
|
3736
|
+
callback
|
|
3737
|
+
);
|
|
3548
3738
|
dependencyDetection_exports.ignore(function() {
|
|
3549
3739
|
if (valueAllowUnset) {
|
|
3550
|
-
selectExtensions.writeValue(
|
|
3740
|
+
selectExtensions.writeValue(
|
|
3741
|
+
element,
|
|
3742
|
+
unwrap(allBindings.get("value")),
|
|
3743
|
+
true
|
|
3744
|
+
/* allowUnset */
|
|
3745
|
+
);
|
|
3551
3746
|
} else {
|
|
3552
|
-
|
|
3747
|
+
let selectionChanged;
|
|
3553
3748
|
if (multiple) {
|
|
3554
3749
|
selectionChanged = previousSelectedValues.length && selectedOptions2().length < previousSelectedValues.length;
|
|
3555
3750
|
} else {
|
|
@@ -3560,7 +3755,6 @@ var options2 = {
|
|
|
3560
3755
|
}
|
|
3561
3756
|
}
|
|
3562
3757
|
});
|
|
3563
|
-
ensureSelectElementIsRenderedCorrectly(element);
|
|
3564
3758
|
if (previousScrollTop && Math.abs(previousScrollTop - element.scrollTop) > 20) {
|
|
3565
3759
|
element.scrollTop = previousScrollTop;
|
|
3566
3760
|
}
|
|
@@ -3570,9 +3764,9 @@ var options2 = {
|
|
|
3570
3764
|
// src/selectedOptions.ts
|
|
3571
3765
|
var selectedOptions = {
|
|
3572
3766
|
after: ["options", "foreach"],
|
|
3573
|
-
init: function(element, valueAccessor,
|
|
3767
|
+
init: function(element, valueAccessor, _allBindings) {
|
|
3574
3768
|
registerEventHandler(element, "change", function() {
|
|
3575
|
-
|
|
3769
|
+
const value2 = valueAccessor(), valueToWrite = new Array();
|
|
3576
3770
|
arrayForEach(element.getElementsByTagName("option"), function(node) {
|
|
3577
3771
|
if (node.selected) {
|
|
3578
3772
|
valueToWrite.push(selectExtensions.readValue(node));
|
|
@@ -3585,10 +3779,10 @@ var selectedOptions = {
|
|
|
3585
3779
|
if (tagNameLower(element) != "select") {
|
|
3586
3780
|
throw new Error("values binding applies only to SELECT elements");
|
|
3587
3781
|
}
|
|
3588
|
-
|
|
3782
|
+
const newValue = unwrap(valueAccessor()), previousScrollTop = element.scrollTop;
|
|
3589
3783
|
if (newValue && typeof newValue.length === "number") {
|
|
3590
3784
|
arrayForEach(element.getElementsByTagName("option"), function(node) {
|
|
3591
|
-
|
|
3785
|
+
const isSelected = arrayIndexOf(newValue, selectExtensions.readValue(node)) >= 0;
|
|
3592
3786
|
if (node.selected != isSelected) {
|
|
3593
3787
|
setOptionNodeSelectionState(node, isSelected);
|
|
3594
3788
|
}
|
|
@@ -3599,17 +3793,16 @@ var selectedOptions = {
|
|
|
3599
3793
|
};
|
|
3600
3794
|
|
|
3601
3795
|
// src/style.ts
|
|
3602
|
-
var { jQueryInstance: jQueryInstance2 } = options_default;
|
|
3603
3796
|
var style = {
|
|
3604
3797
|
update: function(element, valueAccessor) {
|
|
3605
|
-
|
|
3798
|
+
const value2 = unwrap(valueAccessor() || {});
|
|
3606
3799
|
objectForEach(value2, function(styleName, styleValue) {
|
|
3607
3800
|
styleValue = unwrap(styleValue);
|
|
3608
3801
|
if (styleValue === null || styleValue === void 0 || styleValue === false) {
|
|
3609
3802
|
styleValue = "";
|
|
3610
3803
|
}
|
|
3611
|
-
if (
|
|
3612
|
-
|
|
3804
|
+
if (options_default.jQuery) {
|
|
3805
|
+
jQuery(element).css(styleName, styleValue);
|
|
3613
3806
|
} else {
|
|
3614
3807
|
styleName = styleName.replace(/-(\w)/g, (all, letter) => letter.toUpperCase());
|
|
3615
3808
|
const previousStyle = element.style[styleName];
|
|
@@ -3624,13 +3817,13 @@ var style = {
|
|
|
3624
3817
|
|
|
3625
3818
|
// src/submit.ts
|
|
3626
3819
|
var submit = {
|
|
3627
|
-
init: function(element, valueAccessor,
|
|
3820
|
+
init: function(element, valueAccessor, _allBindings, _viewModel, bindingContext2) {
|
|
3628
3821
|
if (typeof valueAccessor() !== "function") {
|
|
3629
3822
|
throw new Error("The value for a submit binding must be a function");
|
|
3630
3823
|
}
|
|
3631
3824
|
registerEventHandler(element, "submit", function(event) {
|
|
3632
|
-
|
|
3633
|
-
|
|
3825
|
+
let handlerReturnValue;
|
|
3826
|
+
const value2 = valueAccessor();
|
|
3634
3827
|
try {
|
|
3635
3828
|
handlerReturnValue = value2.call(bindingContext2["$data"], element);
|
|
3636
3829
|
} finally {
|
|
@@ -3658,9 +3851,11 @@ var text = {
|
|
|
3658
3851
|
};
|
|
3659
3852
|
|
|
3660
3853
|
// src/textInput.ts
|
|
3854
|
+
var MSIE_REGEX = /MSIE ([^ ;]+)|rv:([^ )]+)/;
|
|
3661
3855
|
var operaVersion;
|
|
3662
3856
|
var safariVersion;
|
|
3663
3857
|
var firefoxVersion;
|
|
3858
|
+
var ieVersion;
|
|
3664
3859
|
var TextInput = class extends BindingHandler {
|
|
3665
3860
|
get aliases() {
|
|
3666
3861
|
return "textinput";
|
|
@@ -3698,6 +3893,7 @@ var TextInput = class extends BindingHandler {
|
|
|
3698
3893
|
const elementValue = element.value;
|
|
3699
3894
|
if (this.previousElementValue !== elementValue) {
|
|
3700
3895
|
if (options_default.debug && event) {
|
|
3896
|
+
;
|
|
3701
3897
|
element._ko_textInputProcessedEvent = event.type;
|
|
3702
3898
|
}
|
|
3703
3899
|
this.previousElementValue = elementValue;
|
|
@@ -3708,8 +3904,8 @@ var TextInput = class extends BindingHandler {
|
|
|
3708
3904
|
const element = this.$element;
|
|
3709
3905
|
if (!this.timeoutHandle) {
|
|
3710
3906
|
this.elementValueBeforeEvent = element.value;
|
|
3711
|
-
const
|
|
3712
|
-
this.timeoutHandle = safeSetTimeout(
|
|
3907
|
+
const handler = options_default.debug ? this.updateModel.bind(this, { type: event.type }) : this.updateModel;
|
|
3908
|
+
this.timeoutHandle = safeSetTimeout(handler, 4);
|
|
3713
3909
|
}
|
|
3714
3910
|
}
|
|
3715
3911
|
updateView() {
|
|
@@ -3727,43 +3923,8 @@ var TextInput = class extends BindingHandler {
|
|
|
3727
3923
|
}
|
|
3728
3924
|
};
|
|
3729
3925
|
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
3926
|
eventsIndicatingSyncValueChange() {
|
|
3741
|
-
return [...super.
|
|
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"];
|
|
3927
|
+
return [...super.eventsIndicatingSyncValueChange(), "keypress"];
|
|
3767
3928
|
}
|
|
3768
3929
|
};
|
|
3769
3930
|
var TextInputLegacySafari = class extends TextInput {
|
|
@@ -3780,9 +3941,13 @@ var TextInputLegacyFirefox = class extends TextInput {
|
|
|
3780
3941
|
eventsIndicatingValueChange() {
|
|
3781
3942
|
return [
|
|
3782
3943
|
...super.eventsIndicatingSyncValueChange(),
|
|
3944
|
+
// Firefox <= 3.6 doesn't fire the 'input' event when text is filled in through autocomplete
|
|
3783
3945
|
"DOMAutoComplete",
|
|
3946
|
+
// Firefox <=3.5 doesn't fire the 'input' event when text is dropped into the input.
|
|
3784
3947
|
"dragdrop",
|
|
3948
|
+
// < 3.5
|
|
3785
3949
|
"drop"
|
|
3950
|
+
// 3.5
|
|
3786
3951
|
];
|
|
3787
3952
|
}
|
|
3788
3953
|
};
|
|
@@ -3791,18 +3956,22 @@ if (w2.navigator) {
|
|
|
3791
3956
|
const parseVersion = (matches) => matches && parseFloat(matches[1]);
|
|
3792
3957
|
const userAgent = w2.navigator.userAgent;
|
|
3793
3958
|
const isChrome = userAgent.match(/Chrome\/([^ ]+)/);
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3959
|
+
if (!isChrome) {
|
|
3960
|
+
operaVersion = w2.opera && w2.opera.version && parseInt(w2.opera.version());
|
|
3961
|
+
safariVersion = parseVersion(userAgent.match(/Version\/([^ ]+) Safari/));
|
|
3962
|
+
firefoxVersion = parseVersion(userAgent.match(/Firefox\/([^ ]*)/));
|
|
3963
|
+
const ieMatch = userAgent.match(MSIE_REGEX);
|
|
3964
|
+
ieVersion = ieMatch && (parseFloat(ieMatch[1]) || parseFloat(ieMatch[2]));
|
|
3965
|
+
}
|
|
3797
3966
|
}
|
|
3798
|
-
var textInput = ieVersion
|
|
3967
|
+
var textInput = ieVersion && ieVersion <= 11 ? TextInputIE : safariVersion && safariVersion < 5 ? TextInputLegacySafari : operaVersion && operaVersion < 11 ? TextInputLegacyOpera : firefoxVersion && firefoxVersion < 4 ? TextInputLegacyFirefox : TextInput;
|
|
3799
3968
|
|
|
3800
3969
|
// src/uniqueName.ts
|
|
3801
3970
|
var uniqueName = {
|
|
3802
3971
|
init: function(element, valueAccessor) {
|
|
3803
3972
|
if (valueAccessor()) {
|
|
3804
|
-
|
|
3805
|
-
|
|
3973
|
+
const name = "ko_unique_" + ++uniqueName.currentIndex;
|
|
3974
|
+
element.name = name;
|
|
3806
3975
|
}
|
|
3807
3976
|
},
|
|
3808
3977
|
currentIndex: 0
|
|
@@ -3846,8 +4015,10 @@ var value = class extends BindingHandler {
|
|
|
3846
4015
|
const e = this.$element;
|
|
3847
4016
|
return this.isInput && (e.type == "checkbox" || e.type == "radio");
|
|
3848
4017
|
}
|
|
4018
|
+
// Workaround for https://github.com/SteveSanderson/knockout/issues/122
|
|
4019
|
+
// IE doesn't fire "change" events on textboxes if the user selects a value from its autocomplete list
|
|
3849
4020
|
get ieAutoCompleteHackNeeded() {
|
|
3850
|
-
return
|
|
4021
|
+
return this.isInput && this.$element.type == "text" && this.$element.autocomplete != "off" && (!this.$element.form || this.$element.form.autocomplete != "off") && MSIE_REGEX.test(window.navigator.userAgent);
|
|
3851
4022
|
}
|
|
3852
4023
|
valueUpdateHandler() {
|
|
3853
4024
|
this.elementValueBeforeEvent = null;
|
|
@@ -3855,18 +4026,21 @@ var value = class extends BindingHandler {
|
|
|
3855
4026
|
this.value = selectExtensions.readValue(this.$element);
|
|
3856
4027
|
}
|
|
3857
4028
|
registerEvent(eventName) {
|
|
3858
|
-
|
|
4029
|
+
let handler = this.valueUpdateHandler.bind(this);
|
|
3859
4030
|
if (stringStartsWith(eventName, "after")) {
|
|
3860
|
-
|
|
4031
|
+
handler = () => {
|
|
3861
4032
|
this.elementValueBeforeEvent = selectExtensions.readValue(this.$element);
|
|
3862
4033
|
safeSetTimeout(this.valueUpdateHandler.bind(this), 0);
|
|
3863
4034
|
};
|
|
3864
|
-
eventName = eventName.substring(
|
|
4035
|
+
eventName = eventName.substring(
|
|
4036
|
+
5
|
|
4037
|
+
/* 'after'.length */
|
|
4038
|
+
);
|
|
3865
4039
|
}
|
|
3866
|
-
this.addEventListener(eventName,
|
|
4040
|
+
this.addEventListener(eventName, handler);
|
|
3867
4041
|
}
|
|
3868
4042
|
updateFromModelForFile() {
|
|
3869
|
-
|
|
4043
|
+
const newValue = unwrap(this.value);
|
|
3870
4044
|
if (newValue === null || newValue === void 0 || newValue === "") {
|
|
3871
4045
|
this.$element.value = "";
|
|
3872
4046
|
} else {
|
|
@@ -3875,8 +4049,8 @@ var value = class extends BindingHandler {
|
|
|
3875
4049
|
}
|
|
3876
4050
|
updateFromModelForValue() {
|
|
3877
4051
|
const element = this.$element;
|
|
3878
|
-
|
|
3879
|
-
|
|
4052
|
+
const newValue = unwrap(this.value);
|
|
4053
|
+
const elementValue = selectExtensions.readValue(element);
|
|
3880
4054
|
if (this.elementValueBeforeEvent !== null && newValue === this.elementValueBeforeEvent) {
|
|
3881
4055
|
safeSetTimeout(this.updateFromModel.bind(this), 0);
|
|
3882
4056
|
return;
|
|
@@ -3899,8 +4073,8 @@ var value = class extends BindingHandler {
|
|
|
3899
4073
|
// src/visible.ts
|
|
3900
4074
|
var visible = {
|
|
3901
4075
|
update: function(element, valueAccessor) {
|
|
3902
|
-
|
|
3903
|
-
|
|
4076
|
+
const value2 = unwrap(valueAccessor());
|
|
4077
|
+
const isCurrentlyVisible = !(element.style.display === "none");
|
|
3904
4078
|
if (value2 && !isCurrentlyVisible) {
|
|
3905
4079
|
element.style.display = "";
|
|
3906
4080
|
} else if (!value2 && isCurrentlyVisible) {
|
|
@@ -3916,8 +4090,8 @@ var hidden = {
|
|
|
3916
4090
|
|
|
3917
4091
|
// src/using.ts
|
|
3918
4092
|
var using = {
|
|
3919
|
-
init: function(element, valueAccessor,
|
|
3920
|
-
|
|
4093
|
+
init: function(element, valueAccessor, _allBindings, _viewModel, bindingContext2) {
|
|
4094
|
+
const innerContext = bindingContext2.createChildContext(valueAccessor);
|
|
3921
4095
|
applyBindingsToDescendants(innerContext, element);
|
|
3922
4096
|
return { controlsDescendantBindings: true };
|
|
3923
4097
|
},
|
|
@@ -3931,16 +4105,16 @@ var bindings = {
|
|
|
3931
4105
|
checkedValue,
|
|
3932
4106
|
click,
|
|
3933
4107
|
css,
|
|
3934
|
-
|
|
4108
|
+
class: css,
|
|
3935
4109
|
descendantsComplete: DescendantsCompleteHandler,
|
|
3936
4110
|
enable,
|
|
3937
|
-
|
|
4111
|
+
event: eventHandler,
|
|
3938
4112
|
disable,
|
|
3939
4113
|
hasfocus,
|
|
3940
4114
|
hasFocus: hasfocus,
|
|
3941
4115
|
hidden,
|
|
3942
4116
|
html,
|
|
3943
|
-
|
|
4117
|
+
let: let_default,
|
|
3944
4118
|
on: onHandler,
|
|
3945
4119
|
options: options2,
|
|
3946
4120
|
selectedOptions,
|