@xiee/utils 1.14.19 → 1.14.20
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/js/appendix.js +8 -3
- package/js/appendix.min.js +1 -1
- package/js/appendix.min.js.map +1 -1
- package/package.json +1 -1
package/js/appendix.js
CHANGED
|
@@ -5,11 +5,16 @@
|
|
|
5
5
|
const h = d.querySelector([1, 2, 3, 4, 5, 6].map(i => `h${i}.appendix`).join(','));
|
|
6
6
|
if (!h) return;
|
|
7
7
|
h.classList.remove('appendix');
|
|
8
|
-
// if
|
|
9
|
-
|
|
8
|
+
// test if two elements have same tag and class
|
|
9
|
+
function sameClass(e1, e2) {
|
|
10
|
+
return e1 && e2 && e1.tagName === e2.tagName && e1.className === e2.className;
|
|
11
|
+
}
|
|
12
|
+
// if h is in a wrapper whose prev/next sibling has the same class, simply add class to wrappers
|
|
13
|
+
const p1 = h.parentNode, p0 = p1.previousElementSibling;
|
|
14
|
+
let wrapper = sameClass(p1, p0), p2 = p1;
|
|
10
15
|
while (p1) {
|
|
11
16
|
p2 = p2.nextElementSibling;
|
|
12
|
-
if (!
|
|
17
|
+
if (!sameClass(p1, p2)) break;
|
|
13
18
|
p2.classList.add('appendix');
|
|
14
19
|
wrapper = true;
|
|
15
20
|
}
|
package/js/appendix.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(e=>{const
|
|
1
|
+
(e=>{const n=e.querySelector([1,2,3,4,5,6].map(e=>`h${e}.appendix`).join(","));if(!n)return;function a(e,n){return e&&n&&e.tagName===n.tagName&&e.className===n.className}n.classList.remove("appendix");const t=n.parentNode;let i=a(t,t.previousElementSibling),p=t;for(;t&&(p=p.nextElementSibling,a(t,p));)p.classList.add("appendix"),i=!0;if(i)return void t.classList.add("appendix");const d=e.createElement("div");for(d.className="appendix",d.append(n.cloneNode(!0));n.nextSibling;)d.append(n.nextSibling);"BODY"===n.parentNode.tagName?e.body.append(d):n.parentNode.after(d),n.remove()})(document);
|
|
2
2
|
//# sourceMappingURL=appendix.min.js.map
|
package/js/appendix.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["d","h","querySelector","map","i","join","classList","remove","p1","parentNode","
|
|
1
|
+
{"version":3,"names":["d","h","querySelector","map","i","join","sameClass","e1","e2","tagName","className","classList","remove","p1","parentNode","wrapper","previousElementSibling","p2","nextElementSibling","add","a","createElement","append","cloneNode","nextSibling","body","after","document"],"sources":["appendix.js"],"mappings":"AAGA,CAACA,IACC,MAAMC,EAAID,EAAEE,cAAc,CAAC,EAAG,EAAG,EAAG,EAAG,EAAG,GAAGC,IAAIC,GAAK,IAAIA,cAAcC,KAAK,MAC7E,IAAKJ,EAAG,OAGR,SAASK,EAAUC,EAAIC,GACrB,OAAOD,GAAMC,GAAMD,EAAGE,UAAYD,EAAGC,SAAWF,EAAGG,YAAcF,EAAGE,SACtE,CAJAT,EAAEU,UAAUC,OAAO,YAMnB,MAAMC,EAAKZ,EAAEa,WACb,IAAIC,EAAUT,EAAUO,EADMA,EAAGG,wBACAC,EAAKJ,EACtC,KAAOA,IACLI,EAAKA,EAAGC,mBACHZ,EAAUO,EAAII,KACnBA,EAAGN,UAAUQ,IAAI,YACjBJ,GAAU,EAEZ,GAAIA,EAEF,YADAF,EAAGF,UAAUQ,IAAI,YAInB,MAAMC,EAAIpB,EAAEqB,cAAc,OAG1B,IAFAD,EAAEV,UAAY,WACdU,EAAEE,OAAOrB,EAAEsB,WAAU,IACftB,EAAEuB,aACNJ,EAAEE,OAAOrB,EAAEuB,aAEY,SAAzBvB,EAAEa,WAAWL,QAAqBT,EAAEyB,KAAKH,OAAOF,GAAKnB,EAAEa,WAAWY,MAAMN,GACxEnB,EAAEW,QACH,EA9BD,CA8BGe","ignoreList":[]}
|