\QueryPath\CSSEventHandler

An event handler for handling CSS 3 Selector parsing.

This provides a standard interface for CSS 3 Selector event handling. As the parser parses a selector, it will fire events. Implementations of EventHandler can then handle the events.

This library is inspired by the SAX2 API for parsing XML. Each component of a selector fires an event, passing the necessary data on to the event handler.

Summary

Methods
Constants
elementID()
element()
elementNS()
anyElement()
anyElementInNS()
elementClass()
attribute()
attributeNS()
pseudoClass()
pseudoElement()
directDescendant()
adjacent()
anotherSelector()
sibling()
anyDescendant()
isExactly
containsWithSpace
containsWithHyphen
containsInString
beginsWith
endsWith
anyElement
No protected methods found
N/A
No private methods found
N/A

Constants

isExactly

isExactly

The is-exactly (=) operator.

containsWithSpace

containsWithSpace

The contains-with-space operator (~=).

containsWithHyphen

containsWithHyphen

The contains-with-hyphen operator (!=).

containsInString

containsInString

The contains-in-string operator (*=).

beginsWith

beginsWith

The begins-with operator (^=).

endsWith

endsWith

The ends-with operator ($=).

anyElement

anyElement

The any-element operator (*).

Methods

elementID()

elementID(string  $id) 

This event is fired when a CSS ID is encountered.

An ID begins with an octothorp: #name.

Parameters

string $id

The ID passed in.

element()

element(string  $name) 

Handle an element name.

Example: name

Parameters

string $name

The name of the element.

elementNS()

elementNS(string  $name, string  $namespace = NULL) 

Handle a namespaced element name.

example: namespace|name

Parameters

string $name

The tag name.

string $namespace

The namespace identifier (Not the URI)

anyElement()

anyElement() 

Handle an any-element (*) operator.

Example: *

anyElementInNS()

anyElementInNS(string  $ns) 

Handle an any-element operator that is constrained to a namespace.

Example: ns|*

Parameters

string $ns

The namespace identifier (not the URI).

elementClass()

elementClass(string  $name) 

Handle a CSS class selector.

Example: .name

Parameters

string $name

The name of the class.

attribute()

attribute(string  $name, string  $value = NULL, integer  $operation = \QueryPath\CSS\EventHandler::isExactly) 

Handle an attribute selector.

Example: [name=attr] Example: [name~=attr]

Parameters

string $name

The attribute name.

string $value

The value of the attribute, if given.

integer $operation

The operation to be used for matching. See {@link EventHandler} constants for a list of supported operations.

attributeNS()

attributeNS(string  $name, string  $ns, string  $value = NULL, integer  $operation = \QueryPath\CSS\EventHandler::isExactly) 

Handle an attribute selector bound to a specific namespace.

Example: [ns|name=attr] Example: [ns|name~=attr]

Parameters

string $name

The attribute name.

string $ns

The namespace identifier (not the URI).

string $value

The value of the attribute, if given.

integer $operation

The operation to be used for matching. See {@link EventHandler} constants for a list of supported operations.

pseudoClass()

pseudoClass(string  $name, string  $value = NULL) 

Handle a pseudo-class.

Example: :name(value)

Parameters

string $name

The pseudo-class name.

string $value

The value, if one is found.

pseudoElement()

pseudoElement(string  $name) 

Handle a pseudo-element.

Example: ::name

Parameters

string $name

The pseudo-element name.

directDescendant()

directDescendant() 

Handle a direct descendant combinator.

Example: >

adjacent()

adjacent() 

Handle a adjacent combinator.

Example: +

anotherSelector()

anotherSelector() 

Handle an another-selector combinator.

Example: ,

sibling()

sibling() 

Handle a sibling combinator.

Example: ~

anyDescendant()

anyDescendant() 

Handle an any-descendant combinator.

Example: ' '