Skip to content

Trying to parse undefined will cause error in cssColor dependency's resolveColor #189

@kasimir-dka

Description

@kasimir-dka

exports.parseColor = function parseColor(val) {

In parseColor we test if value is empty string or null, otherwise we continue to use resolveColor:

  if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
    return val;
  }
  if (/^[a-z]+$/i.test(val) && type === exports.TYPES.COLOR) {
    return val;
  }
  var res = resolveColor(val, {
    format: 'specifiedValue',
  });

If val is undefined, this will cause an error in resolveColor

We can prevent this by adding a test for undefined:

  if (typeof val === undefined || type === exports.TYPES.NULL_OR_EMPTY_STR) {
    return val;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions