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

[css] duplicate rules should override previously defined rules #301

Open
hedyhli opened this issue Apr 20, 2024 · 2 comments
Open

[css] duplicate rules should override previously defined rules #301

hedyhli opened this issue Apr 20, 2024 · 2 comments

Comments

@hedyhli
Copy link
Contributor

hedyhli commented Apr 20, 2024

While working on #300 I encountered what is likely to be a bug.

Minimal reproducible example:

<html>
  <head>
    <style>
    body {color: yellow;}
    body {color: blue;}
    </style>
  </head>
  <body>
  <p>text</p>
  </body>
</html>
elinks test.html

The text should show up in blue out of all other browsers I've tested, but it shows up in yellow instead.

I haven't digged into how this happens or whether it can be fixed, but I saw this comment in css_parse_ruleset:

/* We don't handle the case where a property has already been added to
* a selector. That doesn't matter though, because the best one will be
* always the last one (FIXME: 'important!'), therefore the applier
* will take it last and it will have the "final" effect.
*
* So it's only a little waste and no real harm. The thing is, what do
* you do when you have 'background: #fff' and then 'background:
* x-repeat'? It would require yet another logic to handle merging of
* these etc and the induced overhead would in most cases mean more
* waste that having the property multiple times in a selector, I
* believe. --pasky */

It gives me reason to believe that repeated rules should already be overriding previous rules... but it isn't.

@rkd77
Copy link
Owner

rkd77 commented Apr 20, 2024

When libcss is enabled it is blue.

rkd77 added a commit that referenced this issue Apr 20, 2024
@rkd77
Copy link
Owner

rkd77 commented Apr 20, 2024

Please check this ^ commit.

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