@samitouri / QOS-React / commits / 79a62b09ea

Consolidate SVG config to avoid some duplication

Paul O’Shannessy committed Mar 9, 2016 at 13:41 UTC 79a62b09eac4de5b19aa9e9858a23be7aecec310
1 file changed +264 -398
src/renderers/dom/shared/SVGDOMPropertyConfig.js
+264 -398
@@ -16,258 +16,263 @@ var NS = {
16 xml: 'http://www.w3.org/XML/1998/namespace',
17 };
18
19 +// We use attributes for everything SVG so let's avoid some duplication and run
20 +// code instead.
21 +
22 +var ATTRS = {
23 + accentHeight: 'accent-height',
24 + accumulate: null,
25 + additive: null,
26 + alignmentBaseline: 'alignment-baseline',
27 + allowReorder: 'allowReorder',
28 + alphabetic: null,
29 + amplitude: null,
30 + arabicForm: 'arabic-form',
31 + ascent: null,
32 + attributeName: 'attributeName',
33 + attributeType: 'attributeType',
34 + autoReverse: 'autoReverse',
35 + azimuth: null,
36 + baseFrequency: 'baseFrequency',
37 + baseProfile: 'baseProfile',
38 + baselineShift: 'baseline-shift',
39 + bbox: null,
40 + begin: null,
41 + bias: null,
42 + by: null,
43 + calcMode: 'calcMode',
44 + capHeight: 'cap-height',
45 + class: null,
46 + clip: null,
47 + clipPath: 'clip-path',
48 + clipRule: 'clip-rule',
49 + clipPathUnits: 'clipPathUnits',
50 + color: null,
51 + colorInterpolation: 'color-interpolation',
52 + colorInterpolationFilters: 'color-interpolation-filters',
53 + colorProfile: 'color-profile',
54 + colorRendering: 'color-rendering',
55 + contentScriptType: 'contentScriptType',
56 + contentStyleType: 'contentStyleType',
57 + cursor: null,
58 + cx: null,
59 + cy: null,
60 + d: null,
61 + decelerate: null,
62 + descent: null,
63 + diffuseConstant: 'diffuseConstant',
64 + direction: null,
65 + display: null,
66 + divisor: null,
67 + dominantBaseline: 'dominant-baseline',
68 + dur: null,
69 + dx: null,
70 + dy: null,
71 + edgeMode: 'edgeMode',
72 + elevation: null,
73 + enableBackground: 'enable-background',
74 + end: null,
75 + exponent: null,
76 + externalResourcesRequired: 'externalResourcesRequired',
77 + fill: null,
78 + fillOpacity: 'fill-opacity',
79 + fillRule: 'fill-rule',
80 + filter: null,
81 + filterRes: 'filterRes',
82 + filterUnits: 'filterUnits',
83 + floodColor: 'flood-color',
84 + floodOpacity: 'flood-opacity',
85 + fontFamily: 'font-family',
86 + fontSize: 'font-size',
87 + fontSizeAdjust: 'font-size-adjust',
88 + fontStretch: 'font-stretch',
89 + fontStyle: 'font-style',
90 + fontVariant: 'font-variant',
91 + fontWeight: 'font-weight',
92 + format: null,
93 + from: null,
94 + fx: null,
95 + fy: null,
96 + g1: null,
97 + g2: null,
98 + glyphName: 'glyph-name',
99 + glyphOrientationHorizontal: 'glyph-orientation-horizontal',
100 + glyphOrientationVertical: 'glyph-orientation-vertical',
101 + glyphRef: 'glyphRef',
102 + gradientTransform: 'gradientTransform',
103 + gradientUnits: 'gradientUnits',
104 + hanging: null,
105 + height: null,
106 + horizAdvX: 'horiz-adv-x',
107 + horizOriginX: 'horiz-origin-x',
108 + id: null,
109 + ideographic: null,
110 + imageRendering: 'image-rendering',
111 + in: null,
112 + in2: null,
113 + intercept: null,
114 + k: null,
115 + k1: null,
116 + k2: null,
117 + k3: null,
118 + k4: null,
119 + kernelMatrix: 'kernelMatrix',
120 + kernelUnitLength: 'kernelUnitLength',
121 + kerning: null,
122 + keyPoints: 'keyPoints',
123 + keySplines: 'keySplines',
124 + keyTimes: 'keyTimes',
125 + lang: null,
126 + lengthAdjust: 'lengthAdjust',
127 + letterSpacing: 'letter-spacing',
128 + lightingColor: 'lighting-color',
129 + limitingConeAngle: 'limitingConeAngle',
130 + local: null,
131 + markerEnd: 'marker-end',
132 + markerMid: 'marker-mid',
133 + markerStart: 'marker-start',
134 + markerHeight: 'markerHeight',
135 + markerUnits: 'markerUnits',
136 + markerWidth: 'markerWidth',
137 + mask: null,
138 + maskContentUnits: 'maskContentUnits',
139 + maskUnits: 'maskUnits',
140 + mathematical: null,
141 + max: null,
142 + media: null,
143 + method: null,
144 + min: null,
145 + mode: null,
146 + name: null,
147 + numOctaves: 'numOctaves',
148 + offset: null,
149 + opacity: null,
150 + operator: null,
151 + order: null,
152 + orient: null,
153 + orientation: null,
154 + origin: null,
155 + overflow: null,
156 + overlinePosition: 'overline-position',
157 + overlineThickness: 'overline-thickness',
158 + paintOrder: 'paint-order',
159 + panose1: 'panose-1',
160 + pathLength: 'pathLength',
161 + patternContentUnits: 'patternContentUnits',
162 + patternTransform: 'patternTransform',
163 + patternUnits: 'patternUnits',
164 + pointerEvents: 'pointer-events',
165 + points: null,
166 + pointsAtX: 'pointsAtX',
167 + pointsAtY: 'pointsAtY',
168 + pointsAtZ: 'pointsAtZ',
169 + preserveAlpha: 'preserveAlpha',
170 + preserveAspectRatio: 'preserveAspectRatio',
171 + primitiveUnits: 'primitiveUnits',
172 + r: null,
173 + radius: null,
174 + refX: 'refX',
175 + refY: 'refY',
176 + renderingIntent: 'rendering-intent',
177 + repeatCount: 'repeatCount',
178 + repeatDur: 'repeatDur',
179 + requiredExtensions: 'requiredExtensions',
180 + requiredFeatures: 'requiredFeatures',
181 + restart: null,
182 + result: null,
183 + rotate: null,
184 + rx: null,
185 + ry: null,
186 + scale: null,
187 + seed: null,
188 + shapeRendering: 'shape-rendering',
189 + slope: null,
190 + spacing: null,
191 + specularConstant: 'specularConstant',
192 + specularExponent: 'specularExponent',
193 + speed: null,
194 + spreadMethod: 'spreadMethod',
195 + startOffset: 'startOffset',
196 + stdDeviation: 'stdDeviation',
197 + stemh: null,
198 + stemv: null,
199 + stitchTiles: 'stitchTiles',
200 + stopColor: 'stop-color',
201 + stopOpacity: 'stop-opacity',
202 + strikethroughPosition: 'strikethrough-position',
203 + strikethroughThickness: 'strikethrough-thickness',
204 + string: null,
205 + stroke: null,
206 + strokeDasharray: 'stroke-dasharray',
207 + strokeDashoffset: 'stroke-dashoffset',
208 + strokeLinecap: 'stroke-linecap',
209 + strokeLinejoin: 'stroke-linejoin',
210 + strokeMiterlimit: 'stroke-miterlimit',
211 + strokeOpacity: 'stroke-opacity',
212 + strokeWidth: 'stroke-width',
213 + style: null,
214 + surfaceScale: 'surfaceScale',
215 + systemLanguage: 'systemLanguage',
216 + tableValues: 'tableValues',
217 + target: null,
218 + targetX: 'targetX',
219 + targetY: 'targetY',
220 + textAnchor: 'text-anchor',
221 + textDecoration: 'text-decoration',
222 + textRendering: 'text-rendering',
223 + textLength: 'textLength',
224 + to: null,
225 + transform: null,
226 + type: null,
227 + u1: null,
228 + u2: null,
229 + underlinePosition: 'underline-position',
230 + underlineThickness: 'underline-thickness',
231 + unicode: null,
232 + unicodeBidi: 'unicode-bidi',
233 + unicodeRange: 'unicode-range',
234 + unitsPerEm: 'units-per-em',
235 + vAlphabetic: 'v-alphabetic',
236 + vHanging: 'v-hanging',
237 + vIdeographic: 'v-ideographic',
238 + vMathematical: 'v-mathematical',
239 + values: null,
240 + version: null,
241 + vertAdvY: 'vert-adv-y',
242 + vertOriginX: 'vert-origin-x',
243 + vertOriginY: 'vert-origin-y',
244 + viewBox: 'viewBox',
245 + viewTarget: 'viewTarget',
246 + visibility: null,
247 + width: null,
248 + widths: null,
249 + wordSpacing: 'word-spacing',
250 + writingMode: 'writing-mode',
251 + x: null,
252 + xHeight: 'x-height',
253 + x1: null,
254 + x2: null,
255 + xChannelSelector: 'xChannelSelector',
256 + xlinkActuate: 'xlink:actuate',
257 + xlinkArcrole: 'xlink:arcrole',
258 + xlinkHref: 'xlink:href',
259 + xlinkRole: 'xlink:role',
260 + xlinkShow: 'xlink:show',
261 + xlinkTitle: 'xlink:title',
262 + xlinkType: 'xlink:type',
263 + xmlBase: 'xml:base',
264 + xmlLang: 'xml:lang',
265 + xmlSpace: 'xml:space',
266 + y: null,
267 + y1: null,
268 + y2: null,
269 + yChannelSelector: 'yChannelSelector',
270 + z: null,
271 + zoomAndPan: 'zoomAndPan',
272 +};
273 +
274 var SVGDOMPropertyConfig = {
20 - Properties: {
21 - accentHeight: null,
22 - accumulate: null,
23 - additive: null,
24 - alignmentBaseline: null,
25 - allowReorder: null,
26 - alphabetic: null,
27 - amplitude: null,
28 - arabicForm: null,
29 - ascent: null,
30 - attributeName: null,
31 - attributeType: null,
32 - autoReverse: null,
33 - azimuth: null,
34 - baseFrequency: null,
35 - baselineShift: null,
36 - baseProfile: null,
37 - bbox: null,
38 - begin: null,
39 - bias: null,
40 - by: null,
41 - calcMode: null,
42 - capHeight: null,
43 - class: null,
44 - clip: null,
45 - clipPath: null,
46 - clipPathUnits: null,
47 - clipRule: null,
48 - color: null,
49 - colorInterpolation: null,
50 - colorInterpolationFilters: null,
51 - colorProfile: null,
52 - colorRendering: null,
53 - contentScriptType: null,
54 - contentStyleType: null,
55 - cursor: null,
56 - cx: null,
57 - cy: null,
58 - d: null,
59 - decelerate: null,
60 - descent: null,
61 - diffuseConstant: null,
62 - direction: null,
63 - display: null,
64 - divisor: null,
65 - dominantBaseline: null,
66 - dur: null,
67 - dx: null,
68 - dy: null,
69 - edgeMode: null,
70 - elevation: null,
71 - enableBackground: null,
72 - end: null,
73 - exponent: null,
74 - externalResourcesRequired: null,
75 - fill: null,
76 - fillOpacity: null,
77 - fillRule: null,
78 - filter: null,
79 - filterRes: null,
80 - filterUnits: null,
81 - floodColor: null,
82 - floodOpacity: null,
83 - fontFamily: null,
84 - fontSize: null,
85 - fontSizeAdjust: null,
86 - fontStretch: null,
87 - fontStyle: null,
88 - fontVariant: null,
89 - fontWeight: null,
90 - format: null,
91 - from: null,
92 - fx: null,
93 - fy: null,
94 - g1: null,
95 - g2: null,
96 - glyphName: null,
97 - glyphOrientationHorizontal: null,
98 - glyphOrientationVertical: null,
99 - glyphRef: null,
100 - gradientTransform: null,
101 - gradientUnits: null,
102 - hanging: null,
103 - height: null,
104 - horizAdvX: null,
105 - horizOriginX: null,
106 - id: null,
107 - ideographic: null,
108 - imageRendering: null,
109 - in: null,
110 - in2: null,
111 - intercept: null,
112 - k: null,
113 - k1: null,
114 - k2: null,
115 - k3: null,
116 - k4: null,
117 - kernelMatrix: null,
118 - kernelUnitLength: null,
119 - kerning: null,
120 - keyPoints: null,
121 - keySplines: null,
122 - keyTimes: null,
123 - lang: null,
124 - lengthAdjust: null,
125 - letterSpacing: null,
126 - lightingColor: null,
127 - limitingConeAngle: null,
128 - local: null,
129 - markerEnd: null,
130 - markerHeight: null,
131 - markerMid: null,
132 - markerStart: null,
133 - markerUnits: null,
134 - markerWidth: null,
135 - mask: null,
136 - maskContentUnits: null,
137 - maskUnits: null,
138 - mathematical: null,
139 - max: null,
140 - media: null,
141 - method: null,
142 - min: null,
143 - mode: null,
144 - name: null,
145 - numOctaves: null,
146 - offset: null,
147 - opacity: null,
148 - operator: null,
149 - order: null,
150 - orient: null,
151 - orientation: null,
152 - origin: null,
153 - overflow: null,
154 - overlinePosition: null,
155 - overlineThickness: null,
156 - paintOrder: null,
157 - panose1: null,
158 - pathLength: null,
159 - patternContentUnits: null,
160 - patternTransform: null,
161 - patternUnits: null,
162 - pointerEvents: null,
163 - points: null,
164 - pointsAtX: null,
165 - pointsAtY: null,
166 - pointsAtZ: null,
167 - preserveAlpha: null,
168 - preserveAspectRatio: null,
169 - primitiveUnits: null,
170 - r: null,
171 - radius: null,
172 - refX: null,
173 - refY: null,
174 - renderingIntent: null,
175 - repeatCount: null,
176 - repeatDur: null,
177 - requiredExtensions: null,
178 - requiredFeatures: null,
179 - restart: null,
180 - result: null,
181 - rotate: null,
182 - rx: null,
183 - ry: null,
184 - scale: null,
185 - seed: null,
186 - shapeRendering: null,
187 - slope: null,
188 - spacing: null,
189 - specularConstant: null,
190 - specularExponent: null,
191 - speed: null,
192 - spreadMethod: null,
193 - startOffset: null,
194 - stdDeviation: null,
195 - stemh: null,
196 - stemv: null,
197 - stitchTiles: null,
198 - stopColor: null,
199 - stopOpacity: null,
200 - strikethroughPosition: null,
201 - strikethroughThickness: null,
202 - string: null,
203 - stroke: null,
204 - strokeDasharray: null,
205 - strokeDashoffset: null,
206 - strokeLinecap: null,
207 - strokeLinejoin: null,
208 - strokeMiterlimit: null,
209 - strokeOpacity: null,
210 - strokeWidth: null,
211 - style: null,
212 - surfaceScale: null,
213 - systemLanguage: null,
214 - tableValues: null,
215 - target: null,
216 - targetX: null,
217 - targetY: null,
218 - textAnchor: null,
219 - textDecoration: null,
220 - textLength: null,
221 - textRendering: null,
222 - to: null,
223 - transform: null,
224 - type: null,
225 - u1: null,
226 - u2: null,
227 - underlinePosition: null,
228 - underlineThickness: null,
229 - unicode: null,
230 - unicodeBidi: null,
231 - unicodeRange: null,
232 - unitsPerEm: null,
233 - vAlphabetic: null,
234 - values: null,
235 - version: null,
236 - vertAdvY: null,
237 - vertOriginX: null,
238 - vertOriginY: null,
239 - vHanging: null,
240 - vIdeographic: null,
241 - viewBox: null,
242 - viewTarget: null,
243 - visibility: null,
244 - vMathematical: null,
245 - width: null,
246 - widths: null,
247 - wordSpacing: null,
248 - writingMode: null,
249 - x: null,
250 - x1: null,
251 - x2: null,
252 - xChannelSelector: null,
253 - xHeight: null,
254 - xlinkActuate: null,
255 - xlinkArcrole: null,
256 - xlinkHref: null,
257 - xlinkRole: null,
258 - xlinkShow: null,
259 - xlinkTitle: null,
260 - xlinkType: null,
261 - xmlBase: null,
262 - xmlLang: null,
263 - xmlSpace: null,
264 - y: null,
265 - y1: null,
266 - y2: null,
267 - yChannelSelector: null,
268 - z: null,
269 - zoomAndPan: null,
270 - },
275 + Properties: {},
276 DOMAttributeNamespaces: {
277 xlinkActuate: NS.xlink,
278 xlinkArcrole: NS.xlink,
@@ -280,153 +285,14 @@ var SVGDOMPropertyConfig = {
285 xmlLang: NS.xml,
286 xmlSpace: NS.xml,
287 },
283 - DOMAttributeNames: {
284 - accentHeight: 'accent-height',
285 - alignmentBaseline: 'alignment-baseline',
286 - allowReorder: 'allowReorder',
287 - arabicForm: 'arabic-form',
288 - attributeName: 'attributeName',
289 - attributeType: 'attributeType',
290 - autoReverse: 'autoReverse',
291 - baseFrequency: 'baseFrequency',
292 - baselineShift: 'baseline-shift',
293 - baseProfile: 'baseProfile',
294 - calcMode: 'calcMode',
295 - capHeight: 'cap-height',
296 - clipPath: 'clip-path',
297 - clipPathUnits: 'clipPathUnits',
298 - clipRule: 'clip-rule',
299 - colorInterpolation: 'color-interpolation',
300 - colorInterpolationFilters: 'color-interpolation-filters',
301 - colorProfile: 'color-profile',
302 - colorRendering: 'color-rendering',
303 - contentScriptType: 'contentScriptType',
304 - contentStyleType: 'contentStyleType',
305 - diffuseConstant: 'diffuseConstant',
306 - dominantBaseline: 'dominant-baseline',
307 - edgeMode: 'edgeMode',
308 - enableBackground: 'enable-background',
309 - externalResourcesRequired: 'externalResourcesRequired',
310 - fillOpacity: 'fill-opacity',
311 - fillRule: 'fill-rule',
312 - filterRes: 'filterRes',
313 - filterUnits: 'filterUnits',
314 - floodColor: 'flood-color',
315 - floodOpacity: 'flood-opacity',
316 - fontFamily: 'font-family',
317 - fontSize: 'font-size',
318 - fontSizeAdjust: 'font-size-adjust',
319 - fontStretch: 'font-stretch',
320 - fontStyle: 'font-style',
321 - fontVariant: 'font-variant',
322 - fontWeight: 'font-weight',
323 - glyphName: 'glyph-name',
324 - glyphOrientationHorizontal: 'glyph-orientation-horizontal',
325 - glyphOrientationVertical: 'glyph-orientation-vertical',
326 - glyphRef: 'glyphRef',
327 - gradientTransform: 'gradientTransform',
328 - gradientUnits: 'gradientUnits',
329 - horizAdvX: 'horiz-adv-x',
330 - horizOriginX: 'horiz-origin-x',
331 - imageRendering: 'image-rendering',
332 - kernelMatrix: 'kernelMatrix',
333 - kernelUnitLength: 'kernelUnitLength',
334 - keyPoints: 'keyPoints',
335 - keySplines: 'keySplines',
336 - keyTimes: 'keyTimes',
337 - lengthAdjust: 'lengthAdjust',
338 - letterSpacing: 'letter-spacing',
339 - lightingColor: 'lighting-color',
340 - limitingConeAngle: 'limitingConeAngle',
341 - markerEnd: 'marker-end',
342 - markerHeight: 'markerHeight',
343 - markerMid: 'marker-mid',
344 - markerStart: 'marker-start',
345 - markerUnits: 'markerUnits',
346 - markerWidth: 'markerWidth',
347 - maskContentUnits: 'maskContentUnits',
348 - maskUnits: 'maskUnits',
349 - numOctaves: 'numOctaves',
350 - overlinePosition: 'overline-position',
351 - overlineThickness: 'overline-thickness',
352 - paintOrder: 'paint-order',
353 - panose1: 'panose-1',
354 - pathLength: 'pathLength',
355 - patternContentUnits: 'patternContentUnits',
356 - patternTransform: 'patternTransform',
357 - patternUnits: 'patternUnits',
358 - pointerEvents: 'pointer-events',
359 - pointsAtX: 'pointsAtX',
360 - pointsAtY: 'pointsAtY',
361 - pointsAtZ: 'pointsAtZ',
362 - preserveAlpha: 'preserveAlpha',
363 - preserveAspectRatio: 'preserveAspectRatio',
364 - primitiveUnits: 'primitiveUnits',
365 - refX: 'refX',
366 - refY: 'refY',
367 - renderingIntent: 'rendering-intent',
368 - repeatCount: 'repeatCount',
369 - repeatDur: 'repeatDur',
370 - requiredExtensions: 'requiredExtensions',
371 - requiredFeatures: 'requiredFeatures',
372 - shapeRendering: 'shape-rendering',
373 - specularConstant: 'specularConstant',
374 - specularExponent: 'specularExponent',
375 - spreadMethod: 'spreadMethod',
376 - startOffset: 'startOffset',
377 - stdDeviation: 'stdDeviation',
378 - stitchTiles: 'stitchTiles',
379 - stopColor: 'stop-color',
380 - stopOpacity: 'stop-opacity',
381 - strikethroughPosition: 'strikethrough-position',
382 - strikethroughThickness: 'strikethrough-thickness',
383 - strokeDasharray: 'stroke-dasharray',
384 - strokeDashoffset: 'stroke-dashoffset',
385 - strokeLinecap: 'stroke-linecap',
386 - strokeLinejoin: 'stroke-linejoin',
387 - strokeMiterlimit: 'stroke-miterlimit',
388 - strokeOpacity: 'stroke-opacity',
389 - strokeWidth: 'stroke-width',
390 - surfaceScale: 'surfaceScale',
391 - systemLanguage: 'systemLanguage',
392 - tableValues: 'tableValues',
393 - targetX: 'targetX',
394 - targetY: 'targetY',
395 - textAnchor: 'text-anchor',
396 - textDecoration: 'text-decoration',
397 - textLength: 'textLength',
398 - textRendering: 'text-rendering',
399 - underlinePosition: 'underline-position',
400 - underlineThickness: 'underline-thickness',
401 - unicodeBidi: 'unicode-bidi',
402 - unicodeRange: 'unicode-range',
403 - unitsPerEm: 'units-per-em',
404 - vAlphabetic: 'v-alphabetic',
405 - vertAdvY: 'vert-adv-y',
406 - vertOriginX: 'vert-origin-x',
407 - vertOriginY: 'vert-origin-y',
408 - vHanging: 'v-hanging',
409 - vIdeographic: 'v-ideographic',
410 - viewBox: 'viewBox',
411 - viewTarget: 'viewTarget',
412 - vMathematical: 'v-mathematical',
413 - wordSpacing: 'word-spacing',
414 - writingMode: 'writing-mode',
415 - xChannelSelector: 'xChannelSelector',
416 - xHeight: 'x-height',
417 - xlinkActuate: 'xlink:actuate',
418 - xlinkArcrole: 'xlink:arcrole',
419 - xlinkHref: 'xlink:href',
420 - xlinkRole: 'xlink:role',
421 - xlinkShow: 'xlink:show',
422 - xlinkTitle: 'xlink:title',
423 - xlinkType: 'xlink:type',
424 - xmlBase: 'xml:base',
425 - xmlLang: 'xml:lang',
426 - xmlSpace: 'xml:space',
427 - yChannelSelector: 'yChannelSelector',
428 - zoomAndPan: 'zoomAndPan',
429 - },
288 + DOMAttributeNames: {},
289 };
290
291 +Object.keys(ATTRS).map((key) => {
292 + SVGDOMPropertyConfig.Properties[key] = null;
293 + if (ATTRS[key]) {
294 + SVGDOMPropertyConfig.DOMAttributeNames[key] = ATTRS[key];
295 + }
296 +});
297 +
298 module.exports = SVGDOMPropertyConfig;