mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Update camelize() and hyphenate() to simpler versions.
This commit is contained in:
parent
f871430018
commit
e6c59672ac
1 changed files with 2 additions and 6 deletions
|
@ -221,7 +221,7 @@ this.Base = Base.inject(/** @lends Base# */{
|
|||
* Camelizes the passed hyphenated string: caps-lock -> capsLock
|
||||
*/
|
||||
camelize: function(str) {
|
||||
return str.replace(/-(\w)/g, function(all, chr) {
|
||||
return str.replace(/-(.)/g, function(all, chr) {
|
||||
return chr.toUpperCase();
|
||||
});
|
||||
},
|
||||
|
@ -230,11 +230,7 @@ this.Base = Base.inject(/** @lends Base# */{
|
|||
* Converst camelized strings to hyphenated ones: CapsLock -> caps-lock
|
||||
*/
|
||||
hyphenate: function(str) {
|
||||
return str.replace(/[a-z][A-Z0-9]|[0-9][a-zA-Z]|[A-Z]{2}[a-z]/g,
|
||||
function(match) {
|
||||
return match.charAt(0) + '-' + match.substring(1);
|
||||
}
|
||||
).toLowerCase();
|
||||
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue