@tko/utils 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.
Files changed (55) hide show
  1. package/dist/array.js +39 -35
  2. package/dist/array.js.map +2 -2
  3. package/dist/async.js +4 -3
  4. package/dist/async.js.map +2 -2
  5. package/dist/css.js +5 -4
  6. package/dist/css.js.map +2 -2
  7. package/dist/dom/data.js +36 -46
  8. package/dist/dom/data.js.map +2 -2
  9. package/dist/dom/disposal.js +23 -16
  10. package/dist/dom/disposal.js.map +2 -2
  11. package/dist/dom/event.js +39 -41
  12. package/dist/dom/event.js.map +2 -2
  13. package/dist/dom/fixes.js +5 -24
  14. package/dist/dom/fixes.js.map +2 -2
  15. package/dist/dom/html.js +46 -61
  16. package/dist/dom/html.js.map +2 -2
  17. package/dist/dom/info.js +10 -8
  18. package/dist/dom/info.js.map +2 -2
  19. package/dist/dom/manipulation.js +16 -24
  20. package/dist/dom/manipulation.js.map +2 -2
  21. package/dist/dom/selectExtensions.js +33 -23
  22. package/dist/dom/selectExtensions.js.map +2 -2
  23. package/dist/dom/virtualElements.js +40 -32
  24. package/dist/dom/virtualElements.js.map +3 -3
  25. package/dist/error.js +2 -1
  26. package/dist/error.js.map +2 -2
  27. package/dist/function.js +2 -1
  28. package/dist/function.js.map +2 -2
  29. package/dist/index.cjs +446 -449
  30. package/dist/index.cjs.map +4 -4
  31. package/dist/index.js +2 -3
  32. package/dist/index.js.map +2 -2
  33. package/dist/index.mjs +2 -3
  34. package/dist/index.mjs.map +2 -2
  35. package/dist/memoization.js +18 -13
  36. package/dist/memoization.js.map +3 -3
  37. package/dist/object.js +10 -8
  38. package/dist/object.js.map +2 -2
  39. package/dist/options.js +97 -35
  40. package/dist/options.js.map +2 -2
  41. package/dist/string.js +3 -5
  42. package/dist/string.js.map +2 -2
  43. package/dist/symbol.js +3 -2
  44. package/dist/symbol.js.map +2 -2
  45. package/dist/tasks.js +10 -20
  46. package/dist/tasks.js.map +2 -2
  47. package/helpers/jasmine-13-helper.ts +198 -147
  48. package/package.json +2 -3
  49. package/LICENSE +0 -22
  50. package/dist/bind-shim.js +0 -18
  51. package/dist/bind-shim.js.map +0 -7
  52. package/dist/ie.js +0 -15
  53. package/dist/ie.js.map +0 -7
  54. package/dist/jquery.js +0 -6
  55. package/dist/jquery.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/dom/manipulation.ts"],
4
- "sourcesContent": ["//\n// DOM manipulation\n//\n/* eslint no-empty: 0 */\nimport { makeArray } from '../array'\nimport { ieVersion } from '../ie'\nimport { cleanNode, removeNode } from './disposal'\n\nexport function moveCleanedNodesToContainerElement (nodes) {\n // Ensure it's a real array, as we're about to reparent the nodes and\n // we don't want the underlying collection to change while we're doing that.\n var nodesArray = makeArray(nodes)\n var templateDocument = (nodesArray[0] && nodesArray[0].ownerDocument) || document\n\n var container = templateDocument.createElement('div')\n for (var i = 0, j = nodesArray.length; i < j; i++) {\n container.appendChild(cleanNode(nodesArray[i]))\n }\n return container\n}\n\nexport function cloneNodes (nodesArray, shouldCleanNodes) {\n for (var i = 0, j = nodesArray.length, newNodesArray = []; i < j; i++) {\n var clonedNode = nodesArray[i].cloneNode(true)\n newNodesArray.push(shouldCleanNodes ? cleanNode(clonedNode) : clonedNode)\n }\n return newNodesArray\n}\n\nexport function setDomNodeChildren (domNode, childNodes) {\n emptyDomNode(domNode)\n if (childNodes) {\n for (var i = 0, j = childNodes.length; i < j; i++) { domNode.appendChild(childNodes[i]) }\n }\n}\n\nexport function replaceDomNodes (nodeToReplaceOrNodeArray, newNodesArray) {\n var nodesToReplaceArray = nodeToReplaceOrNodeArray.nodeType ? [nodeToReplaceOrNodeArray] : nodeToReplaceOrNodeArray\n if (nodesToReplaceArray.length > 0) {\n var insertionPoint = nodesToReplaceArray[0]\n var parent = insertionPoint.parentNode\n for (var i = 0, j = newNodesArray.length; i < j; i++) { parent.insertBefore(newNodesArray[i], insertionPoint) }\n for (i = 0, j = nodesToReplaceArray.length; i < j; i++) {\n removeNode(nodesToReplaceArray[i])\n }\n }\n}\n\nexport function setElementName (element, name) {\n element.name = name\n\n // Workaround IE 6/7 issue\n // - https://github.com/SteveSanderson/knockout/issues/197\n // - http://www.matts411.com/post/setting_the_name_attribute_in_ie_dom/\n if (ieVersion <= 7) {\n try {\n element.mergeAttributes(document.createElement(\"<input name='\" + element.name + \"'/>\"), false)\n } catch (e) {} // For IE9 with doc mode \"IE9 Standards\" and browser mode \"IE9 Compatibility View\"\n }\n}\n\nexport function emptyDomNode (domNode) {\n while (domNode.firstChild) {\n removeNode(domNode.firstChild)\n }\n}\n"],
5
- "mappings": ";AAIA;AACA;AACA;AAEO,mDAA6C,OAAO;AAGzD,MAAI,aAAa,UAAU,KAAK;AAChC,MAAI,mBAAoB,WAAW,MAAM,WAAW,GAAG,iBAAkB;AAEzE,MAAI,YAAY,iBAAiB,cAAc,KAAK;AACpD,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,IAAI,GAAG,KAAK;AACjD,cAAU,YAAY,UAAU,WAAW,EAAE,CAAC;AAAA,EAChD;AACA,SAAO;AACT;AAEO,2BAAqB,YAAY,kBAAkB;AACxD,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,gBAAgB,CAAC,GAAG,IAAI,GAAG,KAAK;AACrE,QAAI,aAAa,WAAW,GAAG,UAAU,IAAI;AAC7C,kBAAc,KAAK,mBAAmB,UAAU,UAAU,IAAI,UAAU;AAAA,EAC1E;AACA,SAAO;AACT;AAEO,mCAA6B,SAAS,YAAY;AACvD,eAAa,OAAO;AACpB,MAAI,YAAY;AACd,aAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,IAAI,GAAG,KAAK;AAAE,cAAQ,YAAY,WAAW,EAAE;AAAA,IAAE;AAAA,EAC1F;AACF;AAEO,gCAA0B,0BAA0B,eAAe;AACxE,MAAI,sBAAsB,yBAAyB,WAAW,CAAC,wBAAwB,IAAI;AAC3F,MAAI,oBAAoB,SAAS,GAAG;AAClC,QAAI,iBAAiB,oBAAoB;AACzC,QAAI,SAAS,eAAe;AAC5B,aAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,IAAI,GAAG,KAAK;AAAE,aAAO,aAAa,cAAc,IAAI,cAAc;AAAA,IAAE;AAC9G,SAAK,IAAI,GAAG,IAAI,oBAAoB,QAAQ,IAAI,GAAG,KAAK;AACtD,iBAAW,oBAAoB,EAAE;AAAA,IACnC;AAAA,EACF;AACF;AAEO,+BAAyB,SAAS,MAAM;AAC7C,UAAQ,OAAO;AAKf,MAAI,aAAa,GAAG;AAClB,QAAI;AACF,cAAQ,gBAAgB,SAAS,cAAc,kBAAkB,QAAQ,OAAO,KAAK,GAAG,KAAK;AAAA,IAC/F,SAAS,GAAP;AAAA,IAAW;AAAA,EACf;AACF;AAEO,6BAAuB,SAAS;AACrC,SAAO,QAAQ,YAAY;AACzB,eAAW,QAAQ,UAAU;AAAA,EAC/B;AACF;",
4
+ "sourcesContent": ["//\n// DOM manipulation\n//\n/* eslint no-empty: 0 */\nimport { makeArray } from '../array'\nimport { cleanNode, removeNode } from './disposal'\n\nexport function moveCleanedNodesToContainerElement(nodes: ArrayLike<Node>) {\n // Ensure it's a real array, as we're about to reparent the nodes and\n // we don't want the underlying collection to change while we're doing that.\n const nodesArray = makeArray(nodes) as Node[]\n const templateDocument = (nodesArray[0] && nodesArray[0].ownerDocument) || document\n\n const container = templateDocument.createElement('div')\n for (let i = 0, j = nodesArray.length; i < j; i++) {\n container.appendChild(cleanNode(nodesArray[i]))\n }\n return container\n}\n\nexport function cloneNodes(nodesArray: ArrayLike<Node>, shouldCleanNodes?: boolean) {\n const newNodesArray = new Array()\n\n for (let i = 0; i < nodesArray.length; i++) {\n const clonedNode = nodesArray[i].cloneNode(true)\n newNodesArray.push(shouldCleanNodes ? cleanNode(clonedNode) : clonedNode)\n }\n\n return newNodesArray\n}\n\nexport function setDomNodeChildren(domNode: Node, childNodes: ArrayLike<Node>) {\n emptyDomNode(domNode)\n if (childNodes) {\n for (let i = 0; i < childNodes.length; i++) {\n domNode.appendChild(childNodes[i])\n }\n }\n}\n\nexport function replaceDomNodes(nodeToReplaceOrNodeArray: Node[] | Node, newNodesArray: Node[]) {\n const nodesToReplaceArray = Array.isArray(nodeToReplaceOrNodeArray)\n ? nodeToReplaceOrNodeArray\n : [nodeToReplaceOrNodeArray]\n if (nodesToReplaceArray.length > 0) {\n const insertionPoint = nodesToReplaceArray[0]\n const parent = insertionPoint.parentNode\n\n for (let i = 0; i < newNodesArray.length; i++) {\n parent?.insertBefore(newNodesArray[i], insertionPoint)\n }\n for (let i = 0; i < nodesToReplaceArray.length; i++) {\n removeNode(nodesToReplaceArray[i])\n }\n }\n}\n\nexport function emptyDomNode(domNode: Node) {\n while (domNode.firstChild) {\n removeNode(domNode.firstChild)\n }\n}\n"],
5
+ "mappings": ";;AAIA,SAAS,iBAAiB;AAC1B,SAAS,WAAW,kBAAkB;AAE/B,gBAAS,mCAAmC,OAAwB;AAGzE,QAAM,aAAa,UAAU,KAAK;AAClC,QAAM,mBAAoB,WAAW,CAAC,KAAK,WAAW,CAAC,EAAE,iBAAkB;AAE3E,QAAM,YAAY,iBAAiB,cAAc,KAAK;AACtD,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,IAAI,GAAG,KAAK;AACjD,cAAU,YAAY,UAAU,WAAW,CAAC,CAAC,CAAC;AAAA,EAChD;AACA,SAAO;AACT;AAEO,gBAAS,WAAW,YAA6B,kBAA4B;AAClF,QAAM,gBAAgB,IAAI,MAAM;AAEhC,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;AAC1C,UAAM,aAAa,WAAW,CAAC,EAAE,UAAU,IAAI;AAC/C,kBAAc,KAAK,mBAAmB,UAAU,UAAU,IAAI,UAAU;AAAA,EAC1E;AAEA,SAAO;AACT;AAEO,gBAAS,mBAAmB,SAAe,YAA6B;AAC7E,eAAa,OAAO;AACpB,MAAI,YAAY;AACd,aAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;AAC1C,cAAQ,YAAY,WAAW,CAAC,CAAC;AAAA,IACnC;AAAA,EACF;AACF;AAEO,gBAAS,gBAAgB,0BAAyC,eAAuB;AAC9F,QAAM,sBAAsB,MAAM,QAAQ,wBAAwB,IAC9D,2BACA,CAAC,wBAAwB;AAC7B,MAAI,oBAAoB,SAAS,GAAG;AAClC,UAAM,iBAAiB,oBAAoB,CAAC;AAC5C,UAAM,SAAS,eAAe;AAE9B,aAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;AAC7C,cAAQ,aAAa,cAAc,CAAC,GAAG,cAAc;AAAA,IACvD;AACA,aAAS,IAAI,GAAG,IAAI,oBAAoB,QAAQ,KAAK;AACnD,iBAAW,oBAAoB,CAAC,CAAC;AAAA,IACnC;AAAA,EACF;AACF;AAEO,gBAAS,aAAa,SAAe;AAC1C,SAAO,QAAQ,YAAY;AACzB,eAAW,QAAQ,UAAU;AAAA,EAC/B;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,18 +1,22 @@
1
- // @tko/utils 🥊 4.0.0-beta1.0 ESM
1
+ // @tko/utils 🥊 4.0.0 ESM
2
+ "use strict";
2
3
  import { tagNameLower } from "./info";
3
4
  import * as domData from "./data";
4
- var hasDomDataExpandoProperty = Symbol("Knockout selectExtensions hasDomDataProperty");
5
- export var selectExtensions = {
5
+ const hasDomDataExpandoProperty = /* @__PURE__ */ Symbol("Knockout selectExtensions hasDomDataProperty");
6
+ export const selectExtensions = {
6
7
  optionValueDomDataKey: domData.nextKey(),
7
8
  readValue: function(element) {
8
9
  switch (tagNameLower(element)) {
9
- case "option":
10
+ case "option": {
10
11
  if (element[hasDomDataExpandoProperty] === true) {
11
12
  return domData.get(element, selectExtensions.optionValueDomDataKey);
12
13
  }
13
14
  return element.value;
14
- case "select":
15
- return element.selectedIndex >= 0 ? selectExtensions.readValue(element.options[element.selectedIndex]) : void 0;
15
+ }
16
+ case "select": {
17
+ const selectElement = element;
18
+ return selectElement.selectedIndex >= 0 ? selectExtensions.readValue(selectElement.options[selectElement.selectedIndex]) : void 0;
19
+ }
16
20
  default:
17
21
  return element.value;
18
22
  }
@@ -25,36 +29,42 @@ export var selectExtensions = {
25
29
  if (hasDomDataExpandoProperty in element) {
26
30
  delete element[hasDomDataExpandoProperty];
27
31
  }
32
+ ;
28
33
  element.value = value;
29
34
  } else {
35
+ const el = element;
30
36
  domData.set(element, selectExtensions.optionValueDomDataKey, value);
31
- element[hasDomDataExpandoProperty] = true;
32
- element.value = typeof value === "number" ? value : "";
37
+ el[hasDomDataExpandoProperty] = true;
38
+ el.value = typeof value === "number" ? value : "";
33
39
  }
34
40
  break;
35
41
  case "select":
36
- if (value === "" || value === null) {
37
- value = void 0;
38
- }
39
- var selection = -1;
40
- for (let i = 0, n = element.options.length, optionValue; i < n; ++i) {
41
- optionValue = selectExtensions.readValue(element.options[i]);
42
- const strictEqual = optionValue === value;
43
- const blankEqual = optionValue === "" && value === void 0;
44
- const numericEqual = typeof value === "number" && Number(optionValue) === value;
45
- if (strictEqual || blankEqual || numericEqual) {
46
- selection = i;
47
- break;
42
+ {
43
+ if (value === "" || value === null) {
44
+ value = void 0;
45
+ }
46
+ let selection = -1;
47
+ const selectElement = element;
48
+ for (let i = 0, n = selectElement.options.length, optionValue; i < n; ++i) {
49
+ optionValue = selectExtensions.readValue(selectElement.options[i]);
50
+ const strictEqual = optionValue === value;
51
+ const blankEqual = optionValue === "" && value === void 0;
52
+ const numericEqual = typeof value === "number" && Number(optionValue) === value;
53
+ if (strictEqual || blankEqual || numericEqual) {
54
+ selection = i;
55
+ break;
56
+ }
57
+ }
58
+ if (allowUnset || selection >= 0 || value === void 0 && selectElement.size > 1) {
59
+ selectElement.selectedIndex = selection;
48
60
  }
49
- }
50
- if (allowUnset || selection >= 0 || value === void 0 && element.size > 1) {
51
- element.selectedIndex = selection;
52
61
  }
53
62
  break;
54
63
  default:
55
64
  if (value === null || value === void 0) {
56
65
  value = "";
57
66
  }
67
+ ;
58
68
  element.value = value;
59
69
  break;
60
70
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/dom/selectExtensions.ts"],
4
- "sourcesContent": ["\nimport { ieVersion } from '../ie'\nimport { safeSetTimeout } from '../error'\n\nimport { tagNameLower } from './info'\nimport * as domData from './data'\n\nvar hasDomDataExpandoProperty = Symbol('Knockout selectExtensions hasDomDataProperty')\n\n// Normally, SELECT elements and their OPTIONs can only take value of type 'string' (because the values\n// are stored on DOM attributes). ko.selectExtensions provides a way for SELECTs/OPTIONs to have values\n// that are arbitrary objects. This is very convenient when implementing things like cascading dropdowns.\n//\nexport var selectExtensions = {\n optionValueDomDataKey: domData.nextKey(),\n\n readValue: function (element) {\n switch (tagNameLower(element)) {\n case 'option':\n if (element[hasDomDataExpandoProperty] === true) { return domData.get(element, selectExtensions.optionValueDomDataKey) }\n return element.value\n case 'select':\n return element.selectedIndex >= 0 ? selectExtensions.readValue(element.options[element.selectedIndex]) : undefined\n default:\n return element.value\n }\n },\n\n writeValue: function (element, value, allowUnset) {\n switch (tagNameLower(element)) {\n case 'option':\n if (typeof value === 'string') {\n domData.set(element, selectExtensions.optionValueDomDataKey, undefined)\n if (hasDomDataExpandoProperty in element) { // IE <= 8 throws errors if you delete non-existent properties from a DOM node\n delete element[hasDomDataExpandoProperty]\n }\n element.value = value\n } else {\n // Store arbitrary object using DomData\n domData.set(element, selectExtensions.optionValueDomDataKey, value)\n element[hasDomDataExpandoProperty] = true\n // Special treatment of numbers is just for backward compatibility. KO 1.2.1 wrote numerical values to element.value.\n element.value = typeof value === 'number' ? value : ''\n }\n\n break\n case 'select':\n if (value === '' || value === null) {\n // A blank string or null value will select the caption\n value = undefined\n }\n var selection = -1\n for (let i = 0, n = element.options.length, optionValue; i < n; ++i) {\n optionValue = selectExtensions.readValue(element.options[i])\n // Include special check to handle selecting a caption with a blank string value\n // Note that the looser == check here is intentional so that integer model values will match string element values.\n const strictEqual = optionValue === value\n const blankEqual = optionValue === '' && value === undefined\n const numericEqual = typeof value === 'number' && Number(optionValue) === value\n if (strictEqual || blankEqual || numericEqual) {\n selection = i\n break\n }\n }\n if (allowUnset || selection >= 0 || (value === undefined && element.size > 1)) {\n element.selectedIndex = selection\n }\n break\n default:\n if ((value === null) || (value === undefined)) { value = '' }\n element.value = value\n break\n }\n }\n}\n"],
5
- "mappings": ";AAIA;AACA;AAEA,IAAI,4BAA4B,OAAO,8CAA8C;AAM9E,WAAI,mBAAmB;AAAA,EAC5B,uBAAuB,QAAQ,QAAQ;AAAA,EAEvC,WAAW,SAAU,SAAS;AAC5B,YAAQ,aAAa,OAAO;AAAA,WACrB;AACH,YAAI,QAAQ,+BAA+B,MAAM;AAAE,iBAAO,QAAQ,IAAI,SAAS,iBAAiB,qBAAqB;AAAA,QAAE;AACvH,eAAO,QAAQ;AAAA,WACZ;AACH,eAAO,QAAQ,iBAAiB,IAAI,iBAAiB,UAAU,QAAQ,QAAQ,QAAQ,cAAc,IAAI;AAAA;AAEzG,eAAO,QAAQ;AAAA;AAAA,EAErB;AAAA,EAEA,YAAY,SAAU,SAAS,OAAO,YAAY;AAChD,YAAQ,aAAa,OAAO;AAAA,WACrB;AACH,YAAI,OAAO,UAAU,UAAU;AAC7B,kBAAQ,IAAI,SAAS,iBAAiB,uBAAuB,MAAS;AACtE,cAAI,6BAA6B,SAAS;AACxC,mBAAO,QAAQ;AAAA,UACjB;AACA,kBAAQ,QAAQ;AAAA,QAClB,OAAO;AAEL,kBAAQ,IAAI,SAAS,iBAAiB,uBAAuB,KAAK;AAClE,kBAAQ,6BAA6B;AAErC,kBAAQ,QAAQ,OAAO,UAAU,WAAW,QAAQ;AAAA,QACtD;AAEA;AAAA,WACG;AACH,YAAI,UAAU,MAAM,UAAU,MAAM;AAElC,kBAAQ;AAAA,QACV;AACA,YAAI,YAAY;AAChB,iBAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,QAAQ,aAAa,IAAI,GAAG,EAAE,GAAG;AACnE,wBAAc,iBAAiB,UAAU,QAAQ,QAAQ,EAAE;AAG3D,gBAAM,cAAc,gBAAgB;AACpC,gBAAM,aAAa,gBAAgB,MAAM,UAAU;AACnD,gBAAM,eAAe,OAAO,UAAU,YAAY,OAAO,WAAW,MAAM;AAC1E,cAAI,eAAe,cAAc,cAAc;AAC7C,wBAAY;AACZ;AAAA,UACF;AAAA,QACF;AACA,YAAI,cAAc,aAAa,KAAM,UAAU,UAAa,QAAQ,OAAO,GAAI;AAC7E,kBAAQ,gBAAgB;AAAA,QAC1B;AACA;AAAA;AAEA,YAAK,UAAU,QAAU,UAAU,QAAY;AAAE,kBAAQ;AAAA,QAAG;AAC5D,gBAAQ,QAAQ;AAChB;AAAA;AAAA,EAEN;AACF;",
4
+ "sourcesContent": ["import { tagNameLower } from './info'\nimport * as domData from './data'\n\nconst hasDomDataExpandoProperty = Symbol('Knockout selectExtensions hasDomDataProperty')\n\n// Normally, SELECT elements and their OPTIONs can only take value of type 'string' (because the values\n// are stored on DOM attributes). ko.selectExtensions provides a way for SELECTs/OPTIONs to have values\n// that are arbitrary objects. This is very convenient when implementing things like cascading dropdowns.\n//\nexport const selectExtensions = {\n optionValueDomDataKey: domData.nextKey(),\n\n readValue: function (element: HTMLElement) {\n switch (tagNameLower(element)) {\n case 'option': {\n if (element[hasDomDataExpandoProperty] === true) {\n return domData.get(element, selectExtensions.optionValueDomDataKey)\n }\n return (element as HTMLOptionElement).value\n }\n case 'select': {\n const selectElement = element as HTMLSelectElement\n return selectElement.selectedIndex >= 0\n ? selectExtensions.readValue(selectElement.options[selectElement.selectedIndex])\n : undefined\n }\n default:\n return (element as HTMLInputElement).value\n }\n },\n\n writeValue: function (element: HTMLElement, value?: any, allowUnset?: boolean) {\n switch (tagNameLower(element)) {\n case 'option':\n if (typeof value === 'string') {\n domData.set(element, selectExtensions.optionValueDomDataKey, undefined)\n if (hasDomDataExpandoProperty in element) {\n // IE <= 8 throws errors if you delete non-existent properties from a DOM node\n delete element[hasDomDataExpandoProperty]\n }\n ;(element as HTMLOptionElement).value = value\n } else {\n const el = element as any //TODO Custom-Type with hasDomDataExpandoProperty\n // Store arbitrary object using DomData\n domData.set(element, selectExtensions.optionValueDomDataKey, value)\n el[hasDomDataExpandoProperty] = true\n // Special treatment of numbers is just for backward compatibility. KO 1.2.1 wrote numerical values to element.value.\n el.value = typeof value === 'number' ? value : ''\n }\n\n break\n case 'select':\n {\n if (value === '' || value === null) {\n // A blank string or null value will select the caption\n value = undefined\n }\n let selection = -1\n\n const selectElement = element as HTMLSelectElement\n\n for (let i = 0, n = selectElement.options.length, optionValue; i < n; ++i) {\n optionValue = selectExtensions.readValue(selectElement.options[i])\n // Include special check to handle selecting a caption with a blank string value\n // Note that the looser == check here is intentional so that integer model values will match string element values.\n const strictEqual = optionValue === value\n const blankEqual = optionValue === '' && value === undefined\n const numericEqual = typeof value === 'number' && Number(optionValue) === value\n if (strictEqual || blankEqual || numericEqual) {\n selection = i\n break\n }\n }\n if (allowUnset || selection >= 0 || (value === undefined && selectElement.size > 1)) {\n selectElement.selectedIndex = selection\n }\n }\n break\n default:\n if (value === null || value === undefined) {\n value = ''\n }\n ;(element as HTMLInputElement).value = value\n break\n }\n }\n}\n"],
5
+ "mappings": ";;AAAA,SAAS,oBAAoB;AAC7B,YAAY,aAAa;AAEzB,MAAM,4BAA4B,uBAAO,8CAA8C;AAMhF,aAAM,mBAAmB;AAAA,EAC9B,uBAAuB,QAAQ,QAAQ;AAAA,EAEvC,WAAW,SAAU,SAAsB;AACzC,YAAQ,aAAa,OAAO,GAAG;AAAA,MAC7B,KAAK,UAAU;AACb,YAAI,QAAQ,yBAAyB,MAAM,MAAM;AAC/C,iBAAO,QAAQ,IAAI,SAAS,iBAAiB,qBAAqB;AAAA,QACpE;AACA,eAAQ,QAA8B;AAAA,MACxC;AAAA,MACA,KAAK,UAAU;AACb,cAAM,gBAAgB;AACtB,eAAO,cAAc,iBAAiB,IAClC,iBA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;AACvC;AAAA,IACJ;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,27 +1,26 @@
1
- // @tko/utils 🥊 4.0.0-beta1.0 ESM
1
+ // @tko/utils 🥊 4.0.0 ESM
2
+ "use strict";
2
3
  import { emptyDomNode, setDomNodeChildren as setRegularDomNodeChildren } from "./manipulation";
3
4
  import { removeNode } from "./disposal";
4
5
  import { tagNameLower } from "./info";
5
6
  import * as domData from "./data";
6
- import options from "../options";
7
- var commentNodesHaveTextProperty = options.document && options.document.createComment("test").text === "<!--test-->";
8
- export var startCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*ko(?:\s+([\s\S]+))?\s*-->$/ : /^\s*ko(?:\s+([\s\S]+))?\s*$/;
9
- export var endCommentRegex = commentNodesHaveTextProperty ? /^<!--\s*\/ko\s*-->$/ : /^\s*\/ko\s*$/;
10
- var htmlTagsWithOptionallyClosingChildren = { "ul": true, "ol": true };
7
+ export const startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/;
8
+ export const endCommentRegex = /^\s*\/ko\s*$/;
9
+ const htmlTagsWithOptionallyClosingChildren = { ul: true, ol: true };
11
10
  export function isStartComment(node) {
12
- return node.nodeType == 8 && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
11
+ return node.nodeType === Node.COMMENT_NODE && startCommentRegex.test(node.nodeValue);
13
12
  }
14
13
  export function isEndComment(node) {
15
- return node.nodeType == 8 && endCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);
14
+ return node.nodeType === Node.COMMENT_NODE && endCommentRegex.test(node.nodeValue);
16
15
  }
17
16
  function isUnmatchedEndComment(node) {
18
17
  return isEndComment(node) && !domData.get(node, matchedEndCommentDataKey);
19
18
  }
20
19
  const matchedEndCommentDataKey = "__ko_matchedEndComment__";
21
20
  export function getVirtualChildren(startComment, allowUnbalanced) {
22
- var currentNode = startComment;
23
- var depth = 1;
24
- var children = [];
21
+ let currentNode = startComment;
22
+ let depth = 1;
23
+ const children = new Array();
25
24
  while (currentNode = currentNode.nextSibling) {
26
25
  if (isEndComment(currentNode)) {
27
26
  domData.set(currentNode, matchedEndCommentDataKey, true);
@@ -41,7 +40,7 @@ export function getVirtualChildren(startComment, allowUnbalanced) {
41
40
  return null;
42
41
  }
43
42
  function getMatchingEndComment(startComment, allowUnbalanced) {
44
- var allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);
43
+ const allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);
45
44
  if (allVirtualChildren) {
46
45
  if (allVirtualChildren.length > 0) {
47
46
  return allVirtualChildren[allVirtualChildren.length - 1].nextSibling;
@@ -52,13 +51,17 @@ function getMatchingEndComment(startComment, allowUnbalanced) {
52
51
  }
53
52
  }
54
53
  function getUnbalancedChildTags(node) {
55
- var childNode = node.firstChild, captureRemaining = null;
54
+ let childNode = node.firstChild, captureRemaining = null;
56
55
  if (childNode) {
57
56
  do {
58
57
  if (captureRemaining) {
59
58
  captureRemaining.push(childNode);
60
59
  } else if (isStartComment(childNode)) {
61
- var matchingEndComment = getMatchingEndComment(childNode, true);
60
+ const matchingEndComment = getMatchingEndComment(
61
+ childNode,
62
+ /* allowUnbalanced: */
63
+ true
64
+ );
62
65
  if (matchingEndComment) {
63
66
  childNode = matchingEndComment;
64
67
  } else {
@@ -71,8 +74,8 @@ function getUnbalancedChildTags(node) {
71
74
  }
72
75
  return captureRemaining;
73
76
  }
74
- export var allowedBindings = {};
75
- export var hasBindingValue = isStartComment;
77
+ export const allowedBindings = /* @__PURE__ */ Object.create(null);
78
+ export const hasBindingValue = isStartComment;
76
79
  export function childNodes(node) {
77
80
  return isStartComment(node) ? getVirtualChildren(node) : node.childNodes;
78
81
  }
@@ -80,8 +83,8 @@ export function emptyNode(node) {
80
83
  if (!isStartComment(node)) {
81
84
  emptyDomNode(node);
82
85
  } else {
83
- var virtualChildren = childNodes(node);
84
- for (var i = 0, j = virtualChildren.length; i < j; i++) {
86
+ const virtualChildren = childNodes(node);
87
+ for (let i = 0, j = virtualChildren.length; i < j; i++) {
85
88
  removeNode(virtualChildren[i]);
86
89
  }
87
90
  }
@@ -92,9 +95,11 @@ export function setDomNodeChildren(node, childNodes2) {
92
95
  } else {
93
96
  emptyNode(node);
94
97
  const endCommentNode = node.nextSibling;
95
- const parentNode = endCommentNode.parentNode;
96
- for (var i = 0, j = childNodes2.length; i < j; ++i) {
97
- parentNode.insertBefore(childNodes2[i], endCommentNode);
98
+ if (endCommentNode && endCommentNode.parentNode) {
99
+ const parentNode = endCommentNode.parentNode;
100
+ for (let i = 0, j = childNodes2.length; i < j; ++i) {
101
+ parentNode.insertBefore(childNodes2[i], endCommentNode);
102
+ }
98
103
  }
99
104
  }
100
105
  }
@@ -106,7 +111,7 @@ export function prepend(containerNode, nodeToPrepend) {
106
111
  containerNode.appendChild(nodeToPrepend);
107
112
  }
108
113
  } else {
109
- containerNode.parentNode.insertBefore(nodeToPrepend, containerNode.nextSibling);
114
+ containerNode.parentNode?.insertBefore(nodeToPrepend, containerNode.nextSibling);
110
115
  }
111
116
  }
112
117
  export function insertAfter(containerNode, nodeToInsert, insertAfterNode) {
@@ -119,7 +124,7 @@ export function insertAfter(containerNode, nodeToInsert, insertAfterNode) {
119
124
  containerNode.appendChild(nodeToInsert);
120
125
  }
121
126
  } else {
122
- containerNode.parentNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
127
+ containerNode.parentNode?.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
123
128
  }
124
129
  }
125
130
  export function firstChild(node) {
@@ -136,6 +141,7 @@ export function firstChild(node) {
136
141
  }
137
142
  export function lastChild(node) {
138
143
  let nextChild = firstChild(node);
144
+ if (!nextChild) return null;
139
145
  let lastChildNode;
140
146
  do {
141
147
  lastChildNode = nextChild;
@@ -148,7 +154,9 @@ export function nextSibling(node) {
148
154
  }
149
155
  if (node.nextSibling && isEndComment(node.nextSibling)) {
150
156
  if (isUnmatchedEndComment(node.nextSibling)) {
151
- throw Error("Found end comment without a matching opening comment, as next sibling of " + node.outerHTML);
157
+ throw Error(
158
+ "Found end comment without a matching opening comment, as next sibling of " + node.outerHTML
159
+ );
152
160
  }
153
161
  return null;
154
162
  } else {
@@ -156,9 +164,9 @@ export function nextSibling(node) {
156
164
  }
157
165
  }
158
166
  export function previousSibling(node) {
159
- var depth = 0;
167
+ let depth = 0;
160
168
  do {
161
- if (node.nodeType === 8) {
169
+ if (node.nodeType === Node.COMMENT_NODE) {
162
170
  if (isStartComment(node)) {
163
171
  if (--depth === 0) {
164
172
  return node;
@@ -174,21 +182,21 @@ export function previousSibling(node) {
174
182
  } while (node = node.previousSibling);
175
183
  }
176
184
  export function virtualNodeBindingValue(node) {
177
- var regexMatch = (commentNodesHaveTextProperty ? node.text : node.nodeValue).match(startCommentRegex);
185
+ const regexMatch = node.nodeValue.match(startCommentRegex);
178
186
  return regexMatch ? regexMatch[1] : null;
179
187
  }
180
188
  export function normaliseVirtualElementDomStructure(elementVerified) {
181
189
  if (!htmlTagsWithOptionallyClosingChildren[tagNameLower(elementVerified)]) {
182
190
  return;
183
191
  }
184
- var childNode = elementVerified.firstChild;
192
+ let childNode = elementVerified.firstChild;
185
193
  if (childNode) {
186
194
  do {
187
- if (childNode.nodeType === 1) {
188
- var unbalancedTags = getUnbalancedChildTags(childNode);
195
+ if (childNode.nodeType === Node.ELEMENT_NODE) {
196
+ const unbalancedTags = getUnbalancedChildTags(childNode);
189
197
  if (unbalancedTags) {
190
- var nodeToInsertBefore = childNode.nextSibling;
191
- for (var i = 0; i < unbalancedTags.length; i++) {
198
+ const nodeToInsertBefore = childNode.nextSibling;
199
+ for (let i = 0; i < unbalancedTags.length; i++) {
192
200
  if (nodeToInsertBefore) {
193
201
  elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore);
194
202
  } else {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/dom/virtualElements.ts"],
4
- "sourcesContent": ["/* eslint no-cond-assign: 0 */\n//\n// Virtual Elements\n//\n//\n// \"Virtual elements\" is an abstraction on top of the usual DOM API which understands the notion that comment nodes\n// may be used to represent hierarchy (in addition to the DOM's natural hierarchy).\n// If you call the DOM-manipulating functions on ko.virtualElements, you will be able to read and write the state\n// of that virtual hierarchy\n//\n// The point of all this is to support containerless templates (e.g., <!-- ko foreach:someCollection -->blah<!-- /ko -->)\n// without having to scatter special cases all over the binding and templating code.\n\n// IE 9 cannot reliably read the \"nodeValue\" property of a comment node (see https://github.com/SteveSanderson/knockout/issues/186)\n// but it does give them a nonstandard alternative property called \"text\" that it can read reliably. Other browsers don't have that property.\n// So, use node.text where available, and node.nodeValue elsewhere\nimport { emptyDomNode, setDomNodeChildren as setRegularDomNodeChildren } from './manipulation'\nimport { removeNode } from './disposal'\nimport { tagNameLower } from './info'\nimport * as domData from './data'\nimport options from '../options'\n\nvar commentNodesHaveTextProperty = options.document && options.document.createComment('test').text === '<!--test-->'\n\nexport var startCommentRegex = commentNodesHaveTextProperty ? /^<!--\\s*ko(?:\\s+([\\s\\S]+))?\\s*-->$/ : /^\\s*ko(?:\\s+([\\s\\S]+))?\\s*$/\nexport var endCommentRegex = commentNodesHaveTextProperty ? /^<!--\\s*\\/ko\\s*-->$/ : /^\\s*\\/ko\\s*$/\nvar htmlTagsWithOptionallyClosingChildren = { 'ul': true, 'ol': true }\n\nexport function isStartComment (node) {\n return (node.nodeType == 8) && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue)\n}\n\nexport function isEndComment (node) {\n return (node.nodeType == 8) && endCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue)\n}\n\nfunction isUnmatchedEndComment (node) {\n return isEndComment(node) && !domData.get(node, matchedEndCommentDataKey)\n}\n\nconst matchedEndCommentDataKey = '__ko_matchedEndComment__'\n\nexport function getVirtualChildren (startComment, allowUnbalanced) {\n var currentNode = startComment\n var depth = 1\n var children = []\n while (currentNode = currentNode.nextSibling) {\n if (isEndComment(currentNode)) {\n domData.set(currentNode, matchedEndCommentDataKey, true)\n depth--\n if (depth === 0) { return children }\n }\n\n children.push(currentNode)\n\n if (isStartComment(currentNode)) { depth++ }\n }\n if (!allowUnbalanced) { throw new Error('Cannot find closing comment tag to match: ' + startComment.nodeValue) }\n return null\n}\n\nfunction getMatchingEndComment (startComment, allowUnbalanced) {\n var allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced)\n if (allVirtualChildren) {\n if (allVirtualChildren.length > 0) { return allVirtualChildren[allVirtualChildren.length - 1].nextSibling }\n return startComment.nextSibling\n } else { return null } // Must have no matching end comment, and allowUnbalanced is true\n}\n\nfunction getUnbalancedChildTags (node) {\n // e.g., from <div>OK</div><!-- ko blah --><span>Another</span>, returns: <!-- ko blah --><span>Another</span>\n // from <div>OK</div><!-- /ko --><!-- /ko -->, returns: <!-- /ko --><!-- /ko -->\n var childNode = node.firstChild, captureRemaining = null\n if (childNode) {\n do {\n if (captureRemaining) // We already hit an unbalanced node and are now just scooping up all subsequent nodes\n { captureRemaining.push(childNode) } else if (isStartComment(childNode)) {\n var matchingEndComment = getMatchingEndComment(childNode, /* allowUnbalanced: */ true)\n if (matchingEndComment) // It's a balanced tag, so skip immediately to the end of this virtual set\n { childNode = matchingEndComment } else { captureRemaining = [childNode] } // It's unbalanced, so start capturing from this point\n } else if (isEndComment(childNode)) {\n captureRemaining = [childNode] // It's unbalanced (if it wasn't, we'd have skipped over it already), so start capturing\n }\n } while (childNode = childNode.nextSibling)\n }\n return captureRemaining\n}\n\nexport var allowedBindings = {}\nexport var hasBindingValue = isStartComment\n\nexport function childNodes (node) {\n return isStartComment(node) ? getVirtualChildren(node) : node.childNodes\n}\n\nexport function emptyNode (node) {\n if (!isStartComment(node)) { emptyDomNode(node) } else {\n var virtualChildren = childNodes(node)\n for (var i = 0, j = virtualChildren.length; i < j; i++) { removeNode(virtualChildren[i]) }\n }\n}\n\nexport function setDomNodeChildren (node, childNodes) {\n if (!isStartComment(node)) { setRegularDomNodeChildren(node, childNodes) } else {\n emptyNode(node)\n const endCommentNode = node.nextSibling // Must be the next sibling, as we just emptied the children\n const parentNode = endCommentNode.parentNode\n for (var i = 0, j = childNodes.length; i < j; ++i) {\n parentNode.insertBefore(childNodes[i], endCommentNode)\n }\n }\n}\n\nexport function prepend (containerNode, nodeToPrepend) {\n if (!isStartComment(containerNode)) {\n if (containerNode.firstChild) { containerNode.insertBefore(nodeToPrepend, containerNode.firstChild) } else { containerNode.appendChild(nodeToPrepend) }\n } else {\n // Start comments must always have a parent and at least one following sibling (the end comment)\n containerNode.parentNode.insertBefore(nodeToPrepend, containerNode.nextSibling)\n }\n}\n\nexport function insertAfter (containerNode, nodeToInsert, insertAfterNode) {\n if (!insertAfterNode) {\n prepend(containerNode, nodeToInsert)\n } else if (!isStartComment(containerNode)) {\n // Insert after insertion point\n if (insertAfterNode.nextSibling) { containerNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling) } else { containerNode.appendChild(nodeToInsert) }\n } else {\n // Children of start comments must always have a parent and at least one following sibling (the end comment)\n containerNode.parentNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling)\n }\n}\n\nexport function firstChild (node) {\n if (!isStartComment(node)) {\n if (node.firstChild && isEndComment(node.firstChild)) {\n throw new Error('Found invalid end comment, as the first child of ' + node.outerHTML)\n }\n return node.firstChild\n }\n if (!node.nextSibling || isEndComment(node.nextSibling)) {\n return null\n }\n return node.nextSibling\n}\n\nexport function lastChild (node) {\n let nextChild = firstChild(node)\n let lastChildNode\n\n do {\n lastChildNode = nextChild\n } while (nextChild = nextSibling(nextChild))\n\n return lastChildNode\n}\n\nexport function nextSibling (node) {\n if (isStartComment(node)) {\n node = getMatchingEndComment(node)\n }\n\n if (node.nextSibling && isEndComment(node.nextSibling)) {\n if (isUnmatchedEndComment(node.nextSibling)) {\n throw Error('Found end comment without a matching opening comment, as next sibling of ' + node.outerHTML)\n }\n return null\n } else {\n return node.nextSibling\n }\n}\n\nexport function previousSibling (node) {\n var depth = 0\n do {\n if (node.nodeType === 8) {\n if (isStartComment(node)) {\n if (--depth === 0) {\n return node\n }\n } else if (isEndComment(node)) {\n depth++\n }\n } else {\n if (depth === 0) { return node }\n }\n } while (node = node.previousSibling)\n}\n\nexport function virtualNodeBindingValue (node) {\n var regexMatch = (commentNodesHaveTextProperty ? node.text : node.nodeValue).match(startCommentRegex)\n return regexMatch ? regexMatch[1] : null\n}\n\nexport function normaliseVirtualElementDomStructure (elementVerified) {\n // Workaround for https://github.com/SteveSanderson/knockout/issues/155\n // (IE <= 8 or IE 9 quirks mode parses your HTML weirdly, treating closing </li> tags as if they don't exist, thereby moving comment nodes\n // that are direct descendants of <ul> into the preceding <li>)\n if (!htmlTagsWithOptionallyClosingChildren[tagNameLower(elementVerified)]) { return }\n\n // Scan immediate children to see if they contain unbalanced comment tags. If they do, those comment tags\n // must be intended to appear *after* that child, so move them there.\n var childNode = elementVerified.firstChild\n if (childNode) {\n do {\n if (childNode.nodeType === 1) {\n var unbalancedTags = getUnbalancedChildTags(childNode)\n if (unbalancedTags) {\n // Fix up the DOM by moving the unbalanced tags to where they most likely were intended to be placed - *after* the child\n var nodeToInsertBefore = childNode.nextSibling\n for (var i = 0; i < unbalancedTags.length; i++) {\n if (nodeToInsertBefore) { elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore) } else { elementVerified.appendChild(unbalancedTags[i]) }\n }\n }\n }\n } while (childNode = childNode.nextSibling)\n }\n}\n"],
5
- "mappings": ";AAgBA;AACA;AACA;AACA;AACA;AAEA,IAAI,+BAA+B,QAAQ,YAAY,QAAQ,SAAS,cAAc,MAAM,EAAE,SAAS;AAEhG,WAAI,oBAAoB,+BAA+B,uCAAuC;AAC9F,WAAI,kBAAkB,+BAA+B,wBAAwB;AACpF,IAAI,wCAAwC,EAAE,MAAM,MAAM,MAAM,KAAK;AAE9D,+BAAyB,MAAM;AACpC,SAAQ,KAAK,YAAY,KAAM,kBAAkB,KAAK,+BAA+B,KAAK,OAAO,KAAK,SAAS;AACjH;AAEO,6BAAuB,MAAM;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B,KAAK,OAAO,KAAK,WAAW,MAAM,iBAAiB;AACpG,SAAO,aAAa,WAAW,KAAK;AACtC;AAEO,oDAA8C,iBAAiB;AAIpE,MAAI,CAAC,sCAAsC,aAAa,eAAe,IAAI;AAAE;AAAA,EAAO;AAIpF,MAAI,YAAY,gBAAgB;AAChC,MAAI,WAAW;AACb,OAAG;AACD,UAAI,UAAU,aAAa,GAAG;AAC5B,YAAI,iBAAiB,uBAAuB,SAAS;AACrD,YAAI,gBAAgB;AAElB,cAAI,qBAAqB,UAAU;AACnC,mBAAS,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;AAC9C,gBAAI,oBAAoB;AAAE,8BAAgB,aAAa,eAAe,IAAI,kBAAkB;AAAA,YAAE,OAAO;AAAE,8BAAgB,YAAY,eAAe,EAAE;AAAA,YAAE;AAAA,UACxJ;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,YAAY,UAAU;AAAA,EACjC;AACF;",
6
- "names": []
4
+ "sourcesContent": ["/* eslint no-cond-assign: 0 */\n//\n// Virtual Elements\n//\n//\n// \"Virtual elements\" is an abstraction on top of the usual DOM API which understands the notion that comment nodes\n// may be used to represent hierarchy (in addition to the DOM's natural hierarchy).\n// If you call the DOM-manipulating functions on ko.virtualElements, you will be able to read and write the state\n// of that virtual hierarchy\n//\n// The point of all this is to support containerless templates (e.g., <!-- ko foreach:someCollection -->blah<!-- /ko -->)\n// without having to scatter special cases all over the binding and templating code.\n\nimport { emptyDomNode, setDomNodeChildren as setRegularDomNodeChildren } from './manipulation'\nimport { removeNode } from './disposal'\nimport { tagNameLower } from './info'\nimport * as domData from './data'\nimport options from '../options'\n\nexport const startCommentRegex = /^\\s*ko(?:\\s+([\\s\\S]+))?\\s*$/\nexport const endCommentRegex = /^\\s*\\/ko\\s*$/\nconst htmlTagsWithOptionallyClosingChildren = { ul: true, ol: true }\n\nexport function isStartComment(node) {\n return node.nodeType === Node.COMMENT_NODE && startCommentRegex.test(node.nodeValue)\n}\n\nexport function isEndComment(node) {\n return node.nodeType === Node.COMMENT_NODE && endCommentRegex.test(node.nodeValue)\n}\n\nfunction isUnmatchedEndComment(node) {\n return isEndComment(node) && !domData.get(node, matchedEndCommentDataKey)\n}\n\nconst matchedEndCommentDataKey = '__ko_matchedEndComment__'\n\nexport function getVirtualChildren(startComment, allowUnbalanced?) {\n let currentNode = startComment\n let depth = 1\n const children = new Array()\n while ((currentNode = currentNode.nextSibling)) {\n if (isEndComment(currentNode)) {\n domData.set(currentNode, matchedEndCommentDataKey, true)\n depth--\n if (depth === 0) {\n return children\n }\n }\n\n children.push(currentNode)\n\n if (isStartComment(currentNode)) {\n depth++\n }\n }\n if (!allowUnbalanced) {\n throw new Error('Cannot find closing comment tag to match: ' + startComment.nodeValue)\n }\n return null\n}\n\nfunction getMatchingEndComment(startComment, allowUnbalanced?) {\n const allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced)\n if (allVirtualChildren) {\n if (allVirtualChildren.length > 0) {\n return allVirtualChildren[allVirtualChildren.length - 1].nextSibling\n }\n return startComment.nextSibling\n } else {\n return null\n } // Must have no matching end comment, and allowUnbalanced is true\n}\n\nfunction getUnbalancedChildTags(node) {\n // e.g., from <div>OK</div><!-- ko blah --><span>Another</span>, returns: <!-- ko blah --><span>Another</span>\n // from <div>OK</div><!-- /ko --><!-- /ko -->, returns: <!-- /ko --><!-- /ko -->\n let childNode = node.firstChild,\n captureRemaining: any = null\n if (childNode) {\n do {\n if (captureRemaining) // We already hit an unbalanced node and are now just scooping up all subsequent nodes\n {\n captureRemaining.push(childNode)\n } else if (isStartComment(childNode)) {\n const matchingEndComment = getMatchingEndComment(childNode, /* allowUnbalanced: */ true)\n if (matchingEndComment) // It's a balanced tag, so skip immediately to the end of this virtual set\n {\n childNode = matchingEndComment\n } else {\n captureRemaining = [childNode]\n } // It's unbalanced, so start capturing from this point\n } else if (isEndComment(childNode)) {\n captureRemaining = [childNode] // It's unbalanced (if it wasn't, we'd have skipped over it already), so start capturing\n }\n } while ((childNode = childNode.nextSibling))\n }\n return captureRemaining\n}\n\nexport interface VirtualElementsAllowedBindings {\n text: boolean\n foreach: boolean\n if: boolean\n ifnot: boolean\n with: boolean\n let: boolean\n using: boolean\n template: boolean\n component: boolean\n}\n\nexport const allowedBindings: VirtualElementsAllowedBindings = Object.create(null)\nexport const hasBindingValue = isStartComment\n\nexport function childNodes(node: Node): any {\n return isStartComment(node) ? getVirtualChildren(node) : node.childNodes\n}\n\nexport function emptyNode(node: Node) {\n if (!isStartComment(node)) {\n emptyDomNode(node)\n } else {\n const virtualChildren = childNodes(node)\n for (let i = 0, j = virtualChildren.length; i < j; i++) {\n removeNode(virtualChildren[i])\n }\n }\n}\n\nexport function setDomNodeChildren(node: Node, childNodes: Node[]) {\n if (!isStartComment(node)) {\n setRegularDomNodeChildren(node, childNodes)\n } else {\n emptyNode(node)\n const endCommentNode = node.nextSibling // Must be the next sibling, as we just emptied the children\n if (endCommentNode && endCommentNode.parentNode) {\n const parentNode = endCommentNode.parentNode\n for (let i = 0, j = childNodes.length; i < j; ++i) {\n parentNode.insertBefore(childNodes[i], endCommentNode)\n }\n }\n }\n}\n\nexport function prepend(containerNode: Node, nodeToPrepend: Node) {\n if (!isStartComment(containerNode)) {\n if (containerNode.firstChild) {\n containerNode.insertBefore(nodeToPrepend, containerNode.firstChild)\n } else {\n containerNode.appendChild(nodeToPrepend)\n }\n } else {\n // Start comments must always have a parent and at least one following sibling (the end comment)\n containerNode.parentNode?.insertBefore(nodeToPrepend, containerNode.nextSibling)\n }\n}\n\nexport function insertAfter(containerNode: Node, nodeToInsert: Node, insertAfterNode: Node) {\n if (!insertAfterNode) {\n prepend(containerNode, nodeToInsert)\n } else if (!isStartComment(containerNode)) {\n // Insert after insertion point\n if (insertAfterNode.nextSibling) {\n containerNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling)\n } else {\n containerNode.appendChild(nodeToInsert)\n }\n } else {\n // Children of start comments must always have a parent and at least one following sibling (the end comment)\n containerNode.parentNode?.insertBefore(nodeToInsert, insertAfterNode.nextSibling)\n }\n}\n\nexport function firstChild(node: Node) {\n if (!isStartComment(node)) {\n if (node.firstChild && isEndComment(node.firstChild)) {\n throw new Error('Found invalid end comment, as the first child of ' + (node as Element).outerHTML)\n }\n return node.firstChild\n }\n if (!node.nextSibling || isEndComment(node.nextSibling)) {\n return null\n }\n return node.nextSibling\n}\n\nexport function lastChild(node: Node) {\n let nextChild = firstChild(node)\n if (!nextChild) return null\n\n let lastChildNode\n\n do {\n lastChildNode = nextChild\n } while ((nextChild = nextSibling(nextChild)))\n\n return lastChildNode\n}\n\nexport function nextSibling(node: Node) {\n if (isStartComment(node)) {\n node = getMatchingEndComment(node)\n }\n\n if (node.nextSibling && isEndComment(node.nextSibling)) {\n if (isUnmatchedEndComment(node.nextSibling)) {\n throw Error(\n 'Found end comment without a matching opening comment, as next sibling of ' + (node as Element).outerHTML\n )\n }\n return null\n } else {\n return node.nextSibling\n }\n}\n\nexport function previousSibling(node) {\n let depth = 0\n do {\n if (node.nodeType === Node.COMMENT_NODE) {\n if (isStartComment(node)) {\n if (--depth === 0) {\n return node\n }\n } else if (isEndComment(node)) {\n depth++\n }\n } else {\n if (depth === 0) {\n return node\n }\n }\n } while ((node = node.previousSibling))\n}\n\nexport function virtualNodeBindingValue(node): string | null {\n const regexMatch = node.nodeValue.match(startCommentRegex) as RegExpMatchArray\n return regexMatch ? regexMatch[1] : null\n}\n\nexport function normaliseVirtualElementDomStructure(elementVerified) {\n // Workaround for https://github.com/SteveSanderson/knockout/issues/155\n // (IE <= 8 or IE 9 quirks mode parses your HTML weirdly, treating closing </li> tags as if they don't exist, thereby moving comment nodes\n // that are direct descendants of <ul> into the preceding <li>)\n if (!htmlTagsWithOptionallyClosingChildren[tagNameLower(elementVerified)]) {\n return\n }\n\n // Scan immediate children to see if they contain unbalanced comment tags. If they do, those comment tags\n // must be intended to appear *after* that child, so move them there.\n let childNode = elementVerified.firstChild\n if (childNode) {\n do {\n if (childNode.nodeType === Node.ELEMENT_NODE) {\n const unbalancedTags = getUnbalancedChildTags(childNode)\n if (unbalancedTags) {\n // Fix up the DOM by moving the unbalanced tags to where they most likely were intended to be placed - *after* the child\n const nodeToInsertBefore = childNode.nextSibling\n for (let i = 0; i < unbalancedTags.length; i++) {\n if (nodeToInsertBefore) {\n elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore)\n } else {\n elementVerified.appendChild(unbalancedTags[i])\n }\n }\n }\n }\n } while ((childNode = childNode.nextSibling))\n }\n}\n"],
5
+ "mappings": ";;AAaA,SAAS,cAAc,sBAAsB,iCAAiC;AAC9E,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,YAAY,aAAa;AAGlB,aAAM,oBAAoB;AAC1B,aAAM,kBAAkB;AAC/B,MAAM,wCAAwC,EAAE,IAAI,MAAM,IAAI,KAAK;AAE5D,gBAAS,eAAe,MAAM;AACnC,SAAO,KAAK,aAAa,KAAK,gBAAgB,kBAAkB,KAAK,KAAK,SAAS;AACrF;AAEO,gBAAS,aAAa,MAAM;AACjC,SAAO,KAAK,aAAa,KAAK,gBAAgB,gBAAgB,KAAK,KAAK,SAAS;AACnF;AAEA,SAAS,sBAAsB,MAAM;AACnC,SAAO,aAAa,IAAI,KAAK,CAAC,QAAQ,IAAI,MAAM,wBAAwB;AAC1E;AAEA,MAAM,2BAA2B;AAE1B,gBAAS,mBAAmB,cAAc,iBAAkB;AACjE,MAAI,cAAc;AAClB,MAAI,QAAQ;AACZ,QAAM,WAAW,IAAI,MAAM;AAC3B,SAAQ,cAAc,YAAY,aAAc;AAC9C,QAAI,aAAa,WAAW,GAAG;AAC7B,cAAQ,IAAI,aAAa,0BAA0B,IAAI;AACvD;AACA,UAAI,UAAU,GAAG;AACf,eAAO;AAAA,MACT;AAAA,IACF;AAEA,aAAS,KAAK,WAAW;AAEzB,QAAI,eAAe,WAAW,GAAG;AAC/B;AAAA,IACF;AAAA,EACF;AACA,MAAI,CAAC,iBAAiB;AACpB,UAAM,IAA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Q,KAAK;AAC9C,gBAAI,oBAAoB;AACtB,8BAAgB,aAAa,eAAe,CAAC,GAAG,kBAAkB;AAAA,YACpE,OAAO;AACL,8BAAgB,YAAY,eAAe,CAAC,CAAC;AAAA,YAC/C;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAU,YAAY,UAAU;AAAA,EAClC;AACF;",
6
+ "names": ["childNodes"]
7
7
  }
package/dist/error.js CHANGED
@@ -1,4 +1,5 @@
1
- // @tko/utils 🥊 4.0.0-beta1.0 ESM
1
+ // @tko/utils 🥊 4.0.0 ESM
2
+ "use strict";
2
3
  import options from "./options";
3
4
  export function catchFunctionErrors(delegate) {
4
5
  if (!options.onError) {
package/dist/error.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/error.ts"],
4
- "sourcesContent": ["//\n// Error handling\n// ---\n//\n// The default onError handler is to re-throw.\nimport options from './options'\n\nexport function catchFunctionErrors (delegate) {\n if (!options.onError) { return delegate }\n return (...args) => {\n try {\n return delegate(...args)\n } catch (err) {\n options.onError(err)\n }\n }\n}\n\nexport function deferError (error) {\n safeSetTimeout(function () { throw error }, 0)\n}\n\nexport function safeSetTimeout (handler, timeout) {\n return setTimeout(catchFunctionErrors(handler), timeout)\n}\n"],
5
- "mappings": ";AAKA;AAEO,oCAA8B,UAAU;AAC7C,MAAI,CAAC,QAAQ,SAAS;AAAE,WAAO;AAAA,EAAS;AACxC,SAAO,IAAI,SAAS;AAClB,QAAI;AACF,aAAO,SAAS,GAAG,IAAI;AAAA,IACzB,SAAS,KAAP;AACA,cAAQ,QAAQ,GAAG;AAAA,IACrB;AAAA,EACF;AACF;AAEO,2BAAqB,OAAO;AACjC,iBAAe,WAAY;AAAE,UAAM;AAAA,EAAM,GAAG,CAAC;AAC/C;AAEO,+BAAyB,SAAS,SAAS;AAChD,SAAO,WAAW,oBAAoB,OAAO,GAAG,OAAO;AACzD;",
4
+ "sourcesContent": ["//\n// Error handling\n// ---\n//\n// The default onError handler is to re-throw.\nimport options from './options'\n\nexport function catchFunctionErrors(delegate) {\n if (!options.onError) {\n return delegate\n }\n return (...args) => {\n try {\n return delegate(...args)\n } catch (err) {\n options.onError(err)\n }\n }\n}\n\nexport function deferError(error) {\n safeSetTimeout(function () {\n throw error\n }, 0)\n}\n\nexport function safeSetTimeout(handler, timeout: number) {\n return setTimeout(catchFunctionErrors(handler), timeout)\n}\n"],
5
+ "mappings": ";;AAKA,OAAO,aAAa;AAEb,gBAAS,oBAAoB,UAAU;AAC5C,MAAI,CAAC,QAAQ,SAAS;AACpB,WAAO;AAAA,EACT;AACA,SAAO,IAAI,SAAS;AAClB,QAAI;AACF,aAAO,SAAS,GAAG,IAAI;AAAA,IACzB,SAAS,KAAK;AACZ,cAAQ,QAAQ,GAAG;AAAA,IACrB;AAAA,EACF;AACF;AAEO,gBAAS,WAAW,OAAO;AAChC,iBAAe,WAAY;AACzB,UAAM;AAAA,EACR,GAAG,CAAC;AACN;AAEO,gBAAS,eAAe,SAAS,SAAiB;AACvD,SAAO,WAAW,oBAAoB,OAAO,GAAG,OAAO;AACzD;",
6
6
  "names": []
7
7
  }
package/dist/function.js CHANGED
@@ -1,4 +1,5 @@
1
- // @tko/utils 🥊 4.0.0-beta1.0 ESM
1
+ // @tko/utils 🥊 4.0.0 ESM
2
+ "use strict";
2
3
  function testOverwrite() {
3
4
  try {
4
5
  Object.defineProperty(function x() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/function.ts"],
4
- "sourcesContent": ["\nfunction testOverwrite () {\n try {\n Object.defineProperty(function x () {}, 'length', {})\n return true\n } catch (e) {\n return false\n }\n}\n\nexport const functionSupportsLengthOverwrite = testOverwrite()\n\nexport function overwriteLengthPropertyIfSupported (fn, descriptor) {\n if (functionSupportsLengthOverwrite) {\n Object.defineProperty(fn, 'length', descriptor)\n }\n}\n"],
5
- "mappings": ";AACA,yBAA0B;AACxB,MAAI;AACF,WAAO,eAAe,aAAc;AAAA,IAAC,GAAG,UAAU,CAAC,CAAC;AACpD,WAAO;AAAA,EACT,SAAS,GAAP;AACA,WAAO;AAAA,EACT;AACF;AAEO,aAAM,kCAAkC,cAAc;AAEtD,mDAA6C,IAAI,YAAY;AAClE,MAAI,iCAAiC;AACnC,WAAO,eAAe,IAAI,UAAU,UAAU;AAAA,EAChD;AACF;",
4
+ "sourcesContent": ["function testOverwrite() {\n try {\n Object.defineProperty(function x() {}, 'length', {})\n return true\n } catch (e) {\n return false\n }\n}\n\nexport const functionSupportsLengthOverwrite = testOverwrite()\n\nexport function overwriteLengthPropertyIfSupported(fn, descriptor) {\n if (functionSupportsLengthOverwrite) {\n Object.defineProperty(fn, 'length', descriptor)\n }\n}\n"],
5
+ "mappings": ";;AAAA,SAAS,gBAAgB;AACvB,MAAI;AACF,WAAO,eAAe,SAAS,IAAI;AAAA,IAAC,GAAG,UAAU,CAAC,CAAC;AACnD,WAAO;AAAA,EACT,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;AAEO,aAAM,kCAAkC,cAAc;AAEtD,gBAAS,mCAAmC,IAAI,YAAY;AACjE,MAAI,iCAAiC;AACnC,WAAO,eAAe,IAAI,UAAU,UAAU;AAAA,EAChD;AACF;",
6
6
  "names": []
7
7
  }