GithubHelp home page GithubHelp logo

Specificity not supported about premailer HOT 6 OPEN

peterbe avatar peterbe commented on September 28, 2024
Specificity not supported

from premailer.

Comments (6)

peterbe avatar peterbe commented on September 28, 2024

Does lxml support :last-child selectors?

Also, since the parse reads from the top to bottom. Can't you just change the order of your two selectors?

from premailer.

gavinwahl avatar gavinwahl commented on September 28, 2024

It does support that selector; reversing the order does give the expected behavior. So you can 'just' sort your selectors by specificity, but I don't think you can say you really have CSS without the cascade.

from premailer.

elidickinson avatar elidickinson commented on September 28, 2024

@peterbe I haven't dug in very deeply, but is there any reason premailer is trying to calculate specificity itself in _parse_style_rules rather than using the functionality provided by cssselect: https://pythonhosted.org/cssselect/#cssselect.Selector.specificity ?

from premailer.

peterbe avatar peterbe commented on September 28, 2024

@elidickinson I don't know but I suspect that history will explain that. There used to be just lxml but later someone broke that out of lxml and we then have to install both lxml and cssselect. It came into existence late and that's probably simply the explanation.

Do you think you'd be able to write a little patch to switch to using cssselect instead of the ad-hoc custom code? I'd be willing to help and help write some tests.

from premailer.

elidickinson avatar elidickinson commented on September 28, 2024

@peterbe Makes sense, I think I actually knew that and forgot. Yeah, I'll take a swing at it. Writing the tests is probably exactly where I'd need the help. Might take me a bit before I can get to it, though.

from premailer.

peterbe avatar peterbe commented on September 28, 2024

@elidickinson Please do not hesitate to ping me. Writing the tests is going to be easy. But if you're not super familiar with it the project it can be hard to know how to start the tests or where to put the new tests (hint; it's mainly copy-n-paste from some existing test).

from premailer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.