@danielgindi/dom-utils 1.0.5 → 1.0.8

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/lib.es6.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @danielgindi/dom-utils 1.0.5
2
+ * @danielgindi/dom-utils 1.0.8
3
3
  * git://github.com/danielgindi/dom-utils.git
4
4
  */
5
5
  /**
@@ -382,6 +382,11 @@ const isTimeString = (value) => {
382
382
  return /^-?(0?\.)?\d+m?s$/.test(value);
383
383
  };
384
384
 
385
+ /**
386
+ *
387
+ * @param {string} transition
388
+ * @return {{duration: number, delay: number, name: string, timingFunction: string?}}
389
+ */
385
390
  const parseSingleTransition = (transition) => {
386
391
  let parts = transition.split(/\s+/),
387
392
  name = parts[0],
@@ -405,8 +410,14 @@ const parseSingleTransition = (transition) => {
405
410
  };
406
411
  };
407
412
 
413
+ /**
414
+ *
415
+ * @param {string} transition
416
+ * @return {{duration: number, delay: number, name: string, timingFunction: string?}[]}
417
+ */
408
418
  const parseTransition = (transition) => {
409
- return transition.match(/([^,()]|\([^)]*\))+/g).map(value => value.trim()).filter(value => value.length > 0).map(parseSingleTransition);
419
+ if (!transition) return [];
420
+ return (transition.match(/([^,()]|\([^)]*\))+/g) ?? []).map(value => value.trim()).filter(value => value.length > 0).map(parseSingleTransition);
410
421
  };
411
422
 
412
423
  var Css = /*#__PURE__*/Object.freeze({
@@ -465,7 +476,7 @@ const setElementAttrs = function (el, attrs) {
465
476
  el.innerHTML = String(value);
466
477
  else if (key === 'css' && 'style' in el)
467
478
  setCssProps(el, value);
468
- else if (key === 'readOnly' || key === 'tabIndex' || key === 'textContent')
479
+ else if (key in el && key !== 'style')
469
480
  el[key] = value;
470
481
  else el.setAttribute(key, String(value));
471
482
  }
@@ -540,6 +551,13 @@ const next = function (el, selector) {
540
551
  } while (el !== null && el.nodeType === 1);
541
552
 
542
553
  return null;
554
+ };
555
+
556
+ const unwrapChildren = function (el) {
557
+ let parent = el.parentNode;
558
+ while (el.firstChild)
559
+ parent.insertBefore(el.firstChild, el);
560
+ parent.removeChild(el);
543
561
  };
544
562
 
545
563
  var Dom = /*#__PURE__*/Object.freeze({
@@ -548,7 +566,8 @@ var Dom = /*#__PURE__*/Object.freeze({
548
566
  setElementAttrs: setElementAttrs,
549
567
  closestUntil: closestUntil,
550
568
  prev: prev,
551
- next: next
569
+ next: next,
570
+ unwrapChildren: unwrapChildren
552
571
  });
553
572
 
554
573
  /**
@@ -1013,7 +1032,11 @@ const detectRtlScrollType = () => {
1013
1032
  type = 'default';
1014
1033
  } else {
1015
1034
  definer.scrollLeft = 1;
1016
- if (definer.scrollLeft === 0) {
1035
+
1036
+ // bug: on some machines, chrome will have a positive delta of less than 1.
1037
+ // a full scroll will still be in the negative direction.
1038
+ // let's use Math.floor() to account for that bug.
1039
+ if (Math.floor(definer.scrollLeft) === 0) {
1017
1040
  type = 'negative';
1018
1041
  }
1019
1042
  }