Skip to content

Phpquery css #2

Open
wants to merge 13 commits into from

1 participant

@kevee
kevee commented Mar 30, 2012

This branch introduces CSS parsing, including the CSSParse library (https://github.com/sabberworm/PHP-CSS-Parser) which has a compatible license to be included within PHPQuery (MIT).

Aside from using the CSSparsing library, this brach allows users to call pq($el)->css('background') to retrieve css styling of elements, or css('background', 'black') to set CSS styles on elements. All changes or parsing to elements bubble down the DOM tree and compare specificity correctly.

The only thing users have to do is add CSS strings that aren't already in the document captured by "&quot; tags using phpQuery::getDocument()-&gt;addCSS(&#39;p { background: yellow; }&#39;), as we can&#39;t infer the URL location of any given page and then make requests to retrieve CSS files directly, it&#39;s up to the user to fetch any CSS files first.</p> <p>The branch also includes a default CSS file as provided by the W3C [<a href="http://www.w3.org/TR/CSS21/sample.html">http://www.w3.org/TR/CSS21/sample.html</a>] for HTML4 so we can infer standard colors and backgrounds for all elements.</p>

@kevee
kevee commented Mar 30, 2012

There's still a few things missing:
1. We're expanding things like background and margin, which is a good thing, but these cause requests for 'background' to not work as expected, instead users must ask for the sub-components of these type of selectors. This is partially because of the way CSSParser works.
2. Percentage-based sizes aren't affected by bubbling, but could be added easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.