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

Contains word selector doesn't produce correct results #195

Open
mikicz opened this issue Aug 30, 2018 · 4 comments
Open

Contains word selector doesn't produce correct results #195

mikicz opened this issue Aug 30, 2018 · 4 comments

Comments

@mikicz
Copy link

mikicz commented Aug 30, 2018

So I have a HTML email with styles similiar to:

<html>
<head>
<style>
.view a {
  color: green;
}

.view span[style~="color:"] a {
  color: inherit;
}
</style>

<body>
<div class="view">
   <span style="color: red">
     <a href="google.com">Link that should be red</a>
   </span>

   <a href="google.com">Link that should be green</a>
</div>
</body>
</html>

which should produce links of two different colors (open the HTML in a browser).

Using this library the HTML is transformed to the following HTML:

<html>
<head>
<style>.view span[style~="color:"] a {color:inherit}</style>

</head>
<body>
<div class="view">
   <span style="color: red">
     <a href="google.com" style="color:green">Link that should be red</a>
   </span>

   <a href="google.com" style="color:green">Link that should be green</a>
</div>
</body>
</html>

However, this snippet results in two links that are green. The problem is that the inlined color of the first link overrides the inherit from style element.

@peterbe
Copy link
Owner

peterbe commented Aug 30, 2018

Sorry to hear that. I have to admit that it's very unlikely that I'll be able to find the time to patch this. If you can take a stab at the code and figure out why it doesn't work, I can help you write and run a unit test.

@mikicz
Copy link
Author

mikicz commented Aug 30, 2018

Quite understandable, don't worry. I worked around it by simply not having a default link color, just having the color of links always to inherit.

What should the correct behaviour be? Should the library recognise the ~= selector and apply it as other regular selectors?

@peterbe
Copy link
Owner

peterbe commented Aug 30, 2018

This library depends on cssselect which I suspect isn't powerful enough to understand a selector like span[style~="color:"]. Might be the reason.

@mikicz
Copy link
Author

mikicz commented Aug 30, 2018

Ok. I might take a look into that sometimes, as I said, it's not really that important. Will submit a PR if I figure something out...

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

2 participants