storybook-addon-pseudo-states icon indicating copy to clipboard operation
storybook-addon-pseudo-states copied to clipboard

Fail to parse className from SVG elements

Open crysadrak opened this issue 3 years ago • 4 comments

Describe the bug Doesnt work with components containing SVG elements (may be already in issues but not detected as SVG problem)

To Reproduce Steps to reproduce the behavior:

  1. init storybook (webpack5 version), add storybook-addon-pseudo-states addon (version storybook-addon-pseudo-states": "1.1.0-canary.8.ee5c388.0)
  2. compose any component with SVG element inside (missing classNames attribute)
  3. run storybook

Expected behavior Render preview

Current behavior Render fails while trying to split className value, this attr doesnt exists on SVG elements

Desktop (please complete the following information):

  • OS: OS-X, gitlab CI

I have edit dist code, apply try-catch on critical line to print error and element, as you can see its only svg and its childs. I cant reach the code from next version, if you cant find it in your source code:

`

  tagSelectors.add("(?<![.#])\\b".concat(element.tagName, "\\b"));
  if (element.id) idSelectors.add("#".concat(element.id));
  try {
        var _iterator3 = _createForOfIteratorHelper(element.className.split(/\s+/)),
            _step3;
  } catch (e) {
    console.log(e, element);
  }
  try {
    for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
      var classname = _step3.value;
      if (classname) classSelectors.add("\\.".concat(classname));
    }
  } catch (err) {
    _iterator3.e(err);
  } finally {
    _iterator3.f();
  }

`

image

crysadrak avatar May 10 '21 20:05 crysadrak

+1 @ghengeveld - getting this exact same error.

erosenberg avatar May 26 '21 16:05 erosenberg

Same removing plugin for now.

Using @ant-design/icons with storybook 6.30-beta

bfbiggs avatar Jun 06 '21 21:06 bfbiggs

+1 We're also getting a TypeError: element.className.split is not a function at rewriteStyleSheets since upgrading to Webpack 5

EDIT: This also happens when using 1.1.0-canary.8.b81386e.0 from #8

pruik avatar Aug 04 '21 12:08 pruik

Happy to take a PR that wraps the offending code in a try/catch (or other solution).

ghengeveld avatar Aug 04 '21 17:08 ghengeveld