@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/attr.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "@tko/observable";
|
|
9
|
-
export var attr = {
|
|
10
|
-
update: function(element, valueAccessor, allBindings) {
|
|
11
|
-
var value = unwrap(valueAccessor()) || {};
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import { objectForEach } from "@tko/utils";
|
|
4
|
+
import { unwrap } from "@tko/observable";
|
|
5
|
+
export const attr = {
|
|
6
|
+
update: function(element, valueAccessor, _allBindings) {
|
|
7
|
+
const value = unwrap(valueAccessor()) || {};
|
|
12
8
|
objectForEach(value, function(attrName, attrValue) {
|
|
13
9
|
attrValue = unwrap(attrValue);
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const prefixLen = attrName.indexOf(":");
|
|
11
|
+
const namespace = prefixLen > 0 && element.lookupNamespaceURI(attrName.substr(0, prefixLen));
|
|
16
12
|
const toRemove = attrValue === false || attrValue === null || attrValue === void 0;
|
|
17
13
|
if (toRemove) {
|
|
18
14
|
if (namespace) {
|
|
@@ -29,7 +25,7 @@ export var attr = {
|
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
27
|
if (attrName === "name") {
|
|
32
|
-
|
|
28
|
+
element.name = toRemove ? "" : attrValue;
|
|
33
29
|
}
|
|
34
30
|
});
|
|
35
31
|
}
|
package/dist/attr.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/attr.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { objectForEach } from '@tko/utils'\n\nimport { unwrap } from '@tko/observable'\n\nimport type { AllBindings } from '@tko/bind'\n\nexport const attr = {\n update: function (element, valueAccessor, _allBindings: AllBindings) {\n const value = unwrap(valueAccessor()) || {}\n objectForEach(value, function (attrName, attrValue) {\n attrValue = unwrap(attrValue)\n\n // Find the namespace of this attribute, if any.\n const prefixLen = attrName.indexOf(':')\n const namespace = prefixLen > 0 && element.lookupNamespaceURI(attrName.substr(0, prefixLen))\n\n // To cover cases like \"attr: { checked:someProp }\", we want to remove the attribute entirely\n // when someProp is a \"no value\"-like value (strictly null, false, or undefined)\n // (because the absence of the \"checked\" attr is how to mark an element as not checked, etc.)\n const toRemove = attrValue === false || attrValue === null || attrValue === undefined\n\n if (toRemove) {\n if (namespace) {\n element.removeAttributeNS(namespace, attrName)\n } else {\n element.removeAttribute(attrName)\n }\n } else {\n attrValue = attrValue.toString()\n if (namespace) {\n element.setAttributeNS(namespace, attrName, attrValue)\n } else {\n element.setAttribute(attrName, attrValue)\n }\n }\n\n // Deliberately being case-sensitive here because XHTML would regard \"Name\" as a different thing\n // entirely, and there's no strong reason to allow for such casing in HTML.\n if (attrName === 'name') {\n element.name = toRemove ? '' : attrValue\n }\n })\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,qBAAqB;AAE9B,SAAS,cAAc;AAIhB,aAAM,OAAO;AAAA,EAClB,QAAQ,SAAU,SAAS,eAAe,cAA2B;AACnE,UAAM,QAAQ,OAAO,cAAc,CAAC,KAAK,CAAC;AAC1C,kBAAc,OAAO,SAAU,UAAU,WAAW;AAClD,kBAAY,OAAO,SAAS;AAG5B,YAAM,YAAY,SAAS,QAAQ,GAAG;AACtC,YAAM,YAAY,YAAY,KAAK,QAAQ,mBAAmB,SAAS,OAAO,GAAG,SAAS,CAAC;AAK3F,YAAM,WAAW,cAAc,SAAS,cAAc,QAAQ,cAAc;AAE5E,UAAI,UAAU;AACZ,YAAI,WAAW;AACb,kBAAQ,kBAAkB,WAAW,QAAQ;AAAA,QAC/C,OAAO;AACL,kBAAQ,gBAAgB,QAAQ;AAAA,QAClC;AAAA,MACF,OAAO;AACL,oBAAY,UAAU,SAAS;AAC/B,YAAI,WAAW;AACb,kBAAQ,eAAe,WAAW,UAAU,SAAS;AAAA,QACvD,OAAO;AACL,kBAAQ,aAAa,UAAU,SAAS;AAAA,QAC1C;AAAA,MACF;AAIA,UAAI,aAAa,QAAQ;AACvB,gBAAQ,OAAO,WAAW,KAAK;AAAA,MACjC;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/checked.js
CHANGED
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
unwrap,
|
|
9
|
-
dependencyDetection,
|
|
10
|
-
isWriteableObservable
|
|
11
|
-
} from "@tko/observable";
|
|
12
|
-
import {
|
|
13
|
-
computed,
|
|
14
|
-
pureComputed
|
|
15
|
-
} from "@tko/computed";
|
|
16
|
-
export var checked = {
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import { registerEventHandler, arrayIndexOf, addOrRemoveItem } from "@tko/utils";
|
|
4
|
+
import { unwrap, dependencyDetection, isWriteableObservable } from "@tko/observable";
|
|
5
|
+
import { computed, pureComputed } from "@tko/computed";
|
|
6
|
+
export const checked = {
|
|
17
7
|
after: ["value", "attr"],
|
|
18
8
|
init: function(element, valueAccessor, allBindings) {
|
|
19
|
-
|
|
9
|
+
const checkedValue2 = pureComputed(function() {
|
|
20
10
|
if (allBindings.has("checkedValue")) {
|
|
21
11
|
return unwrap(allBindings.get("checkedValue"));
|
|
22
12
|
} else if (useElementValue) {
|
|
@@ -28,16 +18,16 @@ export var checked = {
|
|
|
28
18
|
}
|
|
29
19
|
});
|
|
30
20
|
function updateModel() {
|
|
31
|
-
|
|
21
|
+
let isChecked = element.checked, elemValue = checkedValue2();
|
|
32
22
|
if (dependencyDetection.isInitial()) {
|
|
33
23
|
return;
|
|
34
24
|
}
|
|
35
25
|
if (!isChecked && (isRadio || dependencyDetection.getDependenciesCount())) {
|
|
36
26
|
return;
|
|
37
27
|
}
|
|
38
|
-
|
|
28
|
+
const modelValue = dependencyDetection.ignore(valueAccessor);
|
|
39
29
|
if (valueIsArray) {
|
|
40
|
-
|
|
30
|
+
const writableValue = rawValueIsNonArrayObservable ? modelValue.peek() : modelValue, saveOldValue = oldElemValue;
|
|
41
31
|
oldElemValue = elemValue;
|
|
42
32
|
if (saveOldValue !== elemValue) {
|
|
43
33
|
if (isChecked) {
|
|
@@ -59,13 +49,15 @@ export var checked = {
|
|
|
59
49
|
elemValue = void 0;
|
|
60
50
|
}
|
|
61
51
|
}
|
|
62
|
-
valueAccessor(elemValue, { onlyIfChanged: true });
|
|
52
|
+
const modelValue2 = valueAccessor(elemValue, { onlyIfChanged: true });
|
|
53
|
+
if (isWriteableObservable(modelValue2) && modelValue2.peek() !== elemValue) {
|
|
54
|
+
modelValue2(elemValue);
|
|
55
|
+
}
|
|
63
56
|
}
|
|
64
57
|
}
|
|
65
|
-
;
|
|
66
58
|
function updateView() {
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
const modelValue = unwrap(valueAccessor());
|
|
60
|
+
const elemValue = checkedValue2();
|
|
69
61
|
if (valueIsArray) {
|
|
70
62
|
element.checked = arrayIndexOf(modelValue, elemValue) >= 0;
|
|
71
63
|
oldElemValue = elemValue;
|
|
@@ -75,19 +67,18 @@ export var checked = {
|
|
|
75
67
|
element.checked = checkedValue2() === modelValue;
|
|
76
68
|
}
|
|
77
69
|
}
|
|
78
|
-
;
|
|
79
|
-
var isCheckbox = element.type == "checkbox", isRadio = element.type == "radio";
|
|
70
|
+
const isCheckbox = element.type == "checkbox", isRadio = element.type == "radio";
|
|
80
71
|
if (!isCheckbox && !isRadio) {
|
|
81
72
|
return;
|
|
82
73
|
}
|
|
83
|
-
|
|
74
|
+
let rawValue = valueAccessor(), valueIsArray = isCheckbox && unwrap(rawValue) instanceof Array, rawValueIsNonArrayObservable = !(valueIsArray && rawValue.push && rawValue.splice), useElementValue = isRadio || valueIsArray, oldElemValue = valueIsArray ? checkedValue2() : void 0;
|
|
84
75
|
computed(updateModel, null, { disposeWhenNodeIsRemoved: element });
|
|
85
76
|
registerEventHandler(element, "click", updateModel);
|
|
86
77
|
computed(updateView, null, { disposeWhenNodeIsRemoved: element });
|
|
87
78
|
rawValue = void 0;
|
|
88
79
|
}
|
|
89
80
|
};
|
|
90
|
-
export
|
|
81
|
+
export const checkedValue = {
|
|
91
82
|
update: function(element, valueAccessor) {
|
|
92
83
|
element.value = unwrap(valueAccessor());
|
|
93
84
|
}
|
package/dist/checked.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/checked.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { registerEventHandler, arrayIndexOf, addOrRemoveItem } from '@tko/utils'\n\nimport { unwrap, dependencyDetection, isWriteableObservable } from '@tko/observable'\n\nimport { computed, pureComputed } from '@tko/computed'\n\nimport type { AllBindings } from '@tko/bind'\n\nexport const checked = {\n after: ['value', 'attr'],\n init: function (element, valueAccessor, allBindings: AllBindings) {\n const checkedValue = pureComputed(function () {\n // Treat \"value\" like \"checkedValue\" when it is included with \"checked\" binding\n if (allBindings.has('checkedValue')) {\n return unwrap(allBindings.get('checkedValue'))\n } else if (useElementValue) {\n if (allBindings.has('value')) {\n return unwrap(allBindings.get('value'))\n } else {\n return element.value\n }\n }\n })\n\n function updateModel() {\n // This updates the model value from the view value.\n // It runs in response to DOM events (click) and changes in checkedValue.\n let isChecked = element.checked,\n elemValue = checkedValue()\n\n // When we're first setting up this computed, don't change any model state.\n if (dependencyDetection.isInitial()) {\n return\n }\n\n // We can ignore unchecked radio buttons, because some other radio\n // button will be checked, and that one can take care of updating state.\n // button will be checked, and that one can take care of updating state\n if (!isChecked && (isRadio || dependencyDetection.getDependenciesCount())) {\n return\n }\n\n const modelValue = dependencyDetection.ignore(valueAccessor)\n if (valueIsArray) {\n const writableValue = rawValueIsNonArrayObservable ? modelValue.peek() : modelValue,\n saveOldValue = oldElemValue\n oldElemValue = elemValue\n\n if (saveOldValue !== elemValue) {\n // When we're responding to the checkedValue changing, and the element is\n // currently checked, replace the old elem value with the new elem value\n // in the model array.\n if (isChecked) {\n addOrRemoveItem(writableValue, elemValue, true)\n addOrRemoveItem(writableValue, saveOldValue, false)\n }\n\n oldElemValue = elemValue\n } else {\n // When we're responding to the user having checked/unchecked a checkbox,\n // add/remove the element value to the model array.\n addOrRemoveItem(writableValue, elemValue, isChecked)\n }\n if (rawValueIsNonArrayObservable && isWriteableObservable(modelValue)) {\n modelValue(writableValue)\n }\n } else {\n if (isCheckbox) {\n if (elemValue === undefined) {\n elemValue = isChecked\n } else if (!isChecked) {\n elemValue = undefined\n }\n }\n // valueAccessor(elemValue, {onlyIfChanged: true})\n const modelValue = valueAccessor(elemValue, { onlyIfChanged: true })\n if (isWriteableObservable(modelValue) && modelValue.peek() !== elemValue) {\n modelValue(elemValue)\n }\n }\n }\n\n function updateView() {\n // This updates the view value from the model value.\n // It runs in response to changes in the bound (checked) value.\n const modelValue = unwrap(valueAccessor())\n const elemValue = checkedValue()\n\n if (valueIsArray) {\n // When a checkbox is bound to an array, being checked represents its value being present in that array\n element.checked = arrayIndexOf(modelValue, elemValue) >= 0\n oldElemValue = elemValue\n } else if (isCheckbox && elemValue === undefined) {\n // When a checkbox is bound to any other value (not an array) and \"checkedValue\" is not defined,\n // being checked represents the value being trueish\n element.checked = !!modelValue\n } else {\n // Otherwise, being checked means that the checkbox or radio button's value corresponds to the model value\n element.checked = checkedValue() === modelValue\n }\n }\n\n const isCheckbox = element.type == 'checkbox',\n isRadio = element.type == 'radio'\n\n // Only bind to check boxes and radio buttons\n if (!isCheckbox && !isRadio) {\n return\n }\n\n let rawValue = valueAccessor(),\n valueIsArray = isCheckbox && unwrap(rawValue) instanceof Array,\n rawValueIsNonArrayObservable = !(valueIsArray && rawValue.push && rawValue.splice),\n useElementValue = isRadio || valueIsArray,\n oldElemValue = valueIsArray ? checkedValue() : undefined\n\n // Set up two computeds to update the binding:\n\n // The first responds to changes in the checkedValue value and to element clicks\n computed(updateModel, null, { disposeWhenNodeIsRemoved: element })\n registerEventHandler(element, 'click', updateModel)\n\n // The second responds to changes in the model value (the one associated with the checked binding)\n computed(updateView, null, { disposeWhenNodeIsRemoved: element })\n\n rawValue = undefined\n }\n}\n\nexport const checkedValue = {\n update: function (element, valueAccessor) {\n element.value = unwrap(valueAccessor())\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,sBAAsB,cAAc,uBAAuB;AAEpE,SAAS,QAAQ,qBAAqB,6BAA6B;AAEnE,SAAS,UAAU,oBAAoB;AAIhC,aAAM,UAAU;AAAA,EACrB,OAAO,CAAC,SAAS,MAAM;AAAA,EACvB,MAAM,SAAU,SAAS,eAAe,aAA0B;AAChE,UAAMA,gBAAe,aAAa,WAAY;AAE5C,UAAI,YAAY,IAAI,cAAc,GAAG;AACnC,eAAO,OAAO,YAAY,IAAI,cAAc,CAAC;AAAA,MAC/C,WAAW,iBAAiB;AAC1B,YAAI,YAAY,IAAI,OAAO,GAAG;AAC5B,iBAAO,OAAO,YAAY,IAAI,OAAO,CAAC;AAAA,QACxC,OAAO;AACL,iBAAO,QAAQ;AAAA,QACjB;AAAA,MACF;AAAA,IACF,CAAC;AAED,aAAS,cAAc;AAGrB,UAAI,YAAY,QAAQ,SACtB,YAAYA,cAAa;AAG3B,UAAI,oBAAoB,UAAU,GAAG;AACnC;AAAA,MACF;AAKA,UAAI,CAAC,cAAc,WAAW,oBAAoB,qBAAqB,IAAI;AACzE;AAAA,MACF;AAEA,YAAM,aAAa,oBAAoB,OAAO,aAAa;AAC3D,UAAI,cAAc;AAChB,cAAM,gBAAgB,+BAA+B,WAAW,KAAK,IAAI,YACvE,eAAe;AACjB,uBAAe;AAEf,YAAI,iBAAiB,WAAW;AAI9B,cAAI,WAAW;AACb,4BAAgB,eAAe,WAAW,IAAI;AAC9C,4BAAgB,eAAe,cAAc,KAAK;AAAA,UACpD;AAEA,yBAAe;AAAA,QACjB,OAAO;AAGL,0BAAgB,eAAe,WAAW,SAAS;AAAA,QACrD;AACA,YAAI,gCAAgC,sBAAsB,UAAU,GAAG;AACrE,qBAAW,aAAa;AAAA,QAC1B;AAAA,MACF,OAAO;AACL,YAAI,YAAY;AACd,cAAI,cAAc,QAAW;AAC3B,wBAAY;AAAA,UACd,WAAW,CAAC,WAAW;AACrB,wBAAY;AAAA,UACd;AAAA,QACF;AAEA,cAAMC,cAAa,cAAc,WAAW,EAAE,eAAe,KAAK,CAAC;AACnE,YAAI,sBAAsBA,WAAU,KAAKA,YAAW,KAAK,MAAM,WAAW;AACxE,UAAAA,YAAW,SAAS;AAAA,QACtB;AAAA,MACF;AAAA,IACF;AAEA,aAAS,aAAa;AAGpB,YAAM,aAAa,OAAO,cAAc,CAAC;AACzC,YAAM,YAAYD,cAAa;AAE/B,UAAI,cAAc;AAEhB,gBAAQ,UAAU,aAAa,YAAY,SAAS,KAAK;AACzD,uBAAe;AAAA,MACjB,WAAW,cAAc,cAAc,QAAW;AAGhD,gBAAQ,UAAU,CAAC,CAAC;AAAA,MACtB,OAAO;AAEL,gBAAQ,UAAUA,cAAa,MAAM;AAAA,MACvC;AAAA,IACF;AAEA,UAAM,aAAa,QAAQ,QAAQ,YACjC,UAAU,QAAQ,QAAQ;AAG5B,QAAI,CAAC,cAAc,CAAC,SAAS;AAC3B;AAAA,IACF;AAEA,QAAI,WAAW,cAAc,GAC3B,eAAe,cAAc,OAAO,QAAQ,aAAa,OACzD,+BAA+B,EAAE,gBAAgB,SAAS,QAAQ,SAAS,SAC3E,kBAAkB,WAAW,cAC7B,eAAe,eAAeA,cAAa,IAAI;AAKjD,aAAS,aAAa,MAAM,EAAE,0BAA0B,QAAQ,CAAC;AACjE,yBAAqB,SAAS,SAAS,WAAW;AAGlD,aAAS,YAAY,MAAM,EAAE,0BAA0B,QAAQ,CAAC;AAEhE,eAAW;AAAA,EACb;AACF;AAEO,aAAM,eAAe;AAAA,EAC1B,QAAQ,SAAU,SAAS,eAAe;AACxC,YAAQ,QAAQ,OAAO,cAAc,CAAC;AAAA,EACxC;AACF;",
|
|
6
|
+
"names": ["checkedValue", "modelValue"]
|
|
7
7
|
}
|
package/dist/click.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export var click = makeEventHandlerShortcut("click");
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import { makeEventHandlerShortcut } from "./event";
|
|
4
|
+
export const click = makeEventHandlerShortcut("click");
|
package/dist/click.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/click.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { makeEventHandlerShortcut } from './event'\n\n// 'click' is just a shorthand for the usual full-length event:{click:handler}\nexport const click = makeEventHandlerShortcut('click')\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,gCAAgC;AAGlC,aAAM,QAAQ,yBAAyB,OAAO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/css.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
stringTrim
|
|
7
|
-
} from "@tko/utils";
|
|
8
|
-
import {
|
|
9
|
-
unwrap
|
|
10
|
-
} from "@tko/observable";
|
|
11
|
-
export var css = {
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import { createSymbolOrString, toggleDomNodeCssClass, objectForEach, stringTrim } from "@tko/utils";
|
|
4
|
+
import { unwrap } from "@tko/observable";
|
|
5
|
+
export const css = {
|
|
12
6
|
aliases: ["class"],
|
|
13
7
|
update: function(element, valueAccessor) {
|
|
14
|
-
|
|
8
|
+
let value = unwrap(valueAccessor());
|
|
15
9
|
if (value !== null && typeof value === "object") {
|
|
16
10
|
objectForEach(value, function(className, shouldHaveClass) {
|
|
17
11
|
shouldHaveClass = unwrap(shouldHaveClass);
|
package/dist/css.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/css.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { createSymbolOrString, toggleDomNodeCssClass, objectForEach, stringTrim } from '@tko/utils'\n\nimport { unwrap } from '@tko/observable'\n\nexport const css = {\n aliases: ['class'],\n update: function (element, valueAccessor) {\n let value = unwrap(valueAccessor())\n if (value !== null && typeof value === 'object') {\n objectForEach(value, function (className, shouldHaveClass) {\n shouldHaveClass = unwrap(shouldHaveClass)\n toggleDomNodeCssClass(element, className, shouldHaveClass)\n })\n } else {\n value = stringTrim(String(value || '')) // Make sure we don't try to store or set a non-string value\n toggleDomNodeCssClass(element, element[css.classesWrittenByBindingKey], false)\n element[css.classesWrittenByBindingKey] = value\n toggleDomNodeCssClass(element, value, true)\n }\n },\n classesWrittenByBindingKey: createSymbolOrString('__ko__cssValue')\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,sBAAsB,uBAAuB,eAAe,kBAAkB;AAEvF,SAAS,cAAc;AAEhB,aAAM,MAAM;AAAA,EACjB,SAAS,CAAC,OAAO;AAAA,EACjB,QAAQ,SAAU,SAAS,eAAe;AACxC,QAAI,QAAQ,OAAO,cAAc,CAAC;AAClC,QAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;AAC/C,oBAAc,OAAO,SAAU,WAAW,iBAAiB;AACzD,0BAAkB,OAAO,eAAe;AACxC,8BAAsB,SAAS,WAAW,eAAe;AAAA,MAC3D,CAAC;AAAA,IACH,OAAO;AACL,cAAQ,WAAW,OAAO,SAAS,EAAE,CAAC;AACtC,4BAAsB,SAAS,QAAQ,IAAI,0BAA0B,GAAG,KAAK;AAC7E,cAAQ,IAAI,0BAA0B,IAAI;AAC1C,4BAAsB,SAAS,OAAO,IAAI;AAAA,IAC5C;AAAA,EACF;AAAA,EACA,4BAA4B,qBAAqB,gBAAgB;AACnE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "@tko/bind";
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import { BindingHandler } from "@tko/bind";
|
|
5
4
|
export default class DescendantsCompleteHandler extends BindingHandler {
|
|
6
5
|
onDescendantsComplete() {
|
|
7
6
|
if (typeof this.value === "function") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/descendantsComplete.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * A simple callback binding.\n */\nimport {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * A simple callback binding.\n */\nimport { BindingHandler } from '@tko/bind'\n\nexport default class DescendantsCompleteHandler extends BindingHandler {\n onDescendantsComplete() {\n if (typeof this.value === 'function') {\n this.value(this.$element)\n }\n }\n\n static override get allowVirtualElements() {\n return true\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAGA,SAAS,sBAAsB;AAE/B,qBAAqB,mCAAmC,eAAe;AAAA,EACrE,wBAAwB;AACtB,QAAI,OAAO,KAAK,UAAU,YAAY;AACpC,WAAK,MAAM,KAAK,QAAQ;AAAA,IAC1B;AAAA,EACF;AAAA,EAEA,WAAoB,uBAAuB;AACzC,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/enableDisable.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export var enable = {
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import { unwrap } from "@tko/observable";
|
|
4
|
+
export const enable = {
|
|
6
5
|
update: function(element, valueAccessor) {
|
|
7
|
-
|
|
6
|
+
const value = unwrap(valueAccessor());
|
|
8
7
|
if (value && element.disabled) {
|
|
9
8
|
element.removeAttribute("disabled");
|
|
10
9
|
} else if (!value && !element.disabled) {
|
|
@@ -12,7 +11,7 @@ export var enable = {
|
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
};
|
|
15
|
-
export
|
|
14
|
+
export const disable = {
|
|
16
15
|
update: function(element, valueAccessor) {
|
|
17
16
|
enable.update(element, function() {
|
|
18
17
|
return !unwrap(valueAccessor());
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/enableDisable.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { unwrap } from '@tko/observable'\n\nexport const enable = {\n update: function (element, valueAccessor) {\n const value = unwrap(valueAccessor())\n if (value && element.disabled) {\n element.removeAttribute('disabled')\n } else if (!value && !element.disabled) {\n element.disabled = true\n }\n }\n}\n\nexport const disable = {\n update: function (element, valueAccessor) {\n enable.update(element, function () {\n return !unwrap(valueAccessor())\n })\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,cAAc;AAEhB,aAAM,SAAS;AAAA,EACpB,QAAQ,SAAU,SAAS,eAAe;AACxC,UAAM,QAAQ,OAAO,cAAc,CAAC;AACpC,QAAI,SAAS,QAAQ,UAAU;AAC7B,cAAQ,gBAAgB,UAAU;AAAA,IACpC,WAAW,CAAC,SAAS,CAAC,QAAQ,UAAU;AACtC,cAAQ,WAAW;AAAA,IACrB;AAAA,EACF;AACF;AAEO,aAAM,UAAU;AAAA,EACrB,QAAQ,SAAU,SAAS,eAAe;AACxC,WAAO,OAAO,SAAS,WAAY;AACjC,aAAO,CAAC,OAAO,cAAc,CAAC;AAAA,IAChC,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/event.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
2
3
|
import {
|
|
3
4
|
objectForEach,
|
|
4
5
|
registerEventHandler,
|
|
5
6
|
throttle as throttleFn,
|
|
6
7
|
debounce as debounceFn
|
|
7
8
|
} from "@tko/utils";
|
|
8
|
-
import {
|
|
9
|
-
unwrap
|
|
10
|
-
} from "@tko/observable";
|
|
9
|
+
import { unwrap } from "@tko/observable";
|
|
11
10
|
export function makeEventHandlerShortcut(eventName) {
|
|
12
11
|
return {
|
|
13
12
|
init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const newValueAccessor = function() {
|
|
14
|
+
const result = {};
|
|
16
15
|
result[eventName] = valueAccessor();
|
|
17
16
|
return result;
|
|
18
17
|
};
|
|
@@ -25,12 +24,12 @@ function makeDescriptor(handlerOrObject) {
|
|
|
25
24
|
}
|
|
26
25
|
export const eventHandler = {
|
|
27
26
|
init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
|
|
28
|
-
|
|
27
|
+
const eventsToHandle = valueAccessor() || {};
|
|
29
28
|
objectForEach(eventsToHandle, function(eventName, descriptor) {
|
|
30
29
|
const { passive, capture, once, debounce, throttle } = makeDescriptor(descriptor);
|
|
31
30
|
const eventOptions = (capture || passive || once) && { capture, passive, once };
|
|
32
31
|
let eventHandlerFn = (event, ...more) => {
|
|
33
|
-
|
|
32
|
+
let handlerReturnValue;
|
|
34
33
|
const { handler, passive: passive2, bubble, preventDefault } = makeDescriptor(valueAccessor()[eventName]);
|
|
35
34
|
try {
|
|
36
35
|
if (handler) {
|
package/dist/event.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/event.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import {\n objectForEach,\n registerEventHandler,\n makeArray,\n throttle as throttleFn,\n debounce as debounceFn\n} from '@tko/utils'\n\nimport { unwrap } from '@tko/observable'\n\nimport type { AllBindings, BindingContext } from '@tko/bind'\n\n// For certain common events (currently just 'click'), allow a simplified data-binding syntax\n// e.g. click:handler instead of the usual full-length event:{click:handler}\nexport function makeEventHandlerShortcut(eventName) {\n return {\n init: function (element, valueAccessor, allBindings: AllBindings, viewModel, bindingContext: BindingContext) {\n const newValueAccessor = function () {\n const result = {}\n result[eventName] = valueAccessor()\n return result\n }\n eventHandler.init.call(this, element, newValueAccessor, allBindings, viewModel, bindingContext)\n }\n }\n}\n\nfunction makeDescriptor(handlerOrObject) {\n return typeof handlerOrObject === 'function' ? { handler: handlerOrObject } : handlerOrObject || {}\n}\n\nexport const eventHandler = {\n init: function (element, valueAccessor, allBindings, viewModel, bindingContext: BindingContext) {\n const eventsToHandle = valueAccessor() || {}\n objectForEach(eventsToHandle, function (eventName, descriptor) {\n const { passive, capture, once, debounce, throttle } = makeDescriptor(descriptor)\n const eventOptions = (capture || passive || once) && { capture, passive, once }\n\n let eventHandlerFn = (event, ...more) => {\n let handlerReturnValue\n const { handler, passive, bubble, preventDefault } = makeDescriptor(valueAccessor()[eventName])\n\n try {\n // Take all the event args, and prefix with the viewmodel\n if (handler) {\n const possiblyUpdatedViewModel = bindingContext.$data\n const argsForHandler = [possiblyUpdatedViewModel, event, ...more]\n handlerReturnValue = handler.apply(possiblyUpdatedViewModel, argsForHandler)\n }\n } finally {\n // preventDefault in the descriptor takes precedent over the handler return value\n if (preventDefault !== undefined) {\n if (unwrap(preventDefault)) {\n event.preventDefault()\n }\n } else if (handlerReturnValue !== true) {\n // Normally we want to prevent default action. Developer can override this by explicitly returning true\n // preventDefault will throw an error if the event is passive.\n if (!passive) {\n event.preventDefault()\n }\n }\n }\n\n const bubbleMark = allBindings.get(eventName + 'Bubble') !== false\n if (bubble === false || !bubbleMark) {\n event.cancelBubble = true\n if (event.stopPropagation) {\n event.stopPropagation()\n }\n }\n }\n\n if (debounce) {\n eventHandlerFn = debounceFn(eventHandlerFn, debounce)\n }\n if (throttle) {\n eventHandlerFn = throttleFn(eventHandlerFn, throttle)\n }\n\n registerEventHandler(element, eventName, eventHandlerFn, eventOptions || false)\n })\n }\n}\n\nexport const onHandler = {\n init: eventHandler.init,\n preprocess: function (value, key, addBinding) {\n addBinding(key.replace('on.', ''), '=>' + value)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EAEA,YAAY;AAAA,EACZ,YAAY;AAAA,OACP;AAEP,SAAS,cAAc;AAMhB,gBAAS,yBAAyB,WAAW;AAClD,SAAO;AAAA,IACL,MAAM,SAAU,SAAS,eAAe,aAA0B,WAAW,gBAAgC;AAC3G,YAAM,mBAAmB,WAAY;AACnC,cAAM,SAAS,CAAC;AAChB,eAAO,SAAS,IAAI,cAAc;AAClC,eAAO;AAAA,MACT;AACA,mBAAa,KAAK,KAAK,MAAM,SAAS,kBAAkB,aAAa,WAAW,cAAc;AAAA,IAChG;AAAA,EACF;AACF;AAEA,SAAS,eAAe,iBAAiB;AACvC,SAAO,OAAO,oBAAoB,aAAa,EAAE,SAAS,gBAAgB,IAAI,mBAAmB,CAAC;AACpG;AAEO,aAAM,eAAe;AAAA,EAC1B,MAAM,SAAU,SAAS,eAAe,aAAa,WAAW,gBAAgC;AAC9F,UAAM,iBAAiB,cAAc,KAAK,CAAC;AAC3C,kBAAc,gBAAgB,SAAU,WAAW,YAAY;AAC7D,YAAM,EAAE,SAAS,SAAS,MAAM,UAAU,SAAS,IAAI,eAAe,UAAU;AAChF,YAAM,gBAAgB,WAAW,WAAW,SAAS,EAAE,SAAS,SAAS,KAAK;AAE9E,UAAI,iBAAiB,CAAC,UAAU,SAAS;AACvC,YAAI;AACJ,cAAM,EAAE,SAAS,SAAAA,UAAS,QAAQ,eAAe,IAAI,eAAe,cAAc,EAAE,SAAS,CAAC;AAE9F,YAAI;AAEF,cAAI,SAAS;AACX,kBAAM,2BAA2B,eAAe;AAChD,kBAAM,iBAAiB,CAAC,0BAA0B,OAAO,GAAG,IAAI;AAChE,iCAAqB,QAAQ,MAAM,0BAA0B,cAAc;AAAA,UAC7E;AAAA,QACF,UAAE;AAEA,cAAI,mBAAmB,QAAW;AAChC,gBAAI,OAAO,cAAc,GAAG;AAC1B,oBAAM,eAAe;AAAA,YACvB;AAAA,UACF,WAAW,uBAAuB,MAAM;AAGtC,gBAAI,CAACA,UAAS;AACZ,oBAAM,eAAe;AAAA,YACvB;AAAA,UACF;AAAA,QACF;AAEA,cAAM,aAAa,YAAY,IAAI,YAAY,QAAQ,MAAM;AAC7D,YAAI,WAAW,SAAS,CAAC,YAAY;AACnC,gBAAM,eAAe;AACrB,cAAI,MAAM,iBAAiB;AACzB,kBAAM,gBAAgB;AAAA,UACxB;AAAA,QACF;AAAA,MACF;AAEA,UAAI,UAAU;AACZ,yBAAiB,WAAW,gBAAgB,QAAQ;AAAA,MACtD;AACA,UAAI,UAAU;AACZ,yBAAiB,WAAW,gBAAgB,QAAQ;AAAA,MACtD;AAEA,2BAAqB,SAAS,WAAW,gBAAgB,gBAAgB,KAAK;AAAA,IAChF,CAAC;AAAA,EACH;AACF;AAEO,aAAM,YAAY;AAAA,EACvB,MAAM,aAAa;AAAA,EACnB,YAAY,SAAU,OAAO,KAAK,YAAY;AAC5C,eAAW,IAAI,QAAQ,OAAO,EAAE,GAAG,OAAO,KAAK;AAAA,EACjD;AACF;",
|
|
6
|
+
"names": ["passive"]
|
|
7
7
|
}
|
package/dist/hasfocus.js
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "@tko/observable";
|
|
11
|
-
var hasfocusUpdatingProperty = createSymbolOrString("__ko_hasfocusUpdating");
|
|
12
|
-
var hasfocusLastValue = createSymbolOrString("__ko_hasfocusLastValue");
|
|
13
|
-
export var hasfocus = {
|
|
14
|
-
init: function(element, valueAccessor) {
|
|
15
|
-
var handleElementFocusChange = function(isFocused) {
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import { createSymbolOrString, triggerEvent, registerEventHandler } from "@tko/utils";
|
|
4
|
+
import { unwrap, dependencyDetection, isWriteableObservable } from "@tko/observable";
|
|
5
|
+
const hasfocusUpdatingProperty = createSymbolOrString("__ko_hasfocusUpdating");
|
|
6
|
+
const hasfocusLastValue = createSymbolOrString("__ko_hasfocusLastValue");
|
|
7
|
+
export const hasfocus = {
|
|
8
|
+
init: function(element, valueAccessor, _allBindings) {
|
|
9
|
+
const handleElementFocusChange = function(isFocused) {
|
|
16
10
|
element[hasfocusUpdatingProperty] = true;
|
|
17
|
-
|
|
11
|
+
const ownerDoc = element.ownerDocument;
|
|
18
12
|
if ("activeElement" in ownerDoc) {
|
|
19
|
-
|
|
13
|
+
let active;
|
|
20
14
|
try {
|
|
21
15
|
active = ownerDoc.activeElement;
|
|
22
16
|
} catch (e) {
|
|
@@ -24,21 +18,28 @@ export var hasfocus = {
|
|
|
24
18
|
}
|
|
25
19
|
isFocused = active === element;
|
|
26
20
|
}
|
|
27
|
-
valueAccessor(isFocused, { onlyIfChanged: true });
|
|
21
|
+
const modelValue = valueAccessor(isFocused, { onlyIfChanged: true });
|
|
22
|
+
if (isWriteableObservable(modelValue) && modelValue.peek() !== isFocused) {
|
|
23
|
+
modelValue(isFocused);
|
|
24
|
+
}
|
|
28
25
|
element[hasfocusLastValue] = isFocused;
|
|
29
26
|
element[hasfocusUpdatingProperty] = false;
|
|
30
27
|
};
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const handleElementFocusIn = handleElementFocusChange.bind(null, true);
|
|
29
|
+
const handleElementFocusOut = handleElementFocusChange.bind(null, false);
|
|
33
30
|
registerEventHandler(element, "focus", handleElementFocusIn);
|
|
34
31
|
registerEventHandler(element, "focusin", handleElementFocusIn);
|
|
35
32
|
registerEventHandler(element, "blur", handleElementFocusOut);
|
|
36
33
|
registerEventHandler(element, "focusout", handleElementFocusOut);
|
|
37
34
|
},
|
|
38
35
|
update: function(element, valueAccessor) {
|
|
39
|
-
|
|
36
|
+
const value = !!unwrap(valueAccessor());
|
|
40
37
|
if (!element[hasfocusUpdatingProperty] && element[hasfocusLastValue] !== value) {
|
|
41
|
-
|
|
38
|
+
if (value) {
|
|
39
|
+
element.focus();
|
|
40
|
+
} else {
|
|
41
|
+
element.blur();
|
|
42
|
+
}
|
|
42
43
|
if (!value && element[hasfocusLastValue]) {
|
|
43
44
|
element.ownerDocument.body.focus();
|
|
44
45
|
}
|
package/dist/hasfocus.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/hasfocus.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { createSymbolOrString, triggerEvent, registerEventHandler } from '@tko/utils'\n\nimport { unwrap, dependencyDetection, isWriteableObservable } from '@tko/observable'\n\nimport type { AllBindings } from '@tko/bind'\n\nconst hasfocusUpdatingProperty = createSymbolOrString('__ko_hasfocusUpdating')\nconst hasfocusLastValue = createSymbolOrString('__ko_hasfocusLastValue')\n\nexport const hasfocus = {\n init: function (element, valueAccessor, _allBindings: AllBindings) {\n const handleElementFocusChange = function (isFocused) {\n // Where possible, ignore which event was raised and determine focus state using activeElement,\n // as this avoids phantom focus/blur events raised when changing tabs in modern browsers.\n // However, not all KO-targeted browsers (Firefox 2) support activeElement. For those browsers,\n // prevent a loss of focus when changing tabs/windows by setting a flag that prevents hasfocus\n // from calling 'blur()' on the element when it loses focus.\n // Discussion at https://github.com/SteveSanderson/knockout/pull/352\n element[hasfocusUpdatingProperty] = true\n const ownerDoc = element.ownerDocument\n if ('activeElement' in ownerDoc) {\n let active\n try {\n active = ownerDoc.activeElement\n } catch (e) {\n // IE9 throws if you access activeElement during page load (see issue #703)\n active = ownerDoc.body\n }\n isFocused = active === element\n }\n\n const modelValue = valueAccessor(isFocused, { onlyIfChanged: true })\n // Found a scenario where hasFocus changes were not fired\n // the fix was transfered from ko 3.5 (Focusout event was not fired)\n // This only replies the value if there are changes\n // it won't effect if already set by valueAccessor (Parser.convertToAccessors)\n if (isWriteableObservable(modelValue) && modelValue.peek() !== isFocused) {\n modelValue(isFocused)\n }\n\n // cache the latest value, so we can avoid unnecessarily calling focus/blur in the update function\n element[hasfocusLastValue] = isFocused\n element[hasfocusUpdatingProperty] = false\n }\n\n const handleElementFocusIn = handleElementFocusChange.bind(null, true)\n const handleElementFocusOut = handleElementFocusChange.bind(null, false)\n\n registerEventHandler(element, 'focus', handleElementFocusIn)\n registerEventHandler(element, 'focusin', handleElementFocusIn) // For IE\n registerEventHandler(element, 'blur', handleElementFocusOut)\n registerEventHandler(element, 'focusout', handleElementFocusOut) // For IE\n },\n update: function (element, valueAccessor) {\n const value = !!unwrap(valueAccessor())\n\n if (!element[hasfocusUpdatingProperty] && element[hasfocusLastValue] !== value) {\n if (value) {\n element.focus()\n } else {\n element.blur()\n }\n\n // In IE, the blur method doesn't always cause the element to lose focus (for example, if the window is not in focus).\n // Setting focus to the body element does seem to be reliable in IE, but should only be used if we know that the current\n // element was focused already.\n if (!value && element[hasfocusLastValue]) {\n element.ownerDocument.body.focus()\n }\n\n // For IE, which doesn't reliably fire \"focus\" or \"blur\" events synchronously\n dependencyDetection.ignore(triggerEvent, null, [element, value ? 'focusin' : 'focusout'])\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,sBAAsB,cAAc,4BAA4B;AAEzE,SAAS,QAAQ,qBAAqB,6BAA6B;AAInE,MAAM,2BAA2B,qBAAqB,uBAAuB;AAC7E,MAAM,oBAAoB,qBAAqB,wBAAwB;AAEhE,aAAM,WAAW;AAAA,EACtB,MAAM,SAAU,SAAS,eAAe,cAA2B;AACjE,UAAM,2BAA2B,SAAU,WAAW;AAOpD,cAAQ,wBAAwB,IAAI;AACpC,YAAM,WAAW,QAAQ;AACzB,UAAI,mBAAmB,UAAU;AAC/B,YAAI;AACJ,YAAI;AACF,mBAAS,SAAS;AAAA,QACpB,SAAS,GAAG;AAEV,mBAAS,SAAS;AAAA,QACpB;AACA,oBAAY,WAAW;AAAA,MACzB;AAEA,YAAM,aAAa,cAAc,WAAW,EAAE,eAAe,KAAK,CAAC;AAKnE,UAAI,sBAAsB,UAAU,KAAK,WAAW,KAAK,MAAM,WAAW;AACxE,mBAAW,SAAS;AAAA,MACtB;AAGA,cAAQ,iBAAiB,IAAI;AAC7B,cAAQ,wBAAwB,IAAI;AAAA,IACtC;AAEA,UAAM,uBAAuB,yBAAyB,KAAK,MAAM,IAAI;AACrE,UAAM,wBAAwB,yBAAyB,KAAK,MAAM,KAAK;AAEvE,yBAAqB,SAAS,SAAS,oBAAoB;AAC3D,yBAAqB,SAAS,WAAW,oBAAoB;AAC7D,yBAAqB,SAAS,QAAQ,qBAAqB;AAC3D,yBAAqB,SAAS,YAAY,qBAAqB;AAAA,EACjE;AAAA,EACA,QAAQ,SAAU,SAAS,eAAe;AACxC,UAAM,QAAQ,CAAC,CAAC,OAAO,cAAc,CAAC;AAEtC,QAAI,CAAC,QAAQ,wBAAwB,KAAK,QAAQ,iBAAiB,MAAM,OAAO;AAC9E,UAAI,OAAO;AACT,gBAAQ,MAAM;AAAA,MAChB,OAAO;AACL,gBAAQ,KAAK;AAAA,MACf;AAKA,UAAI,CAAC,SAAS,QAAQ,iBAAiB,GAAG;AACxC,gBAAQ,cAAc,KAAK,MAAM;AAAA,MACnC;AAGA,0BAAoB,OAAO,cAAc,MAAM,CAAC,SAAS,QAAQ,YAAY,UAAU,CAAC;AAAA,IAC1F;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/html.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
// @tko/binding.core 🥊 4.0.0
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export var html = {
|
|
1
|
+
// @tko/binding.core 🥊 4.0.0 ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import { setHtml } from "@tko/utils";
|
|
4
|
+
export const html = {
|
|
6
5
|
init: function() {
|
|
7
|
-
return {
|
|
8
|
-
"controlsDescendantBindings": true
|
|
9
|
-
};
|
|
6
|
+
return { controlsDescendantBindings: true };
|
|
10
7
|
},
|
|
8
|
+
//
|
|
9
|
+
// Modify internal, per ko.punches and :
|
|
10
|
+
// http://stackoverflow.com/a/15348139
|
|
11
11
|
update: function(element, valueAccessor) {
|
|
12
12
|
setHtml(element, valueAccessor());
|
|
13
13
|
},
|
package/dist/html.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/html.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { setHtml } from '@tko/utils'\n\nexport const html = {\n init: function () {\n // Prevent binding on the dynamically-injected HTML (as developers are unlikely to expect that, and it has security implications)\n return { controlsDescendantBindings: true }\n },\n //\n // Modify internal, per ko.punches and :\n // http://stackoverflow.com/a/15348139\n update: function (element, valueAccessor) {\n setHtml(element, valueAccessor())\n },\n allowVirtualElements: true\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,eAAe;AAEjB,aAAM,OAAO;AAAA,EAClB,MAAM,WAAY;AAEhB,WAAO,EAAE,4BAA4B,KAAK;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA,EAIA,QAAQ,SAAU,SAAS,eAAe;AACxC,YAAQ,SAAS,cAAc,CAAC;AAAA,EAClC;AAAA,EACA,sBAAsB;AACxB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|