Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

className applied to incorrect nodes in 5.2.2 #244

Closed
OscarBarrett opened this issue Mar 22, 2019 · 1 comment · Fixed by #245
Closed

className applied to incorrect nodes in 5.2.2 #244

OscarBarrett opened this issue Mar 22, 2019 · 1 comment · Fixed by #245
Labels

Comments

@OscarBarrett
Copy link
Contributor

After upgrading from 5.2.1 to 5.2.2, className props applied to inner nodes using a spread are being applied to outer nodes as well.

For example:

import React from 'react';
import Slider from 'react-slick';

import styles from './styles.scss';

const Test = () => {
  const settings = {
    className: styles.innerSlider
  };

  return (
    <div styleName="vehicleSlider">
      foo

      <Slider {...settings}>
        bar
      </Slider>
    </div>
  );
};

export default Test;

Test:

import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';

import Test from '.';

describe('<Test />', () => {
  it('matches its snapshot', () => {
    const wrapper = shallow(<Test />);
    expect(toJson(wrapper)).toMatchSnapshot();
  });
});

Which generates the snapshot:

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Test /> matches its snapshot 1`] = `
<div
  className="vehicleSlider innerSlider"
>
  foo
  <Slider
    className="innerSlider"
  >
    bar
  </Slider>
</div>
`;

The outer div should only have a className of vehicleSlider.

With 5.2.1, the snapshot is instead

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Test /> matches its snapshot 1`] = `
<div
  className="vehicleSlider"
>
  foo
  <Slider
    className="innerSlider"
  >
    bar
  </Slider>
</div>
`;

Which is what is expected.

@gajus
Copy link
Owner

gajus commented Mar 22, 2019

🎉 This issue has been resolved in version 5.2.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Mar 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants