@symbo.ls/scratch 3.8.7 → 3.8.9

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.
@@ -44,7 +44,7 @@ const setSVG = (val, key) => {
44
44
  const appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
45
45
  const CONFIG = (0, import_factory.getActiveConfig)();
46
46
  const lib = Object.keys(LIBRARY).length ? {} : CONFIG.svg;
47
- for (const key in LIBRARY) lib[key] = CONFIG.svg[key];
47
+ for (const key in LIBRARY) lib[key] = LIBRARY[key];
48
48
  appendSVG(lib, options);
49
49
  };
50
50
  const setSvgIcon = (val, key) => {
@@ -57,12 +57,12 @@ const setSvgIcon = (val, key) => {
57
57
  const appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
58
58
  const CONFIG = (0, import_factory.getActiveConfig)();
59
59
  const lib = Object.keys(LIBRARY).length ? {} : CONFIG.icons;
60
- for (const key in LIBRARY) lib[key] = CONFIG.icons[key];
60
+ for (const key in LIBRARY) lib[key] = LIBRARY[key];
61
61
  appendSVG(lib, options);
62
62
  };
63
- const createSVGSpriteElement = (options = { isRoot: true }) => {
64
- if (!import_utils.document || !import_utils.document.createElementNS) return;
65
- const svgElem = import_utils.document.createElementNS("http://www.w3.org/2000/svg", "svg");
63
+ const createSVGSpriteElement = (doc, options = { isRoot: true }) => {
64
+ if (!doc || !doc.createElementNS) return;
65
+ const svgElem = doc.createElementNS("http://www.w3.org/2000/svg", "svg");
66
66
  if (options.isRoot) {
67
67
  svgElem.setAttribute("aria-hidden", "true");
68
68
  svgElem.setAttribute("width", "0");
@@ -83,15 +83,24 @@ const appendSVG = (lib, options = DEF_OPTIONS) => {
83
83
  }
84
84
  const exists = doc.querySelector("#svgSprite");
85
85
  const SVGsprite = (0, import_utils2.generateSprite)(lib);
86
+ const spriteHtml = `<svg aria-hidden="true" width="0" height="0" style="position:absolute" id="svgSprite">${SVGsprite}</svg>`;
86
87
  if (exists) {
87
- const tempSVG = createSVGSpriteElement({ isRoot: false });
88
- tempSVG.innerHTML = SVGsprite;
89
- exists.append(...tempSVG.children);
88
+ if (doc.body.insertAdjacentHTML) {
89
+ exists.insertAdjacentHTML("beforeend", SVGsprite);
90
+ } else {
91
+ const tempSVG = createSVGSpriteElement(doc, { isRoot: false });
92
+ tempSVG.innerHTML = SVGsprite;
93
+ exists.append(...tempSVG.children);
94
+ }
90
95
  } else {
91
- const svgSpriteDOM = createSVGSpriteElement();
92
- if (svgSpriteDOM && svgSpriteDOM.nodeType) {
93
- svgSpriteDOM.innerHTML = SVGsprite;
94
- doc.body.prepend(svgSpriteDOM);
96
+ if (doc.body.insertAdjacentHTML) {
97
+ doc.body.insertAdjacentHTML("afterbegin", spriteHtml);
98
+ } else {
99
+ const svgSpriteDOM = createSVGSpriteElement(doc);
100
+ if (svgSpriteDOM && svgSpriteDOM.nodeType) {
101
+ svgSpriteDOM.innerHTML = SVGsprite;
102
+ doc.body.prepend(svgSpriteDOM);
103
+ }
95
104
  }
96
105
  }
97
106
  };
@@ -18,7 +18,7 @@ const setSVG = (val, key) => {
18
18
  const appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
19
19
  const CONFIG = getActiveConfig();
20
20
  const lib = Object.keys(LIBRARY).length ? {} : CONFIG.svg;
21
- for (const key in LIBRARY) lib[key] = CONFIG.svg[key];
21
+ for (const key in LIBRARY) lib[key] = LIBRARY[key];
22
22
  appendSVG(lib, options);
23
23
  };
24
24
  const setSvgIcon = (val, key) => {
@@ -31,12 +31,12 @@ const setSvgIcon = (val, key) => {
31
31
  const appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
32
32
  const CONFIG = getActiveConfig();
33
33
  const lib = Object.keys(LIBRARY).length ? {} : CONFIG.icons;
34
- for (const key in LIBRARY) lib[key] = CONFIG.icons[key];
34
+ for (const key in LIBRARY) lib[key] = LIBRARY[key];
35
35
  appendSVG(lib, options);
36
36
  };
37
- const createSVGSpriteElement = (options = { isRoot: true }) => {
38
- if (!document || !document.createElementNS) return;
39
- const svgElem = document.createElementNS("http://www.w3.org/2000/svg", "svg");
37
+ const createSVGSpriteElement = (doc, options = { isRoot: true }) => {
38
+ if (!doc || !doc.createElementNS) return;
39
+ const svgElem = doc.createElementNS("http://www.w3.org/2000/svg", "svg");
40
40
  if (options.isRoot) {
41
41
  svgElem.setAttribute("aria-hidden", "true");
42
42
  svgElem.setAttribute("width", "0");
@@ -57,15 +57,24 @@ const appendSVG = (lib, options = DEF_OPTIONS) => {
57
57
  }
58
58
  const exists = doc.querySelector("#svgSprite");
59
59
  const SVGsprite = generateSprite(lib);
60
+ const spriteHtml = `<svg aria-hidden="true" width="0" height="0" style="position:absolute" id="svgSprite">${SVGsprite}</svg>`;
60
61
  if (exists) {
61
- const tempSVG = createSVGSpriteElement({ isRoot: false });
62
- tempSVG.innerHTML = SVGsprite;
63
- exists.append(...tempSVG.children);
62
+ if (doc.body.insertAdjacentHTML) {
63
+ exists.insertAdjacentHTML("beforeend", SVGsprite);
64
+ } else {
65
+ const tempSVG = createSVGSpriteElement(doc, { isRoot: false });
66
+ tempSVG.innerHTML = SVGsprite;
67
+ exists.append(...tempSVG.children);
68
+ }
64
69
  } else {
65
- const svgSpriteDOM = createSVGSpriteElement();
66
- if (svgSpriteDOM && svgSpriteDOM.nodeType) {
67
- svgSpriteDOM.innerHTML = SVGsprite;
68
- doc.body.prepend(svgSpriteDOM);
70
+ if (doc.body.insertAdjacentHTML) {
71
+ doc.body.insertAdjacentHTML("afterbegin", spriteHtml);
72
+ } else {
73
+ const svgSpriteDOM = createSVGSpriteElement(doc);
74
+ if (svgSpriteDOM && svgSpriteDOM.nodeType) {
75
+ svgSpriteDOM.innerHTML = SVGsprite;
76
+ doc.body.prepend(svgSpriteDOM);
77
+ }
69
78
  }
70
79
  }
71
80
  };
@@ -2694,7 +2694,7 @@ var SmblsScratch = (() => {
2694
2694
  var appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
2695
2695
  const CONFIG2 = getActiveConfig();
2696
2696
  const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.svg;
2697
- for (const key in LIBRARY) lib[key] = CONFIG2.svg[key];
2697
+ for (const key in LIBRARY) lib[key] = LIBRARY[key];
2698
2698
  appendSVG(lib, options);
2699
2699
  };
2700
2700
  var setSvgIcon = (val, key) => {
@@ -2707,12 +2707,12 @@ var SmblsScratch = (() => {
2707
2707
  var appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
2708
2708
  const CONFIG2 = getActiveConfig();
2709
2709
  const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.icons;
2710
- for (const key in LIBRARY) lib[key] = CONFIG2.icons[key];
2710
+ for (const key in LIBRARY) lib[key] = LIBRARY[key];
2711
2711
  appendSVG(lib, options);
2712
2712
  };
2713
- var createSVGSpriteElement = (options = { isRoot: true }) => {
2714
- if (!document2 || !document2.createElementNS) return;
2715
- const svgElem = document2.createElementNS("http://www.w3.org/2000/svg", "svg");
2713
+ var createSVGSpriteElement = (doc, options = { isRoot: true }) => {
2714
+ if (!doc || !doc.createElementNS) return;
2715
+ const svgElem = doc.createElementNS("http://www.w3.org/2000/svg", "svg");
2716
2716
  if (options.isRoot) {
2717
2717
  svgElem.setAttribute("aria-hidden", "true");
2718
2718
  svgElem.setAttribute("width", "0");
@@ -2733,15 +2733,24 @@ var SmblsScratch = (() => {
2733
2733
  }
2734
2734
  const exists = doc.querySelector("#svgSprite");
2735
2735
  const SVGsprite = generateSprite(lib);
2736
+ const spriteHtml = `<svg aria-hidden="true" width="0" height="0" style="position:absolute" id="svgSprite">${SVGsprite}</svg>`;
2736
2737
  if (exists) {
2737
- const tempSVG = createSVGSpriteElement({ isRoot: false });
2738
- tempSVG.innerHTML = SVGsprite;
2739
- exists.append(...tempSVG.children);
2738
+ if (doc.body.insertAdjacentHTML) {
2739
+ exists.insertAdjacentHTML("beforeend", SVGsprite);
2740
+ } else {
2741
+ const tempSVG = createSVGSpriteElement(doc, { isRoot: false });
2742
+ tempSVG.innerHTML = SVGsprite;
2743
+ exists.append(...tempSVG.children);
2744
+ }
2740
2745
  } else {
2741
- const svgSpriteDOM = createSVGSpriteElement();
2742
- if (svgSpriteDOM && svgSpriteDOM.nodeType) {
2743
- svgSpriteDOM.innerHTML = SVGsprite;
2744
- doc.body.prepend(svgSpriteDOM);
2746
+ if (doc.body.insertAdjacentHTML) {
2747
+ doc.body.insertAdjacentHTML("afterbegin", spriteHtml);
2748
+ } else {
2749
+ const svgSpriteDOM = createSVGSpriteElement(doc);
2750
+ if (svgSpriteDOM && svgSpriteDOM.nodeType) {
2751
+ svgSpriteDOM.innerHTML = SVGsprite;
2752
+ doc.body.prepend(svgSpriteDOM);
2753
+ }
2745
2754
  }
2746
2755
  }
2747
2756
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@symbo.ls/scratch",
3
3
  "description": "Φ / CSS framework and methodology.",
4
4
  "author": "symbo.ls",
5
- "version": "3.8.7",
5
+ "version": "3.8.9",
6
6
  "files": [
7
7
  "dist",
8
8
  "*.js",
@@ -33,8 +33,8 @@
33
33
  "prepublish": "npm run build && npm run copy:package:cjs"
34
34
  },
35
35
  "dependencies": {
36
- "@domql/utils": "^3.8.7",
37
- "@symbo.ls/smbls-utils": "^3.8.7",
36
+ "@domql/utils": "^3.8.9",
37
+ "@symbo.ls/smbls-utils": "^3.8.9",
38
38
  "color-contrast-checker": "^1.5.0"
39
39
  },
40
40
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
package/src/system/svg.js CHANGED
@@ -23,7 +23,7 @@ export const appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
23
23
  const CONFIG = getActiveConfig()
24
24
 
25
25
  const lib = Object.keys(LIBRARY).length ? {} : CONFIG.svg
26
- for (const key in LIBRARY) lib[key] = CONFIG.svg[key]
26
+ for (const key in LIBRARY) lib[key] = LIBRARY[key]
27
27
 
28
28
  appendSVG(lib, options)
29
29
  }
@@ -39,14 +39,14 @@ export const appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
39
39
  const CONFIG = getActiveConfig()
40
40
 
41
41
  const lib = Object.keys(LIBRARY).length ? {} : CONFIG.icons
42
- for (const key in LIBRARY) lib[key] = CONFIG.icons[key]
42
+ for (const key in LIBRARY) lib[key] = LIBRARY[key]
43
43
 
44
44
  appendSVG(lib, options)
45
45
  }
46
46
 
47
- const createSVGSpriteElement = (options = { isRoot: true }) => {
48
- if (!document || !document.createElementNS) return
49
- const svgElem = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
47
+ const createSVGSpriteElement = (doc, options = { isRoot: true }) => {
48
+ if (!doc || !doc.createElementNS) return
49
+ const svgElem = doc.createElementNS('http://www.w3.org/2000/svg', 'svg')
50
50
  if (options.isRoot) {
51
51
  svgElem.setAttribute('aria-hidden', 'true')
52
52
  svgElem.setAttribute('width', '0')
@@ -71,16 +71,25 @@ const appendSVG = (lib, options = DEF_OPTIONS) => {
71
71
  const exists = doc.querySelector('#svgSprite')
72
72
  const SVGsprite = generateSprite(lib)
73
73
 
74
+ const spriteHtml = `<svg aria-hidden="true" width="0" height="0" style="position:absolute" id="svgSprite">${SVGsprite}</svg>`
75
+
74
76
  if (exists) {
75
- const tempSVG = createSVGSpriteElement({ isRoot: false })
76
- // const svgSpriteWithoutRoot = doc.createElement('template')
77
- tempSVG.innerHTML = SVGsprite
78
- exists.append(...tempSVG.children)
77
+ if (doc.body.insertAdjacentHTML) {
78
+ exists.insertAdjacentHTML('beforeend', SVGsprite)
79
+ } else {
80
+ const tempSVG = createSVGSpriteElement(doc, { isRoot: false })
81
+ tempSVG.innerHTML = SVGsprite
82
+ exists.append(...tempSVG.children)
83
+ }
79
84
  } else {
80
- const svgSpriteDOM = createSVGSpriteElement()
81
- if (svgSpriteDOM && svgSpriteDOM.nodeType) {
82
- svgSpriteDOM.innerHTML = SVGsprite
83
- doc.body.prepend(svgSpriteDOM)
85
+ if (doc.body.insertAdjacentHTML) {
86
+ doc.body.insertAdjacentHTML('afterbegin', spriteHtml)
87
+ } else {
88
+ const svgSpriteDOM = createSVGSpriteElement(doc)
89
+ if (svgSpriteDOM && svgSpriteDOM.nodeType) {
90
+ svgSpriteDOM.innerHTML = SVGsprite
91
+ doc.body.prepend(svgSpriteDOM)
92
+ }
84
93
  }
85
94
  }
86
95
  }