@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/lib/Css.js CHANGED
@@ -378,6 +378,11 @@ const isTimeString = (value) => {
378
378
  return /^-?(0?\.)?\d+m?s$/.test(value);
379
379
  };
380
380
 
381
+ /**
382
+ *
383
+ * @param {string} transition
384
+ * @return {{duration: number, delay: number, name: string, timingFunction: string?}}
385
+ */
381
386
  const parseSingleTransition = (transition) => {
382
387
  let parts = transition.split(/\s+/),
383
388
  name = parts[0],
@@ -401,8 +406,14 @@ const parseSingleTransition = (transition) => {
401
406
  };
402
407
  };
403
408
 
409
+ /**
410
+ *
411
+ * @param {string} transition
412
+ * @return {{duration: number, delay: number, name: string, timingFunction: string?}[]}
413
+ */
404
414
  const parseTransition = (transition) => {
405
- return transition.match(/([^,()]|\([^)]*\))+/g).map(value => value.trim()).filter(value => value.length > 0).map(parseSingleTransition);
415
+ if (!transition) return [];
416
+ return (transition.match(/([^,()]|\([^)]*\))+/g) ?? []).map(value => value.trim()).filter(value => value.length > 0).map(parseSingleTransition);
406
417
  };
407
418
 
408
419
  export {
package/lib/Dom.js CHANGED
@@ -38,7 +38,7 @@ const setElementAttrs = function (el, attrs) {
38
38
  el.innerHTML = String(value);
39
39
  else if (key === 'css' && 'style' in el)
40
40
  setCssProps(el, value);
41
- else if (key === 'readOnly' || key === 'tabIndex' || key === 'textContent')
41
+ else if (key in el && key !== 'style')
42
42
  el[key] = value;
43
43
  else el.setAttribute(key, String(value));
44
44
  }
@@ -115,10 +115,18 @@ const next = function (el, selector) {
115
115
  return null;
116
116
  };
117
117
 
118
+ const unwrapChildren = function (el) {
119
+ let parent = el.parentNode;
120
+ while (el.firstChild)
121
+ parent.insertBefore(el.firstChild, el);
122
+ parent.removeChild(el);
123
+ };
124
+
118
125
  export {
119
126
  createElement,
120
127
  setElementAttrs,
121
128
  closestUntil,
122
129
  prev,
123
130
  next,
131
+ unwrapChildren,
124
132
  };
@@ -21,7 +21,11 @@ const detectRtlScrollType = () => {
21
21
  type = 'default';
22
22
  } else {
23
23
  definer.scrollLeft = 1;
24
- if (definer.scrollLeft === 0) {
24
+
25
+ // bug: on some machines, chrome will have a positive delta of less than 1.
26
+ // a full scroll will still be in the negative direction.
27
+ // let's use Math.floor() to account for that bug.
28
+ if (Math.floor(definer.scrollLeft) === 0) {
25
29
  type = 'negative';
26
30
  }
27
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielgindi/dom-utils",
3
- "version": "1.0.5",
3
+ "version": "1.0.8",
4
4
  "description": "A collection of dom utilities. So you can work natively with the dom without dom frameworks.",
5
5
  "main": "dist/lib.cjs.min.js",
6
6
  "module": "lib/index.js",
@@ -28,19 +28,19 @@
28
28
  "homepage": "https://github.com/danielgindi/dom-utils#readme",
29
29
  "license": "MIT",
30
30
  "devDependencies": {
31
- "@babel/core": "^7.15.8",
32
- "@babel/preset-env": "^7.15.8",
33
- "@babel/runtime": "^7.15.3",
31
+ "@babel/core": "^7.17.8",
32
+ "@babel/preset-env": "^7.16.11",
33
+ "@babel/runtime": "^7.17.8",
34
+ "@rollup/plugin-babel": "^5.3.1",
35
+ "@rollup/plugin-commonjs": "^21.0.3",
36
+ "@rollup/plugin-node-resolve": "^13.1.3",
34
37
  "babelify": "^10.0.0",
35
- "core-js": "^3.18.2",
38
+ "core-js": "^3.21.1",
36
39
  "eslint": "^7.32.0",
37
- "fs-extra": "^10.0.0",
38
- "husky": "^7.0.2",
40
+ "fs-extra": "^10.0.1",
41
+ "husky": "^7.0.4",
39
42
  "pinst": "^2.1.4",
40
- "rollup": "^2.58.0",
41
- "@rollup/plugin-babel": "^5.3.0",
42
- "@rollup/plugin-commonjs": "^21.0.0",
43
- "@rollup/plugin-node-resolve": "^13.0.4",
43
+ "rollup": "^2.70.1",
44
44
  "rollup-plugin-terser": "^7.0.2"
45
45
  },
46
46
  "dependencies": {}