@tko/binding.core 4.0.0-beta1.3 → 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 (50) hide show
  1. package/dist/attr.js +10 -14
  2. package/dist/attr.js.map +2 -2
  3. package/dist/checked.js +19 -28
  4. package/dist/checked.js.map +3 -3
  5. package/dist/click.js +4 -5
  6. package/dist/click.js.map +2 -2
  7. package/dist/css.js +6 -12
  8. package/dist/css.js.map +2 -2
  9. package/dist/descendantsComplete.js +3 -4
  10. package/dist/descendantsComplete.js.map +2 -2
  11. package/dist/enableDisable.js +6 -7
  12. package/dist/enableDisable.js.map +2 -2
  13. package/dist/event.js +7 -8
  14. package/dist/event.js.map +3 -3
  15. package/dist/hasfocus.js +23 -22
  16. package/dist/hasfocus.js.map +2 -2
  17. package/dist/html.js +8 -8
  18. package/dist/html.js.map +2 -2
  19. package/dist/index.cjs +1037 -863
  20. package/dist/index.cjs.map +4 -4
  21. package/dist/index.js +6 -5
  22. package/dist/index.js.map +2 -2
  23. package/dist/index.mjs +6 -5
  24. package/dist/index.mjs.map +2 -2
  25. package/dist/let.js +6 -7
  26. package/dist/let.js.map +2 -2
  27. package/dist/options.js +39 -26
  28. package/dist/options.js.map +2 -2
  29. package/dist/selectedOptions.js +8 -9
  30. package/dist/selectedOptions.js.map +2 -2
  31. package/dist/style.js +8 -13
  32. package/dist/style.js.map +2 -2
  33. package/dist/submit.js +7 -8
  34. package/dist/submit.js.map +2 -2
  35. package/dist/text.js +4 -5
  36. package/dist/text.js.map +2 -2
  37. package/dist/textInput.js +24 -59
  38. package/dist/textInput.js.map +2 -2
  39. package/dist/uniqueName.js +5 -7
  40. package/dist/uniqueName.js.map +2 -2
  41. package/dist/using.js +6 -7
  42. package/dist/using.js.map +2 -2
  43. package/dist/value.js +17 -23
  44. package/dist/value.js.map +2 -2
  45. package/dist/visible.js +7 -8
  46. package/dist/visible.js.map +2 -2
  47. package/package.json +6 -7
  48. package/LICENSE +0 -22
  49. package/dist/test-helper.js +0 -14
  50. package/dist/test-helper.js.map +0 -7
package/dist/textInput.js CHANGED
@@ -1,19 +1,10 @@
1
- // @tko/binding.core 🥊 4.0.0-beta1.3 ESM
2
- import {
3
- domData,
4
- registerEventHandler,
5
- ieVersion,
6
- safeSetTimeout,
7
- options,
8
- arrayForEach
9
- } from "@tko/utils";
10
- import {
11
- unwrap
12
- } from "@tko/observable";
13
- import {
14
- BindingHandler
15
- } from "@tko/bind";
16
- var parseVersion, operaVersion, safariVersion, firefoxVersion;
1
+ // @tko/binding.core 🥊 4.0.0 ESM
2
+ "use strict";
3
+ import { safeSetTimeout, options, arrayForEach } from "@tko/utils";
4
+ import { unwrap } from "@tko/observable";
5
+ import { BindingHandler } from "@tko/bind";
6
+ export const MSIE_REGEX = /MSIE ([^ ;]+)|rv:([^ )]+)/;
7
+ let operaVersion, safariVersion, firefoxVersion, ieVersion;
17
8
  class TextInput extends BindingHandler {
18
9
  get aliases() {
19
10
  return "textinput";
@@ -51,6 +42,7 @@ class TextInput extends BindingHandler {
51
42
  const elementValue = element.value;
52
43
  if (this.previousElementValue !== elementValue) {
53
44
  if (options.debug && event) {
45
+ ;
54
46
  element._ko_textInputProcessedEvent = event.type;
55
47
  }
56
48
  this.previousElementValue = elementValue;
@@ -61,8 +53,8 @@ class TextInput extends BindingHandler {
61
53
  const element = this.$element;
62
54
  if (!this.timeoutHandle) {
63
55
  this.elementValueBeforeEvent = element.value;
64
- const handler2 = options.debug ? this.updateModel.bind(this, { type: event.type }) : this.updateModel;
65
- this.timeoutHandle = safeSetTimeout(handler2, 4);
56
+ const handler = options.debug ? this.updateModel.bind(this, { type: event.type }) : this.updateModel;
57
+ this.timeoutHandle = safeSetTimeout(handler, 4);
66
58
  }
67
59
  }
68
60
  updateView() {
@@ -80,43 +72,8 @@ class TextInput extends BindingHandler {
80
72
  }
81
73
  }
82
74
  class TextInputIE extends TextInput {
83
- constructor(...args) {
84
- super(...args);
85
- if (ieVersion < 11) {
86
- this.addEventListener("propertychange", (event) => event.propertyName === "value" && this.updateModel(event));
87
- }
88
- if (ieVersion >= 8 && ieVersion < 10) {
89
- this.watchForSelectionChangeEvent();
90
- this.addEventListener("dragend", "deferUpdateModel");
91
- }
92
- }
93
75
  eventsIndicatingSyncValueChange() {
94
- return [...super.eventsIndicatingValueChange(), "keypress"];
95
- }
96
- selectionChangeHandler(event) {
97
- const target = this.activeElement;
98
- const handler2 = target && domData.get(target, selectionChangeHandlerName);
99
- if (handler2) {
100
- handler2(event);
101
- }
102
- }
103
- watchForSelectionChangeEvent(element, ieUpdateModel) {
104
- const ownerDoc = element.ownerDocument;
105
- if (!domData.get(ownerDoc, selectionChangeRegisteredName)) {
106
- domData.set(ownerDoc, selectionChangeRegisteredName, true);
107
- registerEventHandler(ownerDoc, "selectionchange", this.selectionChangeHandler.bind(ownerDoc));
108
- }
109
- domData.set(element, selectionChangeHandlerName, handler);
110
- }
111
- }
112
- class TextInputIE9 extends TextInputIE {
113
- updateModel(...args) {
114
- this.deferUpdateModel(...args);
115
- }
116
- }
117
- class TextInputIE8 extends TextInputIE {
118
- eventsIndicatingValueChange() {
119
- return [...super.eventsIndicatingValueChange(), "keyup", "keydown"];
76
+ return [...super.eventsIndicatingSyncValueChange(), "keypress"];
120
77
  }
121
78
  }
122
79
  class TextInputLegacySafari extends TextInput {
@@ -133,19 +90,27 @@ class TextInputLegacyFirefox extends TextInput {
133
90
  eventsIndicatingValueChange() {
134
91
  return [
135
92
  ...super.eventsIndicatingSyncValueChange(),
93
+ // Firefox <= 3.6 doesn't fire the 'input' event when text is filled in through autocomplete
136
94
  "DOMAutoComplete",
95
+ // Firefox <=3.5 doesn't fire the 'input' event when text is dropped into the input.
137
96
  "dragdrop",
97
+ // < 3.5
138
98
  "drop"
99
+ // 3.5
139
100
  ];
140
101
  }
141
102
  }
142
103
  const w = options.global;
143
104
  if (w.navigator) {
144
- const parseVersion2 = (matches) => matches && parseFloat(matches[1]);
105
+ const parseVersion = (matches) => matches && parseFloat(matches[1]);
145
106
  const userAgent = w.navigator.userAgent;
146
107
  const isChrome = userAgent.match(/Chrome\/([^ ]+)/);
147
- operaVersion = w.opera && w.opera.version && parseInt(w.opera.version());
148
- safariVersion = parseVersion2(userAgent.match(/Version\/([^ ]+) Safari/));
149
- firefoxVersion = parseVersion2(userAgent.match(/Firefox\/([^ ]*)/));
108
+ if (!isChrome) {
109
+ operaVersion = w.opera && w.opera.version && parseInt(w.opera.version());
110
+ safariVersion = parseVersion(userAgent.match(/Version\/([^ ]+) Safari/));
111
+ firefoxVersion = parseVersion(userAgent.match(/Firefox\/([^ ]*)/));
112
+ const ieMatch = userAgent.match(MSIE_REGEX);
113
+ ieVersion = ieMatch && (parseFloat(ieMatch[1]) || parseFloat(ieMatch[2]));
114
+ }
150
115
  }
151
- export const textInput = ieVersion === 8 ? TextInputIE8 : ieVersion === 9 ? TextInputIE9 : ieVersion ? TextInputIE : safariVersion && safariVersion < 5 ? TextInputLegacySafari : operaVersion < 11 ? TextInputLegacyOpera : firefoxVersion && firefoxVersion < 4 ? TextInputLegacyFirefox : TextInput;
116
+ export const textInput = ieVersion && ieVersion <= 11 ? TextInputIE : safariVersion && safariVersion < 5 ? TextInputLegacySafari : operaVersion && operaVersion < 11 ? TextInputLegacyOpera : firefoxVersion && firefoxVersion < 4 ? TextInputLegacyFirefox : TextInput;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/textInput.ts"],
4
- "sourcesContent": ["\nimport {\n domData, registerEventHandler, ieVersion, safeSetTimeout, options,\n arrayForEach, tagNameLower\n} from '@tko/utils'\n\nimport {\n unwrap\n} from '@tko/observable'\n\nimport {\n computed\n} from '@tko/computed'\n\nimport {\n BindingHandler\n} from '@tko/bind'\n\nvar parseVersion, operaVersion, safariVersion, firefoxVersion\n\n\n/**\n * TextInput binding handler for modern browsers (legacy below).\n * @extends BindingHandler\n */\nclass TextInput extends BindingHandler {\n get aliases () { return 'textinput' }\n\n constructor (...args) {\n super(...args)\n this.previousElementValue = this.$element.value\n\n if (options.debug && this.constructor._forceUpdateOn) {\n // Provide a way for tests to specify exactly which events are bound\n arrayForEach(this.constructor._forceUpdateOn, (eventName) => {\n if (eventName.slice(0, 5) === 'after') {\n this.addEventListener(eventName.slice(5), 'deferUpdateModel')\n } else {\n this.addEventListener(eventName, 'updateModel')\n }\n })\n }\n\n for (const eventName of this.eventsIndicatingSyncValueChange()) {\n this.addEventListener(eventName, 'updateModel')\n }\n for (const eventName of this.eventsIndicatingDeferValueChange()) {\n this.addEventListener(eventName, 'deferUpdateModel')\n }\n this.computed('updateView')\n }\n\n eventsIndicatingSyncValueChange () {\n // input: Default, modern handler\n // change: Catch programmatic updates of the value that fire this event.\n // blur: To deal with browsers that don't notify any kind of event for some changes (IE, Safari, etc.)\n return ['input', 'change', 'blur']\n }\n\n eventsIndicatingDeferValueChange () {\n return []\n }\n\n updateModel (event) {\n const element = this.$element\n clearTimeout(this.timeoutHandle)\n this.elementValueBeforeEvent = this.timeoutHandle = undefined\n const elementValue = element.value\n if (this.previousElementValue !== elementValue) {\n // Provide a way for tests to know exactly which event was processed\n if (options.debug && event) {\n element._ko_textInputProcessedEvent = event.type\n }\n this.previousElementValue = elementValue\n this.value = elementValue\n }\n }\n\n deferUpdateModel (event) {\n const element = this.$element\n if (!this.timeoutHandle) {\n // The elementValueBeforeEvent variable is set *only* during the brief gap between an\n // event firing and the updateModel function running. This allows us to ignore model\n // updates that are from the previous state of the element, usually due to techniques\n // such as rateLimit. Such updates, if not ignored, can cause keystrokes to be lost.\n this.elementValueBeforeEvent = element.value\n const handler = options.debug ? this.updateModel.bind(this, { type: event.type }) : this.updateModel\n this.timeoutHandle = safeSetTimeout(handler, 4)\n }\n }\n\n updateView () {\n let modelValue = unwrap(this.value)\n if (modelValue === null || modelValue === undefined) {\n modelValue = ''\n }\n if (this.elementValueBeforeEvent !== undefined\n && modelValue === this.elementValueBeforeEvent) {\n setTimeout(this.updateView.bind(this), 4)\n } else if (this.$element.value !== modelValue) {\n // Update the element only if the element and model are different. On some browsers, updating the value\n // will move the cursor to the end of the input, which would be bad while the user is typing.\n this.previousElementValue = modelValue // Make sure we ignore events (propertychange) that result from updating the value\n this.$element.value = modelValue\n this.previousElementValue = this.$element.value // In case the browser changes the value (see #2281)\n }\n }\n}\n\n/**\n * Legacy Input Classes, below\n */\nclass TextInputIE extends TextInput {\n constructor (...args) {\n super(...args)\n\n if (ieVersion < 11) {\n // Internet Explorer <= 8 doesn't support the 'input' event, but does include 'propertychange' that fires whenever\n // any property of an element changes. Unlike 'input', it also fires if a property is changed from JavaScript code,\n // but that's an acceptable compromise for this binding. IE 9 and 10 support 'input', but since they don't always\n // fire it when using autocomplete, we'll use 'propertychange' for them also.\n this.addEventListener('propertychange', event =>\n event.propertyName === 'value' && this.updateModel(event)\n )\n }\n\n if (ieVersion >= 8 && ieVersion < 10) {\n this.watchForSelectionChangeEvent()\n this.addEventListener('dragend', 'deferUpdateModel')\n }\n }\n\n eventsIndicatingSyncValueChange () {\n // keypress: All versions (including 11) of Internet Explorer have a bug that they don't generate an input or propertychange event when ESC is pressed\n return [...super.eventsIndicatingValueChange(), 'keypress']\n }\n\n // IE 8 and 9 have bugs that prevent the normal events from firing when the value changes.\n // But it does fire the 'selectionchange' event on many of those, presumably because the\n // cursor is moving and that counts as the selection changing. The 'selectionchange' event is\n // fired at the document level only and doesn't directly indicate which element changed. We\n // set up just one event handler for the document and use 'activeElement' to determine which\n // element was changed.\n selectionChangeHandler (event) {\n const target = this.activeElement\n const handler = target && domData.get(target, selectionChangeHandlerName)\n if (handler) { handler(event) }\n }\n\n watchForSelectionChangeEvent (element, ieUpdateModel) {\n const ownerDoc = element.ownerDocument;\n if (!domData.get(ownerDoc, selectionChangeRegisteredName)) {\n domData.set(ownerDoc, selectionChangeRegisteredName, true)\n registerEventHandler(ownerDoc, 'selectionchange', this.selectionChangeHandler.bind(ownerDoc))\n }\n domData.set(element, selectionChangeHandlerName, handler)\n }\n}\n\n\n// IE 8 and 9 have bugs that prevent the normal events from firing when the value changes.\n// But it does fire the 'selectionchange' event on many of those, presumably because the\n// cursor is moving and that counts as the selection changing. The 'selectionchange' event is\n// fired at the document level only and doesn't directly indicate which element changed. We\n// set up just one event handler for the document and use 'activeElement' to determine which\n// element was changed.\nclass TextInputIE9 extends TextInputIE {\n updateModel (...args) {\n // IE9 will mess up the DOM if you handle events synchronously which results in DOM changes (such as other bindings);\n // so we'll make sure all updates are asynchronous\n this.deferUpdateModel(...args)\n }\n}\n\n\nclass TextInputIE8 extends TextInputIE {\n eventsIndicatingValueChange () {\n // IE 8 has a bug where it fails to fire 'propertychange' on the first update following a value change from\n // JavaScript code. It also doesn't fire if you clear the entire value. To fix this, we bind to the following\n // events too.\n // keypress: All versions (including 11) of Internet Explorer have a bug that they don't generate an input or propertychange event when ESC is pressed\n // keyup: A single keystoke\n // keydown: First character when a key is held down\n return [...super.eventsIndicatingValueChange(), 'keyup', 'keydown']\n }\n}\n\n\n// Safari <5 doesn't fire the 'input' event for <textarea> elements (it does fire 'textInput'\n// but only when typing). So we'll just catch as much as we can with keydown, cut, and paste.\nclass TextInputLegacySafari extends TextInput {\n eventsIndicatingDeferValueChange () {\n return ['keydown', 'paste', 'cut']\n }\n}\n\n\nclass TextInputLegacyOpera extends TextInput {\n eventsIndicatingDeferValueChange () {\n // Opera 10 doesn't always fire the 'input' event for cut, paste, undo & drop operations.\n // We can try to catch some of those using 'keydown'.\n return ['keydown']\n }\n}\n\n\nclass TextInputLegacyFirefox extends TextInput {\n eventsIndicatingValueChange () {\n return [\n ...super.eventsIndicatingSyncValueChange(),\n // Firefox <= 3.6 doesn't fire the 'input' event when text is filled in through autocomplete\n 'DOMAutoComplete',\n // Firefox <=3.5 doesn't fire the 'input' event when text is dropped into the input.\n 'dragdrop', // < 3.5\n 'drop' // 3.5\n ]\n }\n}\n\n\nconst w = options.global // window / global\nif (w.navigator) {\n const parseVersion = (matches) => matches && parseFloat(matches[1])\n const userAgent = w.navigator.userAgent\n const isChrome = userAgent.match(/Chrome\\/([^ ]+)/)\n // Detect various browser versions because some old versions don't fully support the 'input' event\n operaVersion = w.opera && w.opera.version && parseInt(w.opera.version())\n safariVersion = parseVersion(userAgent.match(/Version\\/([^ ]+) Safari/))\n firefoxVersion = parseVersion(userAgent.match(/Firefox\\/([^ ]*)/))\n}\n\n\nexport const textInput =\n ieVersion === 8 ? TextInputIE8\n : ieVersion === 9 ? TextInputIE9\n : ieVersion ? TextInputIE\n : safariVersion && safariVersion < 5 ? TextInputLegacySafari\n : operaVersion < 11 ? TextInputLegacyOpera\n : firefoxVersion && firefoxVersion < 4 ? TextInputLegacyFirefox\n : TextInput\n"],
5
- "mappings": ";AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAQA;AAAA;AAAA;AAIA,IAAI,cAAc,cAAc,eAAe;AAO/C,MAAM,kBAAkB,eAAe;AAAA,MACjC,UAAW;AAAE,WAAO;AAAA,EAAY;AAAA,EAEpC,eAAgB,MAAM;AACpB,UAAM,GAAG,IAAI;AACb,SAAK,uBAAuB,KAAK,SAAS;AAE1C,QAAI,QAAQ,SAAS,KAAK,YAAY,gBAAgB;AAEpD,mBAAa,KAAK,YAAY,gBAAgB,CAAC,cAAc;AAC3D,YAAI,UAAU,MAAM,GAAG,CAAC,MAAM,SAAS;AACrC,eAAK,iBAAiB,UAAU,MAAM,CAAC,GAAG,kBAAkB;AAAA,QAC9D,OAAO;AACL,eAAK,iBAAiB,WAAW,aAAa;AAAA,QAChD;AAAA,MACF,CAAC;AAAA,IACH;AAEA,eAAW,aAAa,KAAK,gCAAgC,GAAG;AAC9D,WAAK,iBAAiB,WAAW,aAAa;AAAA,IAChD;AACA,eAAW,aAAa,KAAK,iCAAiC,GAAG;AAC/D,WAAK,iBAAiB,WAAW,kBAAkB;AAAA,IACrD;AACA,SAAK,SAAS,YAAY;AAAA,EAC5B;AAAA,EAEA,kCAAmC;AAIjC,WA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Q;AAClB,IAAI,EAAE,WAAW;AACf,QAAM,gBAAe,CAAC,YAAY,WAAW,WAAW,QAAQ,EAAE;AAClE,QAAM,YAAY,EAAE,UAAU;AAC9B,QAAM,WAAW,UAAU,MAAM,iBAAiB;AAElD,iBAAe,EAAE,SAAS,EAAE,MAAM,WAAW,SAAS,EAAE,MAAM,QAAQ,CAAC;AACvE,kBAAgB,cAAa,UAAU,MAAM,yBAAyB,CAAC;AACvE,mBAAiB,cAAa,UAAU,MAAM,kBAAkB,CAAC;AACnE;AAGO,aAAM,YACX,cAAc,IAAI,eAChB,cAAc,IAAI,eAClB,YAAY,cACZ,iBAAiB,gBAAgB,IAAI,wBACrC,eAAe,KAAK,uBACpB,kBAAkB,iBAAiB,IAAI,yBACvC;",
4
+ "sourcesContent": ["import { safeSetTimeout, options, arrayForEach } from '@tko/utils'\n\nimport { unwrap } from '@tko/observable'\n\nimport { BindingHandler } from '@tko/bind'\n\nexport const MSIE_REGEX = /MSIE ([^ ;]+)|rv:([^ )]+)/\n\nlet operaVersion, safariVersion, firefoxVersion, ieVersion\n\n/**\n * TextInput binding handler for modern browsers (legacy below).\n * @extends BindingHandler\n */\nclass TextInput extends BindingHandler {\n get aliases() {\n return 'textinput'\n }\n\n override $element: HTMLInputElement\n previousElementValue: any\n elementValueBeforeEvent?: ReturnType<typeof setTimeout>\n timeoutHandle?: ReturnType<typeof setTimeout>\n\n constructor(...args: [any]) {\n super(...args)\n this.previousElementValue = this.$element.value\n\n if (options.debug && (this.constructor as any)._forceUpdateOn) {\n // Provide a way for tests to specify exactly which events are bound\n arrayForEach((this.constructor as any)._forceUpdateOn, eventName => {\n if (eventName.slice(0, 5) === 'after') {\n this.addEventListener(eventName.slice(5), 'deferUpdateModel')\n } else {\n this.addEventListener(eventName, 'updateModel')\n }\n })\n }\n\n for (const eventName of this.eventsIndicatingSyncValueChange()) {\n this.addEventListener(eventName, 'updateModel')\n }\n for (const eventName of this.eventsIndicatingDeferValueChange()) {\n this.addEventListener(eventName, 'deferUpdateModel')\n }\n this.computed('updateView')\n }\n\n eventsIndicatingSyncValueChange() {\n // input: Default, modern handler\n // change: Catch programmatic updates of the value that fire this event.\n // blur: To deal with browsers that don't notify any kind of event for some changes (IE, Safari, etc.)\n return ['input', 'change', 'blur']\n }\n\n eventsIndicatingDeferValueChange(): any[] {\n return []\n }\n\n updateModel(event) {\n const element = this.$element\n clearTimeout(this.timeoutHandle)\n this.elementValueBeforeEvent = this.timeoutHandle = undefined\n const elementValue = element.value\n if (this.previousElementValue !== elementValue) {\n // Provide a way for tests to know exactly which event was processed\n if (options.debug && event) {\n ;(element as any)._ko_textInputProcessedEvent = event.type\n }\n this.previousElementValue = elementValue\n this.value = elementValue\n }\n }\n\n deferUpdateModel(event: any) {\n const element = this.$element\n if (!this.timeoutHandle) {\n // The elementValueBeforeEvent variable is set *only* during the brief gap between an\n // event firing and the updateModel function running. This allows us to ignore model\n // updates that are from the previous state of the element, usually due to techniques\n // such as rateLimit. Such updates, if not ignored, can cause keystrokes to be lost.\n this.elementValueBeforeEvent = element.value as any\n const handler = options.debug ? this.updateModel.bind(this, { type: event.type }) : this.updateModel\n this.timeoutHandle = safeSetTimeout(handler, 4)\n }\n }\n\n updateView() {\n let modelValue = unwrap(this.value)\n if (modelValue === null || modelValue === undefined) {\n modelValue = ''\n }\n if (this.elementValueBeforeEvent !== undefined && modelValue === this.elementValueBeforeEvent) {\n setTimeout(this.updateView.bind(this), 4)\n } else if (this.$element.value !== modelValue) {\n // Update the element only if the element and model are different. On some browsers, updating the value\n // will move the cursor to the end of the input, which would be bad while the user is typing.\n this.previousElementValue = modelValue // Make sure we ignore events (propertychange) that result from updating the value\n this.$element.value = modelValue\n this.previousElementValue = this.$element.value // In case the browser changes the value (see #2281)\n }\n }\n}\n\nclass TextInputIE extends TextInput {\n override eventsIndicatingSyncValueChange() {\n //keypress: All versions (including 11) of Internet Explorer have a bug that they don't generate an input or propertychange event when ESC is pressed\n return [...super.eventsIndicatingSyncValueChange(), 'keypress']\n }\n}\n\n// Safari <5 doesn't fire the 'input' event for <textarea> elements (it does fire 'textInput'\n// but only when typing). So we'll just catch as much as we can with keydown, cut, and paste.\nclass TextInputLegacySafari extends TextInput {\n override eventsIndicatingDeferValueChange() {\n return ['keydown', 'paste', 'cut']\n }\n}\n\nclass TextInputLegacyOpera extends TextInput {\n override eventsIndicatingDeferValueChange(): string[] {\n // Opera 10 doesn't always fire the 'input' event for cut, paste, undo & drop operations.\n // We can try to catch some of those using 'keydown'.\n return ['keydown']\n }\n}\n\nclass TextInputLegacyFirefox extends TextInput {\n eventsIndicatingValueChange(): string[] {\n return [\n ...super.eventsIndicatingSyncValueChange(),\n // Firefox <= 3.6 doesn't fire the 'input' event when text is filled in through autocomplete\n 'DOMAutoComplete',\n // Firefox <=3.5 doesn't fire the 'input' event when text is dropped into the input.\n 'dragdrop', // < 3.5\n 'drop' // 3.5\n ]\n }\n}\n\nconst w = options.global // window / global\nif (w.navigator) {\n const parseVersion = matches => matches && parseFloat(matches[1])\n const userAgent = w.navigator.userAgent\n const isChrome = userAgent.match(/Chrome\\/([^ ]+)/)\n if (!isChrome) {\n // Detect various browser versions because some old versions don't fully support the 'input' event\n operaVersion = w.opera && w.opera.version && parseInt(w.opera.version())\n safariVersion = parseVersion(userAgent.match(/Version\\/([^ ]+) Safari/))\n firefoxVersion = parseVersion(userAgent.match(/Firefox\\/([^ ]*)/))\n const ieMatch = userAgent.match(MSIE_REGEX)\n ieVersion = ieMatch && (parseFloat(ieMatch[1]) || parseFloat(ieMatch[2]))\n }\n}\n\nexport const textInput =\n ieVersion && ieVersion <= 11\n ? TextInputIE\n : safariVersion && safariVersion < 5\n ? TextInputLegacySafari\n : operaVersion && operaVersion < 11\n ? TextInputLegacyOpera\n : firefoxVersion && firefoxVersion < 4\n ? TextInputLegacyFirefox\n : TextInput\n"],
5
+ "mappings": ";;AAAA,SAAS,gBAAgB,SAAS,oBAAoB;AAEtD,SAAS,cAAc;AAEvB,SAAS,sBAAsB;A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AE,SAAS,EAAE,MAAM,WAAW,SAAS,EAAE,MAAM,QAAQ,CAAC;AACvE,oBAAgB,aAAa,UAAU,MAAM,yBAAyB,CAAC;AACvE,qBAAiB,aAAa,UAAU,MAAM,kBAAkB,CAAC;AACjE,UAAM,UAAU,UAAU,MAAM,UAAU;AAC1C,gBAAY,YAAY,WAAW,QAAQ,CAAC,CAAC,KAAK,WAAW,QAAQ,CAAC,CAAC;AAAA,EACzE;AACF;AAEO,aAAM,YACX,aAAa,aAAa,KACtB,cACA,iBAAiB,gBAAgB,IAC/B,wBACA,gBAAgB,eAAe,KAC7B,uBACA,kBAAkB,iBAAiB,IACjC,yBACA;",
6
6
  "names": []
7
7
  }
@@ -1,12 +1,10 @@
1
- // @tko/binding.core 🥊 4.0.0-beta1.3 ESM
2
- import {
3
- setElementName
4
- } from "@tko/utils";
5
- export var uniqueName = {
1
+ // @tko/binding.core 🥊 4.0.0 ESM
2
+ "use strict";
3
+ export const uniqueName = {
6
4
  init: function(element, valueAccessor) {
7
5
  if (valueAccessor()) {
8
- var name = "ko_unique_" + ++uniqueName.currentIndex;
9
- setElementName(element, name);
6
+ const name = "ko_unique_" + ++uniqueName.currentIndex;
7
+ element.name = name;
10
8
  }
11
9
  },
12
10
  currentIndex: 0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/uniqueName.ts"],
4
- "sourcesContent": ["\nimport {\n setElementName\n} from '@tko/utils'\n\nexport var uniqueName = {\n init: function (element, valueAccessor) {\n if (valueAccessor()) {\n var name = 'ko_unique_' + (++uniqueName.currentIndex)\n setElementName(element, name)\n }\n },\n currentIndex: 0\n}\n"],
5
- "mappings": ";AACA;AAAA;AAAA;AAIO,WAAI,aAAa;AAAA,EACtB,MAAM,SAAU,SAAS,eAAe;AACtC,QAAI,cAAc,GAAG;AACnB,UAAI,OAAO,eAAgB,EAAE,WAAW;AACxC,qBAAe,SAAS,IAAI;AAAA,IAC9B;AAAA,EACF;AAAA,EACA,cAAc;AAChB;",
4
+ "sourcesContent": ["export const uniqueName = {\n init: function (element, valueAccessor) {\n if (valueAccessor()) {\n const name = 'ko_unique_' + ++uniqueName.currentIndex\n element.name = name\n }\n },\n currentIndex: 0\n}\n"],
5
+ "mappings": ";;AAAO,aAAM,aAAa;AAAA,EACxB,MAAM,SAAU,SAAS,eAAe;AACtC,QAAI,cAAc,GAAG;AACnB,YAAM,OAAO,eAAe,EAAE,WAAW;AACzC,cAAQ,OAAO;AAAA,IACjB;AAAA,EACF;AAAA,EACA,cAAc;AAChB;",
6
6
  "names": []
7
7
  }
package/dist/using.js CHANGED
@@ -1,10 +1,9 @@
1
- // @tko/binding.core 🥊 4.0.0-beta1.3 ESM
2
- import {
3
- applyBindingsToDescendants
4
- } from "@tko/bind";
5
- export var using = {
6
- init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
7
- var innerContext = bindingContext.createChildContext(valueAccessor);
1
+ // @tko/binding.core 🥊 4.0.0 ESM
2
+ "use strict";
3
+ import { applyBindingsToDescendants } from "@tko/bind";
4
+ export const using = {
5
+ init: function(element, valueAccessor, _allBindings, _viewModel, bindingContext) {
6
+ const innerContext = bindingContext.createChildContext(valueAccessor);
8
7
  applyBindingsToDescendants(innerContext, element);
9
8
  return { controlsDescendantBindings: true };
10
9
  },
package/dist/using.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/using.ts"],
4
- "sourcesContent": ["import {\n applyBindingsToDescendants\n} from '@tko/bind'\n\nexport var using = {\n init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {\n var innerContext = bindingContext.createChildContext(valueAccessor)\n applyBindingsToDescendants(innerContext, element)\n return { controlsDescendantBindings: true }\n },\n allowVirtualElements: true\n}\n"],
5
- "mappings": ";AAAA;AAAA;AAAA;AAIO,WAAI,QAAQ;AAAA,EACjB,MAAM,SAAU,SAAS,eAAe,aAAa,WAAW,gBAAgB;AAC9E,QAAI,eAAe,eAAe,mBAAmB,aAAa;AAClE,+BAA2B,cAAc,OAAO;AAChD,WAAO,EAAE,4BAA4B,KAAK;AAAA,EAC5C;AAAA,EACA,sBAAsB;AACxB;",
4
+ "sourcesContent": ["import { applyBindingsToDescendants } from '@tko/bind'\n\nimport type { BindingContext, AllBindings } from '@tko/bind'\n\nexport const using = {\n init: function (element, valueAccessor, _allBindings: AllBindings, _viewModel, bindingContext: BindingContext) {\n const innerContext = bindingContext.createChildContext(valueAccessor)\n applyBindingsToDescendants(innerContext, element)\n return { controlsDescendantBindings: true }\n },\n allowVirtualElements: true\n}\n"],
5
+ "mappings": ";;AAAA,SAAS,kCAAkC;AAIpC,aAAM,QAAQ;AAAA,EACnB,MAAM,SAAU,SAAS,eAAe,cAA2B,YAAY,gBAAgC;AAC7G,UAAM,eAAe,eAAe,mBAAmB,aAAa;AACpE,+BAA2B,cAAc,OAAO;AAChD,WAAO,EAAE,4BAA4B,KAAK;AAAA,EAC5C;AAAA,EACA,sBAAsB;AACxB;",
6
6
  "names": []
7
7
  }
package/dist/value.js CHANGED
@@ -1,20 +1,9 @@
1
- // @tko/binding.core 🥊 4.0.0-beta1.3 ESM
2
- import {
3
- ieVersion,
4
- stringStartsWith,
5
- safeSetTimeout,
6
- tagNameLower,
7
- arrayForEach,
8
- selectExtensions
9
- } from "@tko/utils";
10
- import {
11
- unwrap,
12
- dependencyDetection
13
- } from "@tko/observable";
14
- import {
15
- applyBindingAccessorsToNode,
16
- BindingHandler
17
- } from "@tko/bind";
1
+ // @tko/binding.core 🥊 4.0.0 ESM
2
+ "use strict";
3
+ import { stringStartsWith, safeSetTimeout, tagNameLower, arrayForEach, selectExtensions } from "@tko/utils";
4
+ import { unwrap, dependencyDetection } from "@tko/observable";
5
+ import { applyBindingAccessorsToNode, BindingHandler } from "@tko/bind";
6
+ import { MSIE_REGEX } from "./textInput";
18
7
  export class value extends BindingHandler {
19
8
  static get after() {
20
9
  return ["options", "foreach", "template"];
@@ -52,8 +41,10 @@ export class value extends BindingHandler {
52
41
  const e = this.$element;
53
42
  return this.isInput && (e.type == "checkbox" || e.type == "radio");
54
43
  }
44
+ // Workaround for https://github.com/SteveSanderson/knockout/issues/122
45
+ // IE doesn't fire "change" events on textboxes if the user selects a value from its autocomplete list
55
46
  get ieAutoCompleteHackNeeded() {
56
- return ieVersion && isInputElement && this.$element.type == "text" && this.$element.autocomplete != "off" && (!this.$element.form || this.$element.form.autocomplete != "off");
47
+ return this.isInput && this.$element.type == "text" && this.$element.autocomplete != "off" && (!this.$element.form || this.$element.form.autocomplete != "off") && MSIE_REGEX.test(window.navigator.userAgent);
57
48
  }
58
49
  valueUpdateHandler() {
59
50
  this.elementValueBeforeEvent = null;
@@ -61,18 +52,21 @@ export class value extends BindingHandler {
61
52
  this.value = selectExtensions.readValue(this.$element);
62
53
  }
63
54
  registerEvent(eventName) {
64
- var handler = this.valueUpdateHandler.bind(this);
55
+ let handler = this.valueUpdateHandler.bind(this);
65
56
  if (stringStartsWith(eventName, "after")) {
66
57
  handler = () => {
67
58
  this.elementValueBeforeEvent = selectExtensions.readValue(this.$element);
68
59
  safeSetTimeout(this.valueUpdateHandler.bind(this), 0);
69
60
  };
70
- eventName = eventName.substring(5);
61
+ eventName = eventName.substring(
62
+ 5
63
+ /* 'after'.length */
64
+ );
71
65
  }
72
66
  this.addEventListener(eventName, handler);
73
67
  }
74
68
  updateFromModelForFile() {
75
- var newValue = unwrap(this.value);
69
+ const newValue = unwrap(this.value);
76
70
  if (newValue === null || newValue === void 0 || newValue === "") {
77
71
  this.$element.value = "";
78
72
  } else {
@@ -81,8 +75,8 @@ export class value extends BindingHandler {
81
75
  }
82
76
  updateFromModelForValue() {
83
77
  const element = this.$element;
84
- var newValue = unwrap(this.value);
85
- var elementValue = selectExtensions.readValue(element);
78
+ const newValue = unwrap(this.value);
79
+ const elementValue = selectExtensions.readValue(element);
86
80
  if (this.elementValueBeforeEvent !== null && newValue === this.elementValueBeforeEvent) {
87
81
  safeSetTimeout(this.updateFromModel.bind(this), 0);
88
82
  return;
package/dist/value.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/value.ts"],
4
- "sourcesContent": ["\nimport {\n ieVersion, stringStartsWith, safeSetTimeout, tagNameLower, arrayForEach,\n selectExtensions\n} from '@tko/utils'\n\nimport {\n unwrap, dependencyDetection\n} from '@tko/observable'\n\nimport {\n applyBindingAccessorsToNode, BindingHandler\n} from '@tko/bind'\n\nexport class value extends BindingHandler {\n static get after () { return ['options', 'foreach', 'template'] }\n\n constructor (...args) {\n super(...args)\n\n // If the value binding is placed on a radio/checkbox, then just pass through to checkedValue and quit\n if (this.isCheckboxOrRadio) {\n applyBindingAccessorsToNode(this.$element,\n { checkedValue: this.valueAccessor })\n return\n }\n\n this.propertyChangedFired = false\n this.elementValueBeforeEvent = null\n\n if (this.ieAutoCompleteHackNeeded) {\n this.addEventListener('propertyChange', () => this.propertyChangedFired = true)\n this.addEventListener('focus', () => this.propertyChangedFired = false)\n this.addEventListener('blur', () => this.propertyChangeFired &&\n this.valueUpdateHandler())\n }\n\n arrayForEach(this.eventsToCatch, eventName => this.registerEvent(eventName))\n\n if (this.isInput && this.$element.type === 'file') {\n this.updateFromModel = this.updateFromModelForFile\n } else {\n this.updateFromModel = this.updateFromModelForValue\n }\n\n this.computed('updateFromModel')\n }\n\n get eventsToCatch () {\n const requestedEventsToCatch = this.allBindings.get('valueUpdate')\n const requestedEventsArray = typeof requestedEventsToCatch === 'string' ?\n [requestedEventsToCatch] : requestedEventsToCatch || []\n return [...new Set(['change', ...requestedEventsArray])]\n }\n\n get isInput () {\n return tagNameLower(this.$element) === 'input'\n }\n\n get isCheckboxOrRadio () {\n const e = this.$element\n return this.isInput && (e.type == 'checkbox' || e.type == 'radio')\n }\n\n // Workaround for https://github.com/SteveSanderson/knockout/issues/122\n // IE doesn't fire \"change\" events on textboxes if the user selects a value from its autocomplete list\n get ieAutoCompleteHackNeeded () {\n return ieVersion && isInputElement &&\n this.$element.type == 'text' && this.$element.autocomplete != 'off' &&\n (!this.$element.form || this.$element.form.autocomplete != 'off')\n }\n\n valueUpdateHandler () {\n this.elementValueBeforeEvent = null\n this.propertyChangedFired = false\n this.value = selectExtensions.readValue(this.$element)\n }\n\n registerEvent (eventName) {\n // The syntax \"after<eventname>\" means \"run the handler asynchronously after the event\"\n // This is useful, for example, to catch \"keydown\" events after the browser has updated the control\n // (otherwise, selectExtensions.readValue(this) will receive the control's value *before* the key event)\n var handler = this.valueUpdateHandler.bind(this)\n if (stringStartsWith(eventName, 'after')) {\n handler = () => {\n // The elementValueBeforeEvent variable is non-null *only* during the brief gap between\n // a keyX event firing and the valueUpdateHandler running, which is scheduled to happen\n // at the earliest asynchronous opportunity. We store this temporary information so that\n // if, between keyX and valueUpdateHandler, the underlying model value changes separately,\n // we can overwrite that model value change with the value the user just typed. Otherwise,\n // techniques like rateLimit can trigger model changes at critical moments that will\n // override the user's inputs, causing keystrokes to be lost.\n this.elementValueBeforeEvent = selectExtensions.readValue(this.$element)\n safeSetTimeout(this.valueUpdateHandler.bind(this), 0)\n }\n eventName = eventName.substring(5 /* 'after'.length */)\n }\n this.addEventListener(eventName, handler)\n }\n\n updateFromModelForFile () {\n // For file input elements, can only write the empty string\n var newValue = unwrap(this.value)\n if (newValue === null || newValue === undefined || newValue === '') {\n this.$element.value = ''\n } else {\n dependencyDetection.ignore(this.valueUpdateHandler, this) // reset the model to match the element\n }\n }\n\n updateFromModelForValue () {\n const element = this.$element\n var newValue = unwrap(this.value)\n var elementValue = selectExtensions.readValue(element)\n\n if (this.elementValueBeforeEvent !== null && newValue === this.elementValueBeforeEvent) {\n safeSetTimeout(this.updateFromModel.bind(this), 0)\n return\n }\n\n if (newValue === elementValue && elementValue !== undefined) { return }\n\n if (tagNameLower(element) === 'select') {\n const allowUnset = this.allBindings.get('valueAllowUnset')\n selectExtensions.writeValue(element, newValue, allowUnset)\n\n if (!allowUnset && newValue !== selectExtensions.readValue(element)) {\n // If you try to set a model value that can't be represented in an already-populated dropdown, reject that change,\n // because you're not allowed to have a model value that disagrees with a visible UI selection.\n dependencyDetection.ignore(this.valueUpdateHandler, this)\n }\n } else {\n selectExtensions.writeValue(element, newValue)\n }\n }\n}\n"],
5
- "mappings": ";AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAIA;AAAA;AAAA;AAAA;AAIO,aAAM,cAAc,eAAe;AAAA,aAC7B,QAAS;AAAE,WAAO,CAAC,WAAW,WAAW,UAAU;AAAA,EAAE;AAAA,EAEhE,eAAgB,MAAM;AACpB,UAAM,GAAG,IAAI;AAGb,QAAI,KAAK,mBAAmB;AAC1B,kCAA4B,KAAK,UAC/B,EAAE,cAAc,KAAK,cAAc,CAAC;AACtC;AAAA,IACF;AAEA,SAAK,uBAAuB;AAC5B,SAAK,0BAA0B;AAE/B,QAAI,KAAK,0BAA0B;AACjC,WAAK,iBAAiB,kBAAkB,MAAM,KAAK,uBAAuB,IAAI;AAC9E,WAAK,iBAAiB,SAAS,MAAM,KAAK,uBAAuB,KAAK;AACtE,WAAK,iBAAiB,QAAQ,MAAM,KAAK,uBACvC,KAAK,mBAAmB,CAAC;AAAA,IAC7B;AAEA,iBAAa,KAAK,eAAe,eAAa,KAAK,cAAc,SAAS,CAAC;AAE3E,QAAI,KAAK,WAAW,KAAK,SAAS,SAAS,QAAQ;AACjD,WAAK,kBAAkB,KAAK;AAAA,IAC9B,OAAO;AACL,WAAK,kBAAkB,KAAK;AAAA,IAC9B;AAEA,SAAK,SAAS,iBAAiB;AAAA,EACjC;AAAA,MAEI,gBAAiB;AACnB,UAAM,yBAAyB,KAAK,YAAY,IAAI,aAAa;AACjE,UAAM,uBAAuB,OAAO,2BAA2B,WAC7D,CAAC,sBAAsB,IAAI,0BAA0B,CAAC;AACxD,WAAO,CAAC,GAAG,oBAAI,IAAI,CAAC,UAAU,GAAG,oBAAoB,CAAC,CAAC;AAAA,EACzD;AAAA,MAEI,UAAW;AAC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A,QAAI,aAAa,gBAAgB,iBAAiB,QAAW;AAAE;AAAA,IAAO;AAEtE,QAAI,aAAa,OAAO,MAAM,UAAU;AACtC,YAAM,aAAa,KAAK,YAAY,IAAI,iBAAiB;AACzD,uBAAiB,WAAW,SAAS,UAAU,UAAU;AAEzD,UAAI,CAAC,cAAc,aAAa,iBAAiB,UAAU,OAAO,GAAG;AAGnE,4BAAoB,OAAO,KAAK,oBAAoB,IAAI;AAAA,MAC1D;AAAA,IACF,OAAO;AACL,uBAAiB,WAAW,SAAS,QAAQ;AAAA,IAC/C;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { stringStartsWith, safeSetTimeout, tagNameLower, arrayForEach, selectExtensions } from '@tko/utils'\n\nimport { unwrap, dependencyDetection } from '@tko/observable'\n\nimport { applyBindingAccessorsToNode, BindingHandler } from '@tko/bind'\n\nimport { MSIE_REGEX } from './textInput'\n\nexport class value extends BindingHandler {\n static get after() {\n return ['options', 'foreach', 'template']\n }\n\n override $element: HTMLInputElement\n elementValueBeforeEvent: any\n propertyChangeFired: any\n propertyChangedFired: boolean\n updateFromModel: any\n constructor(...args: [any]) {\n super(...args)\n\n // If the value binding is placed on a radio/checkbox, then just pass through to checkedValue and quit\n if (this.isCheckboxOrRadio) {\n applyBindingAccessorsToNode(this.$element, { checkedValue: this.valueAccessor })\n return\n }\n\n this.propertyChangedFired = false\n this.elementValueBeforeEvent = null\n\n if (this.ieAutoCompleteHackNeeded) {\n this.addEventListener('propertyChange', () => (this.propertyChangedFired = true))\n this.addEventListener('focus', () => (this.propertyChangedFired = false))\n this.addEventListener('blur', () => this.propertyChangeFired && this.valueUpdateHandler())\n }\n\n arrayForEach(this.eventsToCatch, eventName => this.registerEvent(eventName))\n\n if (this.isInput && this.$element.type === 'file') {\n this.updateFromModel = this.updateFromModelForFile\n } else {\n this.updateFromModel = this.updateFromModelForValue\n }\n\n this.computed('updateFromModel')\n }\n\n get eventsToCatch() {\n const requestedEventsToCatch = this.allBindings.get('valueUpdate')\n const requestedEventsArray =\n typeof requestedEventsToCatch === 'string' ? [requestedEventsToCatch] : requestedEventsToCatch || []\n return [...new Set(['change', ...requestedEventsArray])]\n }\n\n get isInput() {\n return tagNameLower(this.$element) === 'input'\n }\n\n get isCheckboxOrRadio() {\n const e = this.$element\n return this.isInput && (e.type == 'checkbox' || e.type == 'radio')\n }\n\n // Workaround for https://github.com/SteveSanderson/knockout/issues/122\n // IE doesn't fire \"change\" events on textboxes if the user selects a value from its autocomplete list\n get ieAutoCompleteHackNeeded() {\n return (\n this.isInput\n && this.$element.type == 'text'\n && this.$element.autocomplete != 'off'\n && (!this.$element.form || this.$element.form.autocomplete != 'off')\n && MSIE_REGEX.test(window.navigator.userAgent) //IE detection (primarily for IE10/11)\n )\n }\n\n valueUpdateHandler() {\n this.elementValueBeforeEvent = null\n this.propertyChangedFired = false\n this.value = selectExtensions.readValue(this.$element)\n }\n\n registerEvent(eventName) {\n // The syntax \"after<eventname>\" means \"run the handler asynchronously after the event\"\n // This is useful, for example, to catch \"keydown\" events after the browser has updated the control\n // (otherwise, selectExtensions.readValue(this) will receive the control's value *before* the key event)\n let handler = this.valueUpdateHandler.bind(this)\n if (stringStartsWith(eventName, 'after')) {\n handler = () => {\n // The elementValueBeforeEvent variable is non-null *only* during the brief gap between\n // a keyX event firing and the valueUpdateHandler running, which is scheduled to happen\n // at the earliest asynchronous opportunity. We store this temporary information so that\n // if, between keyX and valueUpdateHandler, the underlying model value changes separately,\n // we can overwrite that model value change with the value the user just typed. Otherwise,\n // techniques like rateLimit can trigger model changes at critical moments that will\n // override the user's inputs, causing keystrokes to be lost.\n this.elementValueBeforeEvent = selectExtensions.readValue(this.$element)\n safeSetTimeout(this.valueUpdateHandler.bind(this), 0)\n }\n eventName = eventName.substring(5 /* 'after'.length */)\n }\n this.addEventListener(eventName, handler)\n }\n\n updateFromModelForFile() {\n // For file input elements, can only write the empty string\n const newValue = unwrap(this.value)\n if (newValue === null || newValue === undefined || newValue === '') {\n this.$element.value = ''\n } else {\n dependencyDetection.ignore(this.valueUpdateHandler, this) // reset the model to match the element\n }\n }\n\n updateFromModelForValue() {\n const element = this.$element\n const newValue = unwrap(this.value)\n const elementValue = selectExtensions.readValue(element)\n\n if (this.elementValueBeforeEvent !== null && newValue === this.elementValueBeforeEvent) {\n safeSetTimeout(this.updateFromModel.bind(this), 0)\n return\n }\n\n if (newValue === elementValue && elementValue !== undefined) {\n return\n }\n\n if (tagNameLower(element) === 'select') {\n const allowUnset = this.allBindings.get('valueAllowUnset')\n selectExtensions.writeValue(element, newValue, allowUnset)\n\n if (!allowUnset && newValue !== selectExtensions.readValue(element)) {\n // If you try to set a model value that can't be represented in an already-populated dropdown, reject that change,\n // because you're not allowed to have a model value that disagrees with a visible UI selection.\n dependencyDetection.ignore(this.valueUpdateHandler, this)\n }\n } else {\n selectExtensions.writeValue(element, newValue)\n }\n }\n}\n"],
5
+ "mappings": ";;AAAA,SAAS,kBAAkB,gBAAgB,cAAc,cAAc,wBAAwB;AAE/F,SAAS,QAAQ,2BAA2B;AAE5C,SAAS,6BAA6B,sBAAsB;AAE5D,SAAS,kBAAkB;AAEpB,aAAM,cAAc,eAAe;AAAA,EACxC,WAAW,QAAQ;AACjB,WAAO,CAAC,WAAW,WAAW,UAAU;AAAA,EAC1C;AAAA,EAOA,eAAe,MAAa;AAC1B,UAAM,GAAG,IAAI;AAGb,QAAI,KAAK,mBAAmB;AAC1B,kCAA4B,KAAK,UAAU,EAAE,cAAc,KAAK,cAAc,CAAC;AAC/E;AAAA,IACF;AAEA,SAAK,uBAAuB;AAC5B,SAAK,0BAA0B;AAE/B,QAAI,KAAK,0BAA0B;AACjC,WAAK,iBAAiB,kBAAkB,MAAO,KAAK,uBAAuB,IAAK;AAChF,WAAK,iBAAiB,SAAS,MAAO,KAAK,uBAAuB,KAAM;AACxE,WAAK,iBAAiB,QAAQ,MAAM,KAAK,uBAAuB,KAAK,mBAAmB,CAAC;AAAA,IAC3F;AAEA,iBAAa,KAAK,eAAe,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,QAAU;AAAA;AAAA,MAAsB;AAAA,IACxD;AACA,SAAK,iBAAiB,WAAW,OAAO;AAAA,EAC1C;AAAA,EAEA,yBAAyB;AAEvB,UAAM,WAAW,OAAO,KAAK,KAAK;AAClC,QAAI,aAAa,QAAQ,aAAa,UAAa,aAAa,IAAI;AAClE,WAAK,SAAS,QAAQ;AAAA,IACxB,OAAO;AACL,0BAAoB,OAAO,KAAK,oBAAoB,IAAI;AAAA,IAC1D;AAAA,EACF;AAAA,EAEA,0BAA0B;AACxB,UAAM,UAAU,KAAK;AACrB,UAAM,WAAW,OAAO,KAAK,KAAK;AAClC,UAAM,eAAe,iBAAiB,UAAU,OAAO;AAEvD,QAAI,KAAK,4BAA4B,QAAQ,aAAa,KAAK,yBAAyB;AACtF,qBAAe,KAAK,gBAAgB,KAAK,IAAI,GAAG,CAAC;AACjD;AAAA,IACF;AAEA,QAAI,aAAa,gBAAgB,iBAAiB,QAAW;AAC3D;AAAA,IACF;AAEA,QAAI,aAAa,OAAO,MAAM,UAAU;AACtC,YAAM,aAAa,KAAK,YAAY,IAAI,iBAAiB;AACzD,uBAAiB,WAAW,SAAS,UAAU,UAAU;AAEzD,UAAI,CAAC,cAAc,aAAa,iBAAiB,UAAU,OAAO,GAAG;AAGnE,4BAAoB,OAAO,KAAK,oBAAoB,IAAI;AAAA,MAC1D;AAAA,IACF,OAAO;AACL,uBAAiB,WAAW,SAAS,QAAQ;AAAA,IAC/C;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
package/dist/visible.js CHANGED
@@ -1,11 +1,10 @@
1
- // @tko/binding.core 🥊 4.0.0-beta1.3 ESM
2
- import {
3
- unwrap
4
- } from "@tko/observable";
5
- export var visible = {
1
+ // @tko/binding.core 🥊 4.0.0 ESM
2
+ "use strict";
3
+ import { unwrap } from "@tko/observable";
4
+ export const visible = {
6
5
  update: function(element, valueAccessor) {
7
- var value = unwrap(valueAccessor());
8
- var isCurrentlyVisible = !(element.style.display === "none");
6
+ const value = unwrap(valueAccessor());
7
+ const isCurrentlyVisible = !(element.style.display === "none");
9
8
  if (value && !isCurrentlyVisible) {
10
9
  element.style.display = "";
11
10
  } else if (!value && isCurrentlyVisible) {
@@ -13,7 +12,7 @@ export var visible = {
13
12
  }
14
13
  }
15
14
  };
16
- export var hidden = {
15
+ export const hidden = {
17
16
  update: function(element, valueAccessor) {
18
17
  visible.update.call(this, element, () => !unwrap(valueAccessor()));
19
18
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/visible.ts"],
4
- "sourcesContent": ["import {\n unwrap\n} from '@tko/observable'\n\nexport var visible = {\n update: function (element, valueAccessor) {\n var value = unwrap(valueAccessor())\n var isCurrentlyVisible = !(element.style.display === 'none')\n if (value && !isCurrentlyVisible) {\n element.style.display = ''\n } else if (!value && isCurrentlyVisible) {\n element.style.display = 'none'\n }\n }\n}\n\nexport var hidden = {\n update: function (element, valueAccessor) {\n visible.update.call(this, element, () => !unwrap(valueAccessor()))\n }\n}\n"],
5
- "mappings": ";AAAA;AAAA;AAAA;AAIO,WAAI,UAAU;AAAA,EACnB,QAAQ,SAAU,SAAS,eAAe;AACxC,QAAI,QAAQ,OAAO,cAAc,CAAC;AAClC,QAAI,qBAAqB,CAAE,SAAQ,MAAM,YAAY;AACrD,QAAI,SAAS,CAAC,oBAAoB;AAChC,cAAQ,MAAM,UAAU;AAAA,IAC1B,WAAW,CAAC,SAAS,oBAAoB;AACvC,cAAQ,MAAM,UAAU;AAAA,IAC1B;AAAA,EACF;AACF;AAEO,WAAI,SAAS;AAAA,EAClB,QAAQ,SAAU,SAAS,eAAe;AACxC,YAAQ,OAAO,KAAK,MAAM,SAAS,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAAA,EACnE;AACF;",
4
+ "sourcesContent": ["import { unwrap } from '@tko/observable'\n\nexport const visible = {\n update: function (element, valueAccessor) {\n const value = unwrap(valueAccessor())\n const isCurrentlyVisible = !(element.style.display === 'none')\n if (value && !isCurrentlyVisible) {\n element.style.display = ''\n } else if (!value && isCurrentlyVisible) {\n element.style.display = 'none'\n }\n }\n}\n\nexport const hidden = {\n update: function (element, valueAccessor) {\n visible.update.call(this, element, () => !unwrap(valueAccessor()))\n }\n}\n"],
5
+ "mappings": ";;AAAA,SAAS,cAAc;AAEhB,aAAM,UAAU;AAAA,EACrB,QAAQ,SAAU,SAAS,eAAe;AACxC,UAAM,QAAQ,OAAO,cAAc,CAAC;AACpC,UAAM,qBAAqB,EAAE,QAAQ,MAAM,YAAY;AACvD,QAAI,SAAS,CAAC,oBAAoB;AAChC,cAAQ,MAAM,UAAU;AAAA,IAC1B,WAAW,CAAC,SAAS,oBAAoB;AACvC,cAAQ,MAAM,UAAU;AAAA,IAC1B;AAAA,EACF;AACF;AAEO,aAAM,SAAS;AAAA,EACpB,QAAQ,SAAU,SAAS,eAAe;AACxC,YAAQ,OAAO,KAAK,MAAM,SAAS,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAAA,EACnE;AACF;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.0.0-beta1.3",
2
+ "version": "4.0.0",
3
3
  "name": "@tko/binding.core",
4
4
  "description": "TKO Core bindings",
5
5
  "module": "dist/binding.core.js",
@@ -23,10 +23,10 @@
23
23
  },
24
24
  "homepage": "https://tko.io",
25
25
  "dependencies": {
26
- "@tko/bind": "^4.0.0-beta1.3",
27
- "@tko/computed": "^4.0.0-beta1.3",
28
- "@tko/observable": "^4.0.0-beta1.3",
29
- "@tko/utils": "^4.0.0-beta1.3",
26
+ "@tko/bind": "^4.0.0",
27
+ "@tko/computed": "^4.0.0",
28
+ "@tko/observable": "^4.0.0",
29
+ "@tko/utils": "^4.0.0",
30
30
  "tslib": "^2.2.0"
31
31
  },
32
32
  "karma": {
@@ -46,6 +46,5 @@
46
46
  "import": "./dist/index.js"
47
47
  },
48
48
  "./helpers/*": "./helpers/*"
49
- },
50
- "gitHead": "a8843acb8ae085915115e53a4e057b30731c635e"
49
+ }
51
50
  }
package/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- The MIT License (MIT) - http://www.opensource.org/licenses/mit-license.php
2
-
3
- Copyright (c) Steven Sanderson, the Knockout.js team, and other contributors
4
- http://knockoutjs.com/
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in
14
- all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- THE SOFTWARE.
@@ -1,14 +0,0 @@
1
- // @tko/binding.core 🥊 4.0.0-beta1.3 ESM
2
- import {
3
- arrayFilter,
4
- arrayMap,
5
- selectExtensions
6
- } from "@tko/utils";
7
- export var matchers = {
8
- toHaveSelectedValues(expectedValues) {
9
- const selectedNodes = arrayFilter(this.actual.childNodes, (node) => node.selected);
10
- const selectedValues = arrayMap(selectedNodes, (node) => selectExtensions.readValue(node));
11
- this.actual = selectedValues;
12
- return this.env.equals_(selectedValues, expectedValues);
13
- }
14
- };
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/test-helper.ts"],
4
- "sourcesContent": ["\nimport {\n arrayFilter, arrayMap, selectExtensions\n} from '@tko/utils'\n\n/**\n * Note that these matchers cannot be included in jasmine-13-helpers.js.\n *\n * When using Rollup to create the tests, it creates multiple files e.g.\n * - optionsBehaviors\n * - checkedBehaviors\n * - ...\n *\n * This is problematic if domData access is imported via jasmine-13-helper,\n * since there'll be only one instance of domData imported i.e. the imports\n * should look like this:\n *\n * - optionsBehaviors\n * - utils/dom/data\n * - checkedBehaviors\n * - utils/dom/data/\n *\n * But what happens is that the singleton in data.js (dataStore) is created\n * in jasmine-13-helper, so when it's referenced it always comes from\n * the very first import. So in checkedBehaviors any reference to domData\n * would get it from the `dataStore` in optionsBehaviors (because it was\n * imported first).\n *\n * Or at least that seems to be the dragon here.\n */\n\nexport var matchers = {\n toHaveSelectedValues (expectedValues) {\n const selectedNodes = arrayFilter(this.actual.childNodes, node => node.selected)\n const selectedValues = arrayMap(selectedNodes, node => selectExtensions.readValue(node))\n this.actual = selectedValues // Fix explanatory message\n return this.env.equals_(selectedValues, expectedValues)\n }\n}\n"],
5
- "mappings": ";AACA;AAAA;AAAA;AAAA;AAAA;AA8BO,WAAI,WAAW;AAAA,EACpB,qBAAsB,gBAAgB;AACpC,UAAM,gBAAgB,YAAY,KAAK,OAAO,YAAY,UAAQ,KAAK,QAAQ;AAC/E,UAAM,iBAAiB,SAAS,eAAe,UAAQ,iBAAiB,UAAU,IAAI,CAAC;AACvF,SAAK,SAAS;AACd,WAAO,KAAK,IAAI,QAAQ,gBAAgB,cAAc;AAAA,EACxD;AACF;",
6
- "names": []
7
- }