@cocreate/utils 1.7.3 → 1.7.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [1.7.6](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.7.5...v1.7.6) (2022-06-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * remove functon getAttributes ([162228d](https://github.com/CoCreate-app/CoCreate-utils/commit/162228ddd99bcdf64a59088bddf2a6216a911898))
7
+
8
+ ## [1.7.5](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.7.4...v1.7.5) (2022-06-24)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * check path for character < if exist clean up path to mak it in to a valid selector ([9321063](https://github.com/CoCreate-app/CoCreate-utils/commit/93210634425db2dff507919dd32415f0d7bdfc95))
14
+
15
+ ## [1.7.4](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.7.3...v1.7.4) (2022-06-18)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * bump dependencies ([779f302](https://github.com/CoCreate-app/CoCreate-utils/commit/779f3026942bded821eb58ed0631c254494ba9ab))
21
+
1
22
  ## [1.7.3](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.7.2...v1.7.3) (2022-06-12)
2
23
 
3
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/utils",
3
- "version": "1.7.3",
3
+ "version": "1.7.6",
4
4
  "description": "A simple utils component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "utils",
@@ -61,6 +61,6 @@
61
61
  "webpack-log": "^3.0.1"
62
62
  },
63
63
  "dependencies": {
64
- "@cocreate/docs": "^1.3.2"
64
+ "@cocreate/docs": "^1.3.3"
65
65
  }
66
66
  }
package/src/index.js CHANGED
@@ -20,13 +20,6 @@ function clickedElement() {
20
20
  }
21
21
  }
22
22
 
23
- export function getAttributes(element) {
24
- return element.getAttributeNames().reduce((attrMap, name) => {
25
- attrMap[name] = element.getAttribute(name);
26
- return attrMap;
27
- }, {});
28
- }
29
-
30
23
  export function parseTextToHtml(text) {
31
24
  let doc = new DOMParser().parseFromString(text, "text/html");
32
25
  if (doc.head.children[0]) return doc.head.children[0];
@@ -47,15 +40,15 @@ export function cssPath(node, container) {
47
40
  node = '';
48
41
  }
49
42
  else {
50
- let eid = node.getAttribute('eid');
51
- if(/{{\s*([\w\W]+)\s*}}/g.test(eid)) {
52
- eid = false;
53
- }
54
- if (eid) {
55
- pathSplit += `[eid="${eid}"]`;
56
- node = '';
57
- }
58
- else {
43
+ // let eid = node.getAttribute('eid');
44
+ // if(/{{\s*([\w\W]+)\s*}}/g.test(eid)) {
45
+ // eid = false;
46
+ // }
47
+ // if (eid) {
48
+ // pathSplit += `[eid="${eid}"]`;
49
+ // node = '';
50
+ // }
51
+ // else {
59
52
  // if (node.classList.length) {
60
53
  // node.classList.forEach((item) => {
61
54
  // if (item.indexOf(":") === -1) pathSplit += "." + item;
@@ -85,10 +78,21 @@ export function cssPath(node, container) {
85
78
  if (node == null || node.tagName == "HTML" || node.tagName == "DOM-PARSER" || node.nodeName == "#document" || node.hasAttribute('contenteditable'))
86
79
  node = '';
87
80
  }
88
- }
81
+ // }
89
82
  pathSplits.unshift(pathSplit);
90
83
  } while (node);
91
- return pathSplits.join(" > ");
84
+ let path = pathSplits.join(" > ")
85
+ if (path && path.includes('<')) {
86
+ let index = path.lastIndexOf(' >')
87
+ if (index != -1)
88
+ path = path.slice(0, index)
89
+ else{
90
+ index = path.lastIndexOf('<')
91
+ path = path.slice(0, index)
92
+ }
93
+ }
94
+
95
+ return path;
92
96
  }
93
97
 
94
98
  export function domParser(str) {
@@ -196,7 +200,6 @@ clickedElement();
196
200
 
197
201
  export default {
198
202
  parseTextToHtml,
199
- getAttributes,
200
203
  cssPath,
201
204
  domParser,
202
205
  queryFrameSelectorAll