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

class selector does not seem to work #29

Open
SloppyFresh opened this issue Sep 12, 2014 · 4 comments
Open

class selector does not seem to work #29

SloppyFresh opened this issue Sep 12, 2014 · 4 comments

Comments

@SloppyFresh
Copy link

If I call:

jss.set('.myClass', {
'display': 'none'
});

the css is updated properly , and the display elements are updated as expected.

However, calling

jss.remove('.myClass');

has no effect.

Calling

jss.remove();

works though.

The .myClass style is not defined anywhere. If I do define it in a .css file included on the page, the behaviour is the same. If I use an element type selector instead of a class selector, remove seems to work as would be expected.

@dasilvacontin
Copy link

I couldn't reproduce the error: http://jsfiddle.net/Lqdtvy2z/.

Can you provide a failed test case?

@redders6600
Copy link

Hi @dasilvacontin - check the console of your fiddle - jss is not being defined because github is serving the file with the wrong MIME type, so whilst it looks like the example is working as intended, the rule never gets set in the first place.

I replaced the reference to the github resource with a link that does get served with the right MIME type using rawgit, and this is the result.

As you can see remove does not work when passed a selector. I can repro this in my own environment too.

@dasilvacontin
Copy link

Wow, what a fail, thanks for the heads up @redders6600! It would be nice to fix this, indeed.

@redders6600
Copy link

I looked into this and worked out what the issue is - the getRules function forces the selector to lowercase. This is fine for elements, but classes can have uppercase letters (as in this example).

To workaround with the current code, use styles that use all lowercase characters, but I guess this is something that should be updated in JSS.

Similarly, ensure you use the :: pseudoselector syntax when passing to remove instead of :.

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

No branches or pull requests

3 participants