@cajoa/dom 0.8.0 → 0.10.0
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/index.cjs +87 -2
- package/dist/index.js +87 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -32,11 +32,95 @@ module.exports = __toCommonJS(index_exports);
|
|
|
32
32
|
var import_core2 = require("@cajoa/core");
|
|
33
33
|
|
|
34
34
|
// src/dom-renderer.ts
|
|
35
|
+
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
36
|
+
var SVG_TAGS = /* @__PURE__ */ new Set([
|
|
37
|
+
"svg",
|
|
38
|
+
"g",
|
|
39
|
+
"defs",
|
|
40
|
+
"symbol",
|
|
41
|
+
"use",
|
|
42
|
+
"switch",
|
|
43
|
+
"view",
|
|
44
|
+
"desc",
|
|
45
|
+
"metadata",
|
|
46
|
+
"circle",
|
|
47
|
+
"ellipse",
|
|
48
|
+
"line",
|
|
49
|
+
"path",
|
|
50
|
+
"polygon",
|
|
51
|
+
"polyline",
|
|
52
|
+
"rect",
|
|
53
|
+
"image",
|
|
54
|
+
"text",
|
|
55
|
+
"tspan",
|
|
56
|
+
"textPath",
|
|
57
|
+
"foreignObject",
|
|
58
|
+
"linearGradient",
|
|
59
|
+
"radialGradient",
|
|
60
|
+
"stop",
|
|
61
|
+
"pattern",
|
|
62
|
+
"clipPath",
|
|
63
|
+
"mask",
|
|
64
|
+
"marker",
|
|
65
|
+
"filter",
|
|
66
|
+
"feBlend",
|
|
67
|
+
"feColorMatrix",
|
|
68
|
+
"feComponentTransfer",
|
|
69
|
+
"feComposite",
|
|
70
|
+
"feConvolveMatrix",
|
|
71
|
+
"feDiffuseLighting",
|
|
72
|
+
"feDisplacementMap",
|
|
73
|
+
"feDropShadow",
|
|
74
|
+
"feFlood",
|
|
75
|
+
"feGaussianBlur",
|
|
76
|
+
"feImage",
|
|
77
|
+
"feMerge",
|
|
78
|
+
"feMergeNode",
|
|
79
|
+
"feMorphology",
|
|
80
|
+
"feOffset",
|
|
81
|
+
"feSpecularLighting",
|
|
82
|
+
"feTile",
|
|
83
|
+
"feTurbulence",
|
|
84
|
+
"animate",
|
|
85
|
+
"animateMotion",
|
|
86
|
+
"animateTransform",
|
|
87
|
+
"set",
|
|
88
|
+
"mpath"
|
|
89
|
+
]);
|
|
35
90
|
var PROPERTIES = /* @__PURE__ */ new Set(["value", "checked", "selected", "indeterminate"]);
|
|
36
91
|
var ATTRIBUTE_NAMES = {
|
|
37
92
|
className: "class",
|
|
38
93
|
htmlFor: "for"
|
|
39
94
|
};
|
|
95
|
+
var SVG_ATTRIBUTE_NAMES = {
|
|
96
|
+
strokeWidth: "stroke-width",
|
|
97
|
+
strokeLinecap: "stroke-linecap",
|
|
98
|
+
strokeLinejoin: "stroke-linejoin",
|
|
99
|
+
strokeDasharray: "stroke-dasharray",
|
|
100
|
+
strokeDashoffset: "stroke-dashoffset",
|
|
101
|
+
strokeOpacity: "stroke-opacity",
|
|
102
|
+
strokeMiterlimit: "stroke-miterlimit",
|
|
103
|
+
fillOpacity: "fill-opacity",
|
|
104
|
+
fillRule: "fill-rule",
|
|
105
|
+
clipRule: "clip-rule",
|
|
106
|
+
clipPath: "clip-path",
|
|
107
|
+
stopColor: "stop-color",
|
|
108
|
+
stopOpacity: "stop-opacity",
|
|
109
|
+
floodColor: "flood-color",
|
|
110
|
+
floodOpacity: "flood-opacity",
|
|
111
|
+
textAnchor: "text-anchor",
|
|
112
|
+
dominantBaseline: "dominant-baseline",
|
|
113
|
+
fontSize: "font-size",
|
|
114
|
+
fontFamily: "font-family",
|
|
115
|
+
fontWeight: "font-weight",
|
|
116
|
+
letterSpacing: "letter-spacing",
|
|
117
|
+
markerStart: "marker-start",
|
|
118
|
+
markerMid: "marker-mid",
|
|
119
|
+
markerEnd: "marker-end",
|
|
120
|
+
vectorEffect: "vector-effect",
|
|
121
|
+
shapeRendering: "shape-rendering",
|
|
122
|
+
pointerEvents: "pointer-events"
|
|
123
|
+
};
|
|
40
124
|
var EVENT_NAMES = {
|
|
41
125
|
doubleclick: "dblclick"
|
|
42
126
|
};
|
|
@@ -92,7 +176,7 @@ function setProperty(el, name, value) {
|
|
|
92
176
|
}
|
|
93
177
|
}
|
|
94
178
|
var domRenderer = {
|
|
95
|
-
createElement: (tag) => document.createElement(tag),
|
|
179
|
+
createElement: (tag) => SVG_TAGS.has(tag) ? document.createElementNS(SVG_NS, tag) : document.createElement(tag),
|
|
96
180
|
createText: (value) => document.createTextNode(value),
|
|
97
181
|
createMarker: () => document.createComment(""),
|
|
98
182
|
createFragment: () => document.createDocumentFragment(),
|
|
@@ -124,7 +208,8 @@ var domRenderer = {
|
|
|
124
208
|
setProperty(e, key, value);
|
|
125
209
|
return;
|
|
126
210
|
}
|
|
127
|
-
const
|
|
211
|
+
const isSvg = e.namespaceURI === SVG_NS;
|
|
212
|
+
const name = (isSvg ? SVG_ATTRIBUTE_NAMES[key] : void 0) ?? ATTRIBUTE_NAMES[key] ?? key;
|
|
128
213
|
if (value == null || value === false) e.removeAttribute(name);
|
|
129
214
|
else e.setAttribute(name, value === true ? "" : String(value));
|
|
130
215
|
}
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,95 @@
|
|
|
2
2
|
import { setRenderer } from "@cajoa/core";
|
|
3
3
|
|
|
4
4
|
// src/dom-renderer.ts
|
|
5
|
+
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
6
|
+
var SVG_TAGS = /* @__PURE__ */ new Set([
|
|
7
|
+
"svg",
|
|
8
|
+
"g",
|
|
9
|
+
"defs",
|
|
10
|
+
"symbol",
|
|
11
|
+
"use",
|
|
12
|
+
"switch",
|
|
13
|
+
"view",
|
|
14
|
+
"desc",
|
|
15
|
+
"metadata",
|
|
16
|
+
"circle",
|
|
17
|
+
"ellipse",
|
|
18
|
+
"line",
|
|
19
|
+
"path",
|
|
20
|
+
"polygon",
|
|
21
|
+
"polyline",
|
|
22
|
+
"rect",
|
|
23
|
+
"image",
|
|
24
|
+
"text",
|
|
25
|
+
"tspan",
|
|
26
|
+
"textPath",
|
|
27
|
+
"foreignObject",
|
|
28
|
+
"linearGradient",
|
|
29
|
+
"radialGradient",
|
|
30
|
+
"stop",
|
|
31
|
+
"pattern",
|
|
32
|
+
"clipPath",
|
|
33
|
+
"mask",
|
|
34
|
+
"marker",
|
|
35
|
+
"filter",
|
|
36
|
+
"feBlend",
|
|
37
|
+
"feColorMatrix",
|
|
38
|
+
"feComponentTransfer",
|
|
39
|
+
"feComposite",
|
|
40
|
+
"feConvolveMatrix",
|
|
41
|
+
"feDiffuseLighting",
|
|
42
|
+
"feDisplacementMap",
|
|
43
|
+
"feDropShadow",
|
|
44
|
+
"feFlood",
|
|
45
|
+
"feGaussianBlur",
|
|
46
|
+
"feImage",
|
|
47
|
+
"feMerge",
|
|
48
|
+
"feMergeNode",
|
|
49
|
+
"feMorphology",
|
|
50
|
+
"feOffset",
|
|
51
|
+
"feSpecularLighting",
|
|
52
|
+
"feTile",
|
|
53
|
+
"feTurbulence",
|
|
54
|
+
"animate",
|
|
55
|
+
"animateMotion",
|
|
56
|
+
"animateTransform",
|
|
57
|
+
"set",
|
|
58
|
+
"mpath"
|
|
59
|
+
]);
|
|
5
60
|
var PROPERTIES = /* @__PURE__ */ new Set(["value", "checked", "selected", "indeterminate"]);
|
|
6
61
|
var ATTRIBUTE_NAMES = {
|
|
7
62
|
className: "class",
|
|
8
63
|
htmlFor: "for"
|
|
9
64
|
};
|
|
65
|
+
var SVG_ATTRIBUTE_NAMES = {
|
|
66
|
+
strokeWidth: "stroke-width",
|
|
67
|
+
strokeLinecap: "stroke-linecap",
|
|
68
|
+
strokeLinejoin: "stroke-linejoin",
|
|
69
|
+
strokeDasharray: "stroke-dasharray",
|
|
70
|
+
strokeDashoffset: "stroke-dashoffset",
|
|
71
|
+
strokeOpacity: "stroke-opacity",
|
|
72
|
+
strokeMiterlimit: "stroke-miterlimit",
|
|
73
|
+
fillOpacity: "fill-opacity",
|
|
74
|
+
fillRule: "fill-rule",
|
|
75
|
+
clipRule: "clip-rule",
|
|
76
|
+
clipPath: "clip-path",
|
|
77
|
+
stopColor: "stop-color",
|
|
78
|
+
stopOpacity: "stop-opacity",
|
|
79
|
+
floodColor: "flood-color",
|
|
80
|
+
floodOpacity: "flood-opacity",
|
|
81
|
+
textAnchor: "text-anchor",
|
|
82
|
+
dominantBaseline: "dominant-baseline",
|
|
83
|
+
fontSize: "font-size",
|
|
84
|
+
fontFamily: "font-family",
|
|
85
|
+
fontWeight: "font-weight",
|
|
86
|
+
letterSpacing: "letter-spacing",
|
|
87
|
+
markerStart: "marker-start",
|
|
88
|
+
markerMid: "marker-mid",
|
|
89
|
+
markerEnd: "marker-end",
|
|
90
|
+
vectorEffect: "vector-effect",
|
|
91
|
+
shapeRendering: "shape-rendering",
|
|
92
|
+
pointerEvents: "pointer-events"
|
|
93
|
+
};
|
|
10
94
|
var EVENT_NAMES = {
|
|
11
95
|
doubleclick: "dblclick"
|
|
12
96
|
};
|
|
@@ -62,7 +146,7 @@ function setProperty(el, name, value) {
|
|
|
62
146
|
}
|
|
63
147
|
}
|
|
64
148
|
var domRenderer = {
|
|
65
|
-
createElement: (tag) => document.createElement(tag),
|
|
149
|
+
createElement: (tag) => SVG_TAGS.has(tag) ? document.createElementNS(SVG_NS, tag) : document.createElement(tag),
|
|
66
150
|
createText: (value) => document.createTextNode(value),
|
|
67
151
|
createMarker: () => document.createComment(""),
|
|
68
152
|
createFragment: () => document.createDocumentFragment(),
|
|
@@ -94,7 +178,8 @@ var domRenderer = {
|
|
|
94
178
|
setProperty(e, key, value);
|
|
95
179
|
return;
|
|
96
180
|
}
|
|
97
|
-
const
|
|
181
|
+
const isSvg = e.namespaceURI === SVG_NS;
|
|
182
|
+
const name = (isSvg ? SVG_ATTRIBUTE_NAMES[key] : void 0) ?? ATTRIBUTE_NAMES[key] ?? key;
|
|
98
183
|
if (value == null || value === false) e.removeAttribute(name);
|
|
99
184
|
else e.setAttribute(name, value === true ? "" : String(value));
|
|
100
185
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cajoa/dom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Cajoa for the browser: DOM renderer and router.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"sideEffects": true,
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@cajoa/core": "^0.
|
|
29
|
+
"@cajoa/core": "^0.10.0"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|