@cocreate/element-prototype 1.13.1 → 1.13.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.13.2](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.13.1...v1.13.2) (2023-11-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * if value is the same do not set ([ee8538d](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/ee8538d684ab759cc131e1f785b5d80f610557eb))
7
+ * try catch valueType object or json ([bdc6e8a](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/bdc6e8ae951c62351f70a20c9c85b329b5dae545))
8
+
1
9
  ## [1.13.1](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.13.0...v1.13.1) (2023-11-12)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/element-prototype",
3
- "version": "1.13.1",
3
+ "version": "1.13.2",
4
4
  "description": "A simple element-prototype component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "element-prototype",
package/src/getValue.js CHANGED
@@ -98,11 +98,14 @@ const getValue = (element) => {
98
98
  value = [value];
99
99
  }
100
100
 
101
- if (valueType == 'object' || valueType == 'json') {
102
- value = JSON.parse(value)
101
+ if (value && (valueType == 'object' || valueType == 'json')) {
102
+ try {
103
+ value = JSON.parse(value)
104
+ } catch (error) {
105
+ value = value
106
+ }
103
107
  }
104
108
 
105
-
106
109
  return value;
107
110
  };
108
111
 
package/src/setValue.js CHANGED
@@ -15,7 +15,6 @@ HTMLHeadingElement.prototype.setValue = function (value) {
15
15
 
16
16
  // TODO: check if using a a switch case will provide better performance
17
17
  const setValue = (el, value) => {
18
-
19
18
  if (value === null || value === undefined) return;
20
19
  if (el.hasAttribute('component') || el.hasAttribute('plugin'))
21
20
  return storage.set(el, value)
@@ -73,9 +72,12 @@ const setValue = (el, value) => {
73
72
  options[i].selected = "";
74
73
  }
75
74
  }
76
- } else
77
- el.value = value;
75
+ } else {
76
+ if (el.value === value)
77
+ return
78
78
 
79
+ el.value = value;
80
+ }
79
81
  dispatchEvents(el)
80
82
  } else if (el.tagName === 'IMG' || el.tagName === 'SOURCE') {
81
83
  el.src = value;