@algolia/autocomplete-js 1.5.5 → 1.5.6

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.
@@ -142,8 +142,12 @@ export function createAutocompleteDom(_ref) {
142
142
  type: 'button',
143
143
  class: classNames.detachedCancelButton,
144
144
  textContent: translations.detachedCancelButtonText,
145
- onClick: function onClick(event) {
145
+ // Prevent `onTouchStart` from closing the panel
146
+ // since it should be initiated by `onClick` only
147
+ onTouchStart: function onTouchStart(event) {
146
148
  event.stopPropagation();
149
+ },
150
+ onClick: function onClick() {
147
151
  autocomplete.setIsOpen(false);
148
152
  setIsModalOpen(false);
149
153
  }
@@ -1,10 +1,17 @@
1
1
  /* eslint-disable */
2
2
 
3
+ /**
4
+ * Touch-specific event aliases
5
+ *
6
+ * See https://w3c.github.io/touch-events/#extensions-to-the-globaleventhandlers-mixin
7
+ */
8
+ var TOUCH_EVENTS_ALIASES = ['ontouchstart', 'ontouchend', 'ontouchmove', 'ontouchcancel'];
3
9
  /*
4
10
  * Taken from Preact
5
11
  *
6
12
  * See https://github.com/preactjs/preact/blob/6ab49d9020740127577bf4af66bf63f4af7f9fee/src/diff/props.js#L58-L151
7
13
  */
14
+
8
15
  function setStyle(style, key, value) {
9
16
  if (value === null) {
10
17
  style[key] = '';
@@ -50,7 +57,7 @@ export function setProperty(dom, name, value) {
50
57
  else if (name[0] === 'o' && name[1] === 'n') {
51
58
  useCapture = name !== (name = name.replace(/Capture$/, ''));
52
59
  nameLower = name.toLowerCase();
53
- if (nameLower in dom) name = nameLower;
60
+ if (nameLower in dom || TOUCH_EVENTS_ALIASES.includes(nameLower)) name = nameLower;
54
61
  name = name.slice(2);
55
62
  if (!dom._listeners) dom._listeners = {};
56
63
  dom._listeners[name] = value;
@@ -1,4 +1,4 @@
1
- /*! @algolia/autocomplete-js 1.5.5 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
1
+ /*! @algolia/autocomplete-js 1.5.6 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
4
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -311,7 +311,7 @@
311
311
 
312
312
  var noop = function noop() {};
313
313
 
314
- var version = '1.5.5';
314
+ var version = '1.5.6';
315
315
 
316
316
  var userAgents$1 = [{
317
317
  segment: 'autocomplete-core',
@@ -2675,11 +2675,18 @@
2675
2675
 
2676
2676
  /* eslint-disable */
2677
2677
 
2678
+ /**
2679
+ * Touch-specific event aliases
2680
+ *
2681
+ * See https://w3c.github.io/touch-events/#extensions-to-the-globaleventhandlers-mixin
2682
+ */
2683
+ var TOUCH_EVENTS_ALIASES = ['ontouchstart', 'ontouchend', 'ontouchmove', 'ontouchcancel'];
2678
2684
  /*
2679
2685
  * Taken from Preact
2680
2686
  *
2681
2687
  * See https://github.com/preactjs/preact/blob/6ab49d9020740127577bf4af66bf63f4af7f9fee/src/diff/props.js#L58-L151
2682
2688
  */
2689
+
2683
2690
  function setStyle(style, key, value) {
2684
2691
  if (value === null) {
2685
2692
  style[key] = '';
@@ -2725,7 +2732,7 @@
2725
2732
  else if (name[0] === 'o' && name[1] === 'n') {
2726
2733
  useCapture = name !== (name = name.replace(/Capture$/, ''));
2727
2734
  nameLower = name.toLowerCase();
2728
- if (nameLower in dom) name = nameLower;
2735
+ if (nameLower in dom || TOUCH_EVENTS_ALIASES.includes(nameLower)) name = nameLower;
2729
2736
  name = name.slice(2);
2730
2737
  if (!dom._listeners) dom._listeners = {};
2731
2738
  dom._listeners[name] = value;
@@ -2985,8 +2992,12 @@
2985
2992
  type: 'button',
2986
2993
  class: classNames.detachedCancelButton,
2987
2994
  textContent: translations.detachedCancelButtonText,
2988
- onClick: function onClick(event) {
2995
+ // Prevent `onTouchStart` from closing the panel
2996
+ // since it should be initiated by `onClick` only
2997
+ onTouchStart: function onTouchStart(event) {
2989
2998
  event.stopPropagation();
2999
+ },
3000
+ onClick: function onClick() {
2990
3001
  autocomplete.setIsOpen(false);
2991
3002
  setIsModalOpen(false);
2992
3003
  }