This repository has been archived by the owner on Dec 16, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for deprecated camelCase'd SVG props. Fixes #222.
- Loading branch information
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,9 @@ const AUTOBIND_BLACKLIST = { | |
}; | ||
|
||
|
||
const CAMEL_PROPS = /^(accent|alignment|arabic|baseline|cap|clip|color|fill|flood|font|glyph|horiz|marker|overline|paint|stop|strikethrough|stroke|text|underline|unicode|units|v|vert|word|writing|x)[A-Z]/g; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
developit
Author
Member
|
||
|
||
|
||
const BYPASS_HOOK = {}; | ||
|
||
/*global process*/ | ||
|
@@ -96,6 +99,15 @@ function handleVNode(vnode) { | |
|
||
if (vnode.children) a.children = vnode.children; | ||
} | ||
else if (a) { | ||
for (let i in a) { | ||
if (a.hasOwnProperty(i) && i.match(CAMEL_PROPS)) { | ||
This comment has been minimized.
Sorry, something went wrong.
billneff79
Contributor
|
||
a[i.replace(/([A-Z0-9])/g, '-$1').toLowerCase()] = a[i]; | ||
delete a[i]; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For one character more, your regex match can be twice as fast. you don't need the global flag, and you should use a non-capturing group:
CAMEL_PROPS = /^(?:accent.../;
https://esbench.com/bench/57f6475a330ab09900a1a218