Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc12a3b5

Browse files
committed
refactor: SwitchSVG_KEBAB_CASE over
1 parent8e49cc2 commitc12a3b5

File tree

3 files changed

+80
-7
lines changed

3 files changed

+80
-7
lines changed

‎src/index.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
NAMESPACE_REPLACE_REGEX,
66
HTML_LOWER_CASE,
77
HTML_ENUMERATED,
8-
SVG_CAMEL_CASE,
8+
SVG_KEBAB_CASE,
99
createComponent
1010
}from'./lib/util.js';
1111
import{options,h,Fragment}from'preact';
@@ -631,7 +631,7 @@ function _renderToString(
631631
// serialize boolean aria-xyz or enumerated attribute values as strings
632632
v=v+EMPTY_STR;
633633
}elseif(isSvgMode){
634-
if(SVG_CAMEL_CASE.test(name)){
634+
if(SVG_KEBAB_CASE.has(name)){
635635
name=
636636
name==='panose1'
637637
?'panose-1'

‎src/lib/util.js‎

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const VOID_ELEMENTS = new Set([
1818
]);
1919
exportconstUNSAFE_NAME=/[\s\n\\/='"\0<>]/;
2020
exportconstNAMESPACE_REPLACE_REGEX=/^(xlink|xmlns|xml)([A-Z])/;
21-
2221
exportconstHTML_LOWER_CASE=newSet([
2322
'accessKey',
2423
'accessKeyLabel',
@@ -64,8 +63,82 @@ export const HTML_LOWER_CASE = new Set([
6463
'itemID',
6564
'itemRef'
6665
]);
67-
68-
exportconstSVG_CAMEL_CASE=/^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/;
66+
exportconstSVG_KEBAB_CASE=newSet([
67+
'accentHeight',
68+
'accumulate',
69+
'alignmentBaseline',
70+
'arabicForm',
71+
'baselineShift',
72+
'capHeight',
73+
'clipPath',
74+
'clipRule',
75+
'colorInterpolation',
76+
'colorInterpolationFilters',
77+
'colorProfile',
78+
'colorRendering',
79+
'dominantBaseline',
80+
'enableBackground',
81+
'fillOpacity',
82+
'fillRule',
83+
'floodColor',
84+
'floodOpacity',
85+
'fontFamily',
86+
'fontSize',
87+
'fontSizeAdjust',
88+
'fontStretch',
89+
'fontStyle',
90+
'fontVariant',
91+
'fontWeight',
92+
'glyphName',
93+
'glyphOrientationHorizontal',
94+
'glyphOrientationVertical',
95+
'horizAdvX',
96+
'horizOriginX',
97+
'imageRendering',
98+
'letterSpacing',
99+
'lightingColor',
100+
'markerEnd',
101+
'markerMid',
102+
'markerStart',
103+
'overlinePosition',
104+
'overlineThickness',
105+
'paintOrder',
106+
'panose1',
107+
'pointerEvents',
108+
'renderingIntent',
109+
'shapeRendering',
110+
'stopColor',
111+
'stopOpacity',
112+
'strikethroughPosition',
113+
'strikethroughThickness',
114+
'strokeDasharray',
115+
'strokeDashoffset',
116+
'strokeLinecap',
117+
'strokeLinejoin',
118+
'strokeMiterlimit',
119+
'strokeOpacity',
120+
'strokeWidth',
121+
'textAnchor',
122+
'textDecoration',
123+
'textRendering',
124+
'transformOrigin',
125+
'underlinePosition',
126+
'underlineThickness',
127+
'unicodeBidi',
128+
'unicodeRange',
129+
'unitsPerEm',
130+
'vAlphabetic',
131+
'vectorEffect',
132+
'vertAdvY',
133+
'vertOriginX',
134+
'vertOriginY',
135+
'vHanging',
136+
'vIdeographic',
137+
'vMathematical',
138+
'wordSpacing',
139+
'writingMode',
140+
'xHeight'
141+
]);
69142

70143
// Boolean DOM properties that translate to enumerated ('true'/'false') attributes
71144
exportconstHTML_ENUMERATED=newSet(['draggable','spellcheck']);

‎src/pretty.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
UNSAFE_NAME,
99
VOID_ELEMENTS,
1010
NAMESPACE_REPLACE_REGEX,
11-
SVG_CAMEL_CASE,
11+
SVG_KEBAB_CASE,
1212
HTML_LOWER_CASE,
1313
getContext
1414
}from'./lib/util.js';
@@ -252,7 +252,7 @@ function _renderToStringPretty(
252252
}elseif(NAMESPACE_REPLACE_REGEX.test(name)){
253253
name=name.replace(NAMESPACE_REPLACE_REGEX,'$1:$2').toLowerCase();
254254
}elseif(isSvgMode){
255-
if(SVG_CAMEL_CASE.test(name)){
255+
if(SVG_KEBAB_CASE.has(name)){
256256
name=
257257
name==='panose1'
258258
?'panose-1'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp