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

hasStyle: incorrect child components check in case of nested CSS #25

Closed
matrunchyk opened this issue Apr 10, 2017 · 11 comments
Closed

hasStyle: incorrect child components check in case of nested CSS #25

matrunchyk opened this issue Apr 10, 2017 · 11 comments
Assignees
Labels

Comments

@matrunchyk
Copy link

matrunchyk commented Apr 10, 2017

UPD. The real description of the problem is here.

Hi guys, I've just noticed that zIndex doesn't work with hasStyle.

Alt text

I tried also .hasStyle('z-index', '9999'). Still false.

What am I doing wrong? Thanks.

@eddyerburgh
Copy link
Owner

Hi @matrunchyk ,

hasStyle uses the same values as css, so you use z-index instead of the JavaScript version zIndex.

This should work:

expect(temp1.hasStyle('z-index', '9999').to.equal(true)

@eddyerburgh eddyerburgh removed the bug label Apr 10, 2017
@matrunchyk
Copy link
Author

matrunchyk commented Apr 10, 2017

As I mentioned, .hasStyle('z-index', '9999') doesn't work either.
And even more. It works very weird :)

Alt text

P.S I'm trying to debug it & reproduce it somewhere in fiddle. I'll let you know.

@matrunchyk
Copy link
Author

matrunchyk commented Apr 10, 2017

Ok, so I figured out the problem.
Let's pretend a component has CSS rules like that:

.MyComponent > div {
    color: red;
}

As you can see, that div would be red only within .MyComponent.

But here you move an element (div in this case) to the body. So now it's impossible to check the real style of the div.

I'd suggest to not moving that only particular div (or any other child) but mount a whole component at all. Or at least check whether it's already exists in DOM.

@matrunchyk matrunchyk changed the title hasStyle: zIndex hasStyle: incorrect child components check in case of nested CSS Apr 10, 2017
@eddyerburgh
Copy link
Owner

Thanks, I'll look into this tonight.

@eddyerburgh
Copy link
Owner

eddyerburgh commented Apr 11, 2017

Ok, I've got a failing test. I'll try and figure out a workaround in the next couple days

@eddyerburgh eddyerburgh added bug and removed question labels Apr 11, 2017
@matrunchyk
Copy link
Author

matrunchyk commented Apr 11, 2017

@eddyerburgh Created a small repo with a component and a test.

@matrunchyk
Copy link
Author

Alright, thank you!

@eddyerburgh
Copy link
Owner

eddyerburgh commented Apr 12, 2017

Hi, so I've got a workaround. #26 means we can pass an option to attach the component to the DOM when mount is called.

When a component has been mounted to the DOM, hasStyle will check the node without having to attach it to the DOM.

The change to hasStyle hasn't been committed yet, but I'll update you when it's released. Should be by Saturday at the latest.

@matrunchyk
Copy link
Author

wow looks great! Thank you for all you guys do here!

@eddyerburgh eddyerburgh self-assigned this Apr 13, 2017
@eddyerburgh
Copy link
Owner

eddyerburgh commented Apr 14, 2017

Hi, this is fixed in 1.11.1.

@matrunchyk
Copy link
Author

Beautiful, thank you! :)

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

No branches or pull requests

2 participants