@bbn/bbn 1.0.409 → 1.0.411
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/bbn.js +1 -1
- package/dist/bbn.js.map +1 -1
- package/dist/fn/html/getPath.js +9 -7
- package/dist/fn/string/treatForHash.js +8 -3
- package/package.json +1 -1
package/dist/fn/html/getPath.js
CHANGED
|
@@ -11,6 +11,9 @@ export default function getPath(element) {
|
|
|
11
11
|
var path = '',
|
|
12
12
|
//node = $(element),
|
|
13
13
|
node = element, done = 0;
|
|
14
|
+
if (element.id) {
|
|
15
|
+
return '#' + element.id;
|
|
16
|
+
}
|
|
14
17
|
var _loop_1 = function () {
|
|
15
18
|
//let realNode = node[0],
|
|
16
19
|
var realNode = node, name_1 = realNode.localName;
|
|
@@ -19,7 +22,8 @@ export default function getPath(element) {
|
|
|
19
22
|
if (realNode === document.body)
|
|
20
23
|
return "break";
|
|
21
24
|
if (realNode.id) {
|
|
22
|
-
|
|
25
|
+
path = '#' + realNode.id + ' ' + path;
|
|
26
|
+
done = 1;
|
|
23
27
|
}
|
|
24
28
|
if (!done) {
|
|
25
29
|
if (realNode.className && realNode.className !== ' ') {
|
|
@@ -30,25 +34,23 @@ export default function getPath(element) {
|
|
|
30
34
|
//var parent = node.parent(),
|
|
31
35
|
var parent_1 = node.parentNode,
|
|
32
36
|
//sameTagSiblings = parent.children(name);
|
|
33
|
-
sameTagSiblings = parent_1.children.filter(function (val) {
|
|
37
|
+
sameTagSiblings = Array.from(parent_1.children).filter(function (val) {
|
|
34
38
|
return val.tagName === name_1;
|
|
35
39
|
});
|
|
36
40
|
if (sameTagSiblings.length > 1) {
|
|
37
41
|
//var allSiblings = parent.children(),
|
|
38
|
-
var allSiblings = parent_1.children,
|
|
42
|
+
var allSiblings = Array.from(parent_1.children),
|
|
39
43
|
//index = allSiblings.index(realNode) + 1;
|
|
40
44
|
index = allSiblings.indexOf(realNode) + 1;
|
|
41
45
|
if (index > 1) {
|
|
42
46
|
name_1 += ':nth-child(' + index + ')';
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
|
-
path
|
|
49
|
+
path = name_1 + (path ? '>' + path : '');
|
|
46
50
|
node = parent_1;
|
|
47
51
|
};
|
|
48
|
-
while (node.
|
|
52
|
+
while (node && (node !== document.body)) {
|
|
49
53
|
var state_1 = _loop_1();
|
|
50
|
-
if (typeof state_1 === "object")
|
|
51
|
-
return state_1.value;
|
|
52
54
|
if (state_1 === "break")
|
|
53
55
|
break;
|
|
54
56
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import isDom from '../type/isDom.js';
|
|
2
|
+
import getPath from '../html/getPath.js';
|
|
3
|
+
import isCp from '../type/isCp.js';
|
|
2
4
|
/**
|
|
3
5
|
* Makes a string out of anything
|
|
4
6
|
* @param {*} value
|
|
@@ -42,16 +44,19 @@ export default function treatForHash(value, depth, level, visited, fn) {
|
|
|
42
44
|
}
|
|
43
45
|
else if (![undefined, Object, Array, null].includes(value === null || value === void 0 ? void 0 : value.constructor)) {
|
|
44
46
|
if (isDom(value)) {
|
|
45
|
-
if (value
|
|
47
|
+
if (isCp(value)) {
|
|
48
|
+
value = "__BBN_CP__" + value.$cid;
|
|
49
|
+
}
|
|
50
|
+
else if (value.bbnId) {
|
|
46
51
|
value =
|
|
47
52
|
"__BBN_DOM__" + value.tagName + "/" + value.bbnId + value.bbnHash;
|
|
48
53
|
}
|
|
49
54
|
else {
|
|
50
|
-
value = "__BBN_DOM__" + value
|
|
55
|
+
value = "__BBN_DOM__" + getPath(value);
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
58
|
else {
|
|
54
|
-
value = "
|
|
59
|
+
value = "__BBN_UNKNOWN_OBJECT__" + value.constructor.toString();
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
62
|
else if (bbn.fn.isArray(value)) {
|