@cocreate/element-prototype 1.0.0 → 1.1.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # [1.1.0](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.0.0...v1.1.0) (2022-11-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add @cocreate/crud-client ([ffeeef3](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/ffeeef3b3effb8fce00aeb5d17c4ffaf8a72ba13))
7
+ * crud.getAttr renamed to crud.getAttributes ([b51f672](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/b51f672c3919b82bf6c541b34506aad96ec2529f))
8
+
9
+
10
+ ### Features
11
+
12
+ * textarea attribute value support ([ce13d5a](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/ce13d5a4d7b483838f5b111cfd966e4f621846ee))
13
+
1
14
  # 1.0.0 (2022-10-29)
2
15
 
3
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/element-prototype",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
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",
@@ -61,6 +61,7 @@
61
61
  "webpack-log": "^3.0.1"
62
62
  },
63
63
  "dependencies": {
64
+ "@cocreate/crud-client": "^1.12.13",
64
65
  "@cocreate/docs": "^1.2.26",
65
66
  "@cocreate/hosting": "^1.2.22"
66
67
  }
package/src/getValue.js CHANGED
@@ -14,7 +14,7 @@ HTMLHeadingElement.prototype.getValue = function() {
14
14
  };
15
15
 
16
16
 
17
-
17
+ // ToDO: replace esle if with switch case
18
18
  const getValue = (element) => {
19
19
  let value = element.value;
20
20
  let prefix = element.getAttribute('value-prefix') || "";
@@ -32,7 +32,7 @@ const getValue = (element) => {
32
32
  else {
33
33
  value = element.checked;
34
34
  }
35
- }
35
+ }
36
36
  else if (element.type === "number") {
37
37
  value = Number(value);
38
38
  }
@@ -46,10 +46,16 @@ const getValue = (element) => {
46
46
  value.push(options[i].value);
47
47
  }
48
48
  }
49
- else if (element.tagName == 'INPUT' || element.tagName == 'TEXTAREA' || element.tagName == 'SELECT') {
49
+ else if (element.tagName == 'INPUT' || element.tagName == 'SELECT') {
50
50
  value = element.value;
51
51
  }
52
- else if (element.tagName === 'IFRAME') {
52
+ else if (element.tagName == 'TEXTAREA') {
53
+ if (element.hasAttribute('value'))
54
+ value = element.getAttribute('value');
55
+ else
56
+ value = element.value;
57
+ }
58
+ else if (element.t1agName === 'IFRAME') {
53
59
  value = element.srcdoc;
54
60
  }
55
61
  else if (element.hasAttribute('value')){
package/src/setValue.js CHANGED
@@ -1,3 +1,12 @@
1
+ import CRUD from '@cocreate/crud-client';
2
+
3
+ let crud
4
+ if(CRUD && CRUD.default)
5
+ crud = CRUD.default
6
+ else
7
+ crud = CRUD
8
+
9
+
1
10
  HTMLElement.prototype.setValue = function(value) {
2
11
  setValue(this, value)
3
12
  };
@@ -17,7 +26,7 @@ const setValue = (el, value) => {
17
26
  let valueType = el.getAttribute('value-type');
18
27
 
19
28
  if (el.tagName == 'INPUT' || el.tagName == 'TEXTAREA' || el.tagName == 'SELECT') {
20
- const {isCrdt} = crud.getAttr(el);
29
+ const {isCrdt} = crud.getAttributes(el);
21
30
  if (isCrdt == "true" || el.type === 'file') return;
22
31
 
23
32
  if (el.type == 'checkbox') {