Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Phpquery css #2

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Phpquery css #2

wants to merge 13 commits into from

Conversation

kevee
Copy link

@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 "<style>" tags using phpQuery::getDocument()->addCSS('p { background: yellow; }'), as we can't infer the URL location of any given page and then make requests to retrieve CSS files directly, it's up to the user to fetch any CSS files first.

The branch also includes a default CSS file as provided by the W3C [http://www.w3.org/TR/CSS21/sample.html] for HTML4 so we can infer standard colors and backgrounds for all elements.

@kevee
Copy link
Author

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant