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

Move className to props #1242

Closed
eddyerburgh opened this issue Nov 24, 2017 · 3 comments
Closed

Move className to props #1242

eddyerburgh opened this issue Nov 24, 2017 · 3 comments
Labels

Comments

@eddyerburgh
Copy link

I'm making an enzyme-inferno-adapter, but I've hit some problems getting the last few tests to pass.

Enzyme requires the className to be inside props. This is fine normally, because we can convert the inferno VNode tree to an enzyme RST tree. But when you call the Enzmye contains function, enzyme compares the RST node to the newly created VNode. The RST node has className inside props, the inferno VNode has className on the vNode.

Example:

VNode:

{
type: 'div',
  props: {
    className: 'bar'
  }
}
type: 'div',
  props: {
  },
  className: 'bar'
}

This means we can't call a method like this:

const c = <div className="bar" />;
expect(mount(Component).contains(b)).to.equal(true);

Because enzyme is checking a VNode against an RST Node. This could be an issue to raise with Enzyme, but if there isn't a reason for Inferno to have className outside props, it would improve compatibility to add it to props.

Observed Behaviour

Inferno has className on the vNode

Expected Current Behaviour

Inferno should include className in the props

@Havunen
Copy link
Member

Havunen commented Nov 25, 2017

className was moved from props to vNode because its the most common property of any html element. It has quite big impact on performance also, because when className is at the root and its the only prop. We don't need to loop props in diff.

@Havunen
Copy link
Member

Havunen commented Dec 5, 2017

@eddyerburgh Can you do this in enzyme compat to wrap the vNodes? you can use inferno.options.createVNode to accomplish this

@eddyerburgh
Copy link
Author

I've made a PR in enzyme to fix this —enzymejs/enzyme#1423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants