@xiee/utils 1.2.1 → 1.2.3

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/center-img.js CHANGED
@@ -5,13 +5,13 @@
5
5
  tag = tags[i];
6
6
  var parent = tag.parentElement;
7
7
  // center an image if it is the only element of its parent
8
- if (parent.childNodes.length === 1) {
8
+ if (parent.childElementCount === 1) {
9
9
  // if there is a link on image, check grandparent
10
10
  var parentA = parent.nodeName === 'A';
11
11
  if (parentA) {
12
12
  parent = parent.parentElement;
13
- if (parent.childNodes.length != 1) continue;
14
- parent.firstChild.style.border = 'none';
13
+ if (parent.childElementCount != 1) continue;
14
+ parent.firstElementChild.style.border = 'none';
15
15
  }
16
16
  if (parent.nodeName === 'P') {
17
17
  parent.style.textAlign = 'center';
@@ -13,4 +13,14 @@
13
13
  }
14
14
  // scroll to the comments section when URL contains a hash #comment-...
15
15
  location.hash.match(/^#comment-[0-9]+$/) && a.scrollIntoView();
16
+ // create a new script and change attribute 'data-src' to 'src' (to actually load the script)
17
+ const s = a.querySelector('script[data-src]');
18
+ if (!s) return;
19
+ const r = s.dataset.src, s2 = d.createElement('script'), b = s.attributes;
20
+ for (let i = 0; i < b.length; i++) {
21
+ s2.setAttribute(b[i].name, b[i].value);
22
+ }
23
+ s2.src = r;
24
+ s.remove();
25
+ a.appendChild(s2);
16
26
  })(document);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiee/utils",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Miscellaneous tools and utilities to manipulate HTML pages",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"