@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.
- package/dist/array.js +39 -35
- package/dist/array.js.map +2 -2
- package/dist/async.js +4 -3
- package/dist/async.js.map +2 -2
- package/dist/css.js +5 -4
- package/dist/css.js.map +2 -2
- package/dist/dom/data.js +36 -46
- package/dist/dom/data.js.map +2 -2
- package/dist/dom/disposal.js +23 -16
- package/dist/dom/disposal.js.map +2 -2
- package/dist/dom/event.js +39 -41
- package/dist/dom/event.js.map +2 -2
- package/dist/dom/fixes.js +5 -24
- package/dist/dom/fixes.js.map +2 -2
- package/dist/dom/html.js +46 -61
- package/dist/dom/html.js.map +2 -2
- package/dist/dom/info.js +10 -8
- package/dist/dom/info.js.map +2 -2
- package/dist/dom/manipulation.js +16 -24
- package/dist/dom/manipulation.js.map +2 -2
- package/dist/dom/selectExtensions.js +33 -23
- package/dist/dom/selectExtensions.js.map +2 -2
- package/dist/dom/virtualElements.js +40 -32
- package/dist/dom/virtualElements.js.map +3 -3
- package/dist/error.js +2 -1
- package/dist/error.js.map +2 -2
- package/dist/function.js +2 -1
- package/dist/function.js.map +2 -2
- package/dist/index.cjs +446 -449
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +2 -3
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +2 -3
- package/dist/index.mjs.map +2 -2
- package/dist/memoization.js +18 -13
- package/dist/memoization.js.map +3 -3
- package/dist/object.js +10 -8
- package/dist/object.js.map +2 -2
- package/dist/options.js +97 -35
- package/dist/options.js.map +2 -2
- package/dist/string.js +3 -5
- package/dist/string.js.map +2 -2
- package/dist/symbol.js +3 -2
- package/dist/symbol.js.map +2 -2
- package/dist/tasks.js +10 -20
- package/dist/tasks.js.map +2 -2
- package/helpers/jasmine-13-helper.ts +198 -147
- package/package.json +2 -3
- package/LICENSE +0 -22
- package/dist/bind-shim.js +0 -18
- package/dist/bind-shim.js.map +0 -7
- package/dist/ie.js +0 -15
- package/dist/ie.js.map +0 -7
- package/dist/jquery.js +0 -6
- 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 {
|
|
5
|
-
"mappings": "
|
|
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
|
|
1
|
+
// @tko/utils 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
2
3
|
import { tagNameLower } from "./info";
|
|
3
4
|
import * as domData from "./data";
|
|
4
|
-
|
|
5
|
-
export
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
32
|
-
|
|
37
|
+
el[hasDomDataExpandoProperty] = true;
|
|
38
|
+
el.value = typeof value === "number" ? value : "";
|
|
33
39
|
}
|
|
34
40
|
break;
|
|
35
41
|
case "select":
|
|
36
|
-
|
|
37
|
-
value
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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": ["
|
|
5
|
-
"mappings": ";
|
|
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,iBAAiB,UAAU,cAAc,QAAQ,cAAc,aAAa,CAAC,IAC7E;AAAA,MACN;AAAA,MACA;AACE,eAAQ,QAA6B;AAAA,IACzC;AAAA,EACF;AAAA,EAEA,YAAY,SAAU,SAAsB,OAAa,YAAsB;AAC7E,YAAQ,aAAa,OAAO,GAAG;AAAA,MAC7B,KAAK;AACH,YAAI,OAAO,UAAU,UAAU;AAC7B,kBAAQ,IAAI,SAAS,iBAAiB,uBAAuB,MAAS;AACtE,cAAI,6BAA6B,SAAS;AAExC,mBAAO,QAAQ,yBAAyB;AAAA,UAC1C;AACA;AAAC,UAAC,QAA8B,QAAQ;AAAA,QAC1C,OAAO;AACL,gBAAM,KAAK;AAEX,kBAAQ,IAAI,SAAS,iBAAiB,uBAAuB,KAAK;AAClE,aAAG,yBAAyB,IAAI;AAEhC,aAAG,QAAQ,OAAO,UAAU,WAAW,QAAQ;AAAA,QACjD;AAEA;AAAA,MACF,KAAK;AACH;AACE,cAAI,UAAU,MAAM,UAAU,MAAM;AAElC,oBAAQ;AAAA,UACV;AACA,cAAI,YAAY;AAEhB,gBAAM,gBAAgB;AAEtB,mBAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,QAAQ,aAAa,IAAI,GAAG,EAAE,GAAG;AACzE,0BAAc,iBAAiB,UAAU,cAAc,QAAQ,CAAC,CAAC;AAGjE,kBAAM,cAAc,gBAAgB;AACpC,kBAAM,aAAa,gBAAgB,MAAM,UAAU;AACnD,kBAAM,eAAe,OAAO,UAAU,YAAY,OAAO,WAAW,MAAM;AAC1E,gBAAI,eAAe,cAAc,cAAc;AAC7C,0BAAY;AACZ;AAAA,YACF;AAAA,UACF;AACA,cAAI,cAAc,aAAa,KAAM,UAAU,UAAa,cAAc,OAAO,GAAI;AACnF,0BAAc,gBAAgB;AAAA,UAChC;AAAA,QACF;AACA;AAAA,MACF;AACE,YAAI,UAAU,QAAQ,UAAU,QAAW;AACzC,kBAAQ;AAAA,QACV;AACA;AAAC,QAAC,QAA6B,QAAQ;AACvC;AAAA,IACJ;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
// @tko/utils 🥊 4.0.0
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
11
|
+
return node.nodeType === Node.COMMENT_NODE && startCommentRegex.test(node.nodeValue);
|
|
13
12
|
}
|
|
14
13
|
export function isEndComment(node) {
|
|
15
|
-
return node.nodeType
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
75
|
-
export
|
|
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
|
-
|
|
84
|
-
for (
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
|
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
|
|
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(
|
|
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
|
-
|
|
167
|
+
let depth = 0;
|
|
160
168
|
do {
|
|
161
|
-
if (node.nodeType ===
|
|
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
|
-
|
|
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
|
-
|
|
192
|
+
let childNode = elementVerified.firstChild;
|
|
185
193
|
if (childNode) {
|
|
186
194
|
do {
|
|
187
|
-
if (childNode.nodeType ===
|
|
188
|
-
|
|
195
|
+
if (childNode.nodeType === Node.ELEMENT_NODE) {
|
|
196
|
+
const unbalancedTags = getUnbalancedChildTags(childNode);
|
|
189
197
|
if (unbalancedTags) {
|
|
190
|
-
|
|
191
|
-
for (
|
|
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\
|
|
5
|
-
"mappings": "
|
|
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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AAA,EAClC;AACF;",
|
|
6
|
+
"names": ["childNodes"]
|
|
7
7
|
}
|
package/dist/error.js
CHANGED
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
|
|
5
|
-
"mappings": "
|
|
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
package/dist/function.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/function.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
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
|
}
|