cec-nuxt-lib 0.7.5 → 0.7.7

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/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "cec-nuxt-lib",
3
3
  "configKey": "cec-nuxt-lib",
4
- "version": "0.7.5"
4
+ "version": "0.7.7"
5
5
  }
@@ -29,10 +29,12 @@ const toTitleCase = (str) => {
29
29
  .join(' ');
30
30
  };
31
31
 
32
- const toSentenceCase = (str) => {
32
+ const toSentenceCase = (str, notLast) => {
33
33
  return !str.length
34
34
  ? ''
35
- : `${str[0].toUpperCase()}${str.slice(1).replace(/[-_]/g, ' ')}`;
35
+ : notLast
36
+ ? `${str[0].toUpperCase()}${str.slice(1).replace(/[-_]/g, ' ')}`
37
+ : `${str[0].toUpperCase()}${str.slice(1).replace(/_/g, ' ')}`;
36
38
  };
37
39
 
38
40
  // Make arrays of the items in the paths
@@ -54,7 +56,9 @@ let hrefs =
54
56
  }, []);
55
57
 
56
58
  // Sentence case for the breadcrumb display
57
- const links = hrefs.map((e, i) => (!i ? 'Home' : toSentenceCase(e)));
59
+ const links = hrefs.map((e, i) =>
60
+ !i ? 'Home' : toSentenceCase(e, hrefs.length - 1 - i)
61
+ );
58
62
  </script>
59
63
  <template>
60
64
  <div class="cec-breadcrumb-bg">
@@ -132,10 +132,15 @@ onMounted(() => {
132
132
  if (hash) {
133
133
  hash = hash.toLowerCase().replace(/^#/, '').replace(/_/g, ' ');
134
134
  let l = Array.from(document.getElementsByTagName('LABEL')).filter((e) =>
135
- e.innerText.toLowerCase().includes(hash)
135
+ e.innerText.toLowerCase().startsWith(hash)
136
136
  );
137
- if (l.length && l[0].parentNode.tagName === 'SECTION') {
138
- let el = l[0].previousElementSibling;
137
+ let accs = l.filter(
138
+ (e) =>
139
+ e.parentNode.tagName === 'SECTION' ||
140
+ e.parentNode.tagName === 'TEMPLATE'
141
+ );
142
+ if (accs.length) {
143
+ let el = accs[0].previousElementSibling;
139
144
  if (el.tagName === 'INPUT') {
140
145
  el.checked = true;
141
146
  el.scrollIntoView();
@@ -146,7 +151,7 @@ onMounted(() => {
146
151
  let h3s = Array.from(document.getElementsByTagName('H3')).filter((e) =>
147
152
  e.innerHTML.toLowerCase().includes(hash)
148
153
  );
149
- if (h3s) {
154
+ if (h3s.length) {
150
155
  let parent = h3s[0].parentNode;
151
156
  if (parent.tagName === 'ARTICLE') {
152
157
  let el = parent.previousElementSibling;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.7.5",
2
+ "version": "0.7.7",
3
3
  "name": "cec-nuxt-lib",
4
4
  "description": "Nuxt components and assets",
5
5
  "license": "MIT",