Sage: camelCase util function does not return what it states for the sample input

Created on 3 Dec 2019  路  3Comments  路  Source: roots/sage

Description

See the current code:
https://github.com/roots/sage/blob/bd38502616188be973f60b75717eea95c1fc69d2/resources/assets/scripts/util/camelCase.js#L2-L9
The camelCase util function does not return what it states for the sample input (except being the "the most terrible camelizer"), is this by design? (if so, maybe add a comment about that)

Steps to reproduce

Actual behavior:
input "CAMeL_CaSEiS-harD" => output "cAMeLCaSEiSHarD"

Expected behavior:
if .toLowerCase() is added in the map() the result will be "camelCaseisHard".
Note that the change will change the correctly camelCase input "camelCaseIsHard" => output "camelcaseishard", so it will convert the uppercase characters to lowercase.

Most helpful comment

@bwbroersma The function wasn鈥檛 meant to be used generally outside of Sage 9鈥檚 DOM router since it only meets the needs of the router (camelcasing CSS class names iirc). The new version of the router doesn鈥檛 use the camelcasing anymore and Sage 10 doesn鈥檛 even include any JS DOM router since it recommends code splitting instead.

In other words, use something like Lodash instead.

All 3 comments

the most terrible camelizer on the internet

Sounds like it's working as advertised 馃槒

Sounds like it's working as advertised smirk

I'm actually not sure what it should do, it's not really clear, especially since the output example does not match the input example. I was looking into the javascript of one of my colleagues and was amazed by this function. Since 'a fix' would change the behavior, I'm asking this question.
If it is really intended to be terrible, maybe add 'this will produce cAMeLCaSEiSHarD' to the example input.

@bwbroersma The function wasn鈥檛 meant to be used generally outside of Sage 9鈥檚 DOM router since it only meets the needs of the router (camelcasing CSS class names iirc). The new version of the router doesn鈥檛 use the camelcasing anymore and Sage 10 doesn鈥檛 even include any JS DOM router since it recommends code splitting instead.

In other words, use something like Lodash instead.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jlariza picture jlariza  路  5Comments

evertsemeijn picture evertsemeijn  路  3Comments

collegeman picture collegeman  路  3Comments

emilsgulbis picture emilsgulbis  路  6Comments

timalbert picture timalbert  路  6Comments