@symbo.ls/scratch 3.8.7 → 3.8.8
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/cjs/system/svg.js +19 -10
- package/dist/esm/system/svg.js +19 -10
- package/dist/iife/index.js +19 -10
- package/package.json +3 -3
- package/src/system/svg.js +20 -11
package/dist/cjs/system/svg.js
CHANGED
|
@@ -60,9 +60,9 @@ const appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
|
60
60
|
for (const key in LIBRARY) lib[key] = CONFIG.icons[key];
|
|
61
61
|
appendSVG(lib, options);
|
|
62
62
|
};
|
|
63
|
-
const createSVGSpriteElement = (options = { isRoot: true }) => {
|
|
64
|
-
if (!
|
|
65
|
-
const svgElem =
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
doc
|
|
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
|
};
|
package/dist/esm/system/svg.js
CHANGED
|
@@ -34,9 +34,9 @@ const appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
|
34
34
|
for (const key in LIBRARY) lib[key] = CONFIG.icons[key];
|
|
35
35
|
appendSVG(lib, options);
|
|
36
36
|
};
|
|
37
|
-
const createSVGSpriteElement = (options = { isRoot: true }) => {
|
|
38
|
-
if (!
|
|
39
|
-
const svgElem =
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
doc
|
|
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
|
};
|
package/dist/iife/index.js
CHANGED
|
@@ -2710,9 +2710,9 @@ var SmblsScratch = (() => {
|
|
|
2710
2710
|
for (const key in LIBRARY) lib[key] = CONFIG2.icons[key];
|
|
2711
2711
|
appendSVG(lib, options);
|
|
2712
2712
|
};
|
|
2713
|
-
var createSVGSpriteElement = (options = { isRoot: true }) => {
|
|
2714
|
-
if (!
|
|
2715
|
-
const svgElem =
|
|
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
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
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
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
doc
|
|
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.
|
|
5
|
+
"version": "3.8.8",
|
|
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.
|
|
37
|
-
"@symbo.ls/smbls-utils": "^3.8.
|
|
36
|
+
"@domql/utils": "^3.8.8",
|
|
37
|
+
"@symbo.ls/smbls-utils": "^3.8.8",
|
|
38
38
|
"color-contrast-checker": "^1.5.0"
|
|
39
39
|
},
|
|
40
40
|
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
package/src/system/svg.js
CHANGED
|
@@ -44,9 +44,9 @@ export const appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
|
|
|
44
44
|
appendSVG(lib, options)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const createSVGSpriteElement = (options = { isRoot: true }) => {
|
|
48
|
-
if (!
|
|
49
|
-
const svgElem =
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
doc
|
|
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
|
}
|