cocktail-css-selector

css selector parsing/serializing and matching
https://github.com/haxecocktail/cocktail-css-selector

To install, run:

haxelib install cocktail-css-selector 0.1.4 

See using Haxelib in Haxelib documentation for more information.

README.md

Build Status

cocktail-css-selector

CSS selector matching, parsing and serializing. This lib is part of the larger Cocktail project.

Install

haxelib install cocktail-css-selector

Usage

Selectors parsing


//parser class
import cocktail.selector.SelectorsParser;

//Selectors data structures
import cocktail.selector.SelectorData;

class Main {
  public static function main() {
  
    //parse one or multiple selectors and return them in an array of SelectorVO 
    //(see SelectorData implementation)
    var selectors = SelectorsParser.parse('div, p');
  }
}

Selectors matching


//matcher class
import cocktail.selector.SelectorMatcher;

//Selectors data structures
import cocktail.selector.SelectorData;

//DOM lib
import cocktail.dom.*;

class Main {
  public static function main() {

    //create the DOM node to match
    var element = new Document().createElement('div');
  
    //takes a DOM node and a
    //selector and returns whether the element matches the 
    //selector
    var isMatched = SelectorMatcher.match(element, 'div');

    //an optional object can be provided specifiying which pseudo-class
    //(hover, active, fullscreen... are currently active in the document).
    //It is only useful for interactive documents
    var matchedPseudoClasses = new MatchedPseudoClassesVO(/*bunch of flags*/);

    isMatched = SelectorMatcher.match(element, 'div', matchedPseudoClasses);
  }
}

Run Tests

make
Contributors
yanhick
Version
0.1.4
Published
4 years ago
License
MIT

All libraries are free

Every month, more than thousand developers use haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on Github!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on Github