1
- /**
2
- * Parses href hash
3
- *
4
- * @param urlHash
5
- * @returns {*[] }
6
- */
7
1
const namespaces = [
8
2
'display_for_' ,
9
3
] ;
10
4
5
+ /**
6
+ * Change link's parent DOM element visibility to hidden
7
+ *
8
+ * @param el
9
+ */
11
10
function hideLink ( el ) {
12
11
if ( el . nodeType === 1 ) {
13
12
el . parentNode . hidden = true ;
14
13
}
15
14
}
16
15
16
+ /**
17
+ * Change link's parent DOM element visibility to visible
18
+ *
19
+ * @param el
20
+ */
17
21
function showLink ( el ) {
18
22
if ( el . nodeType === 1 ) {
19
23
el . parentNode . hidden = false ;
20
24
}
21
25
}
22
26
27
+ /**
28
+ * Removes link from DEM tree
29
+ *
30
+ * @param el
31
+ */
23
32
function removeLink ( el ) {
24
33
if ( el . nodeType === 1 && el . parentNode !== null ) {
25
34
el . parentNode . removeChild ( el ) ;
@@ -41,7 +50,6 @@ function parseHashTag(href) {
41
50
const hashTags = href . split ( '#' ) . slice ( 1 ) ;
42
51
43
52
if ( hashTags ) {
44
- // @TODO : optimize ( now it is going to be O(n^2) :/ )
45
53
namespaces . forEach ( ( ns ) => {
46
54
hashTags . forEach ( ( tag ) => {
47
55
const value = tag . split ( ns ) ;
@@ -60,8 +68,9 @@ function parseHashTag(href) {
60
68
/**
61
69
* Applies parsed hash tags based on conditions
62
70
*
63
- * @param aElement
64
- * @param hashTags
71
+ * @param aElement DOM element
72
+ * @param {object } hashTags parsed hash tags
73
+ * @param {function } callbackFn function executing logic based on parsed hash tags
65
74
*/
66
75
function applyConditions ( aElement , hashTags , callbackFn ) {
67
76
hashTags . forEach ( ( hashTag ) => {
@@ -73,7 +82,8 @@ function applyConditions(aElement, hashTags, callbackFn) {
73
82
/**
74
83
* Parses nav fragment; disable visible elements based on hash tags
75
84
*
76
- * @param navSections
85
+ * @param domEl DOM element
86
+ * @param {function } callbackFn function executing logic based on parsed hash tags
77
87
* @returns {* }
78
88
*/
79
89
function parseUrlHashTags ( domEl = 'header' , callbackFn = null ) {
0 commit comments