Skip to content

support custom style properties '--*' (see https://drafts.csswg.org/css-variables/ for more information) #81

@samikarak

Description

@samikarak

Hello,

Our current application requires to use custom styles, so I would like to parse custom styles beginning with '--' without camelCasing the first character after the second dash, so that the parser is compliant to csswg specs for custom styles.
(info : it is also good to know, that react does only support custom styles beginning with '--
' )

I looked into the library files and found html-react-parser/lib/utilities.js which contains the function camelCase. This function is (obviously) responsible for mistakenly converting double dashed styles into camelCases. So for example '--customstyle' gets converted to '-Customstyle'.

besides checking if the string does not contain a dash, it could also be checked if the string is a custom style first.

  // customStyle or no hyphen found
  if (string.startsWith('--') || string.indexOf('-') === -1) {
    return string;
  }

this change would easily solve our problems

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions