PHP 클래스 QueryPath\CSS\DOMTraverser

This traverses a DOMDocument and attempts to find matches to the provided selector. \b How this works This performs a bottom-up search. On the first pass, it attempts to find all of the matching elements for the last simple selector in a selector. Subsequent passes attempt to eliminate matches from the initial matching set. Example: Say we begin with the selector foo.bar baz. This is processed as follows: - First, find all baz elements. - Next, for any baz element that does not have foo as an ancestor, eliminate it from the matches. - Finally, for those that have foo as an ancestor, does that foo also have a class baz? If not, it is removed from the matches. \b Extrapolation Partial simple selectors are almost always expanded to include an element. Examples: - :first is expanded to *:first - .bar is expanded to *.bar. - .outer .inner is expanded to *.outer *.inner The exception is that IDs are sometimes not expanded, e.g.: - #myElement does not get expanded - #myElement .class \i may be expanded to *#myElement *.class (which will obviously not perform well).
상속: implements QueryPath\CSS\Traverser
파일 보기 프로젝트 열기: microweber/microweber 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$dom
$initialized
$matches
$psHandler
$scopeNode
$selector

공개 메소드들

메소드 설명
__construct ( SPLObjectStorage $splos, $initialized = false, $scopeNode = null ) Build a new DOMTraverser.
attachNodeList ( DOMNodeList $nodeList, SplObjectStorage $splos ) Attach all nodes in a node list to the given \SplObjectStorage.
combine ( DOMNode $node, array $selectors, integer $index ) Combine the next selector with the given match using the next combinator.
combineAdjacent ( DOMNode $node, array $selectors, integer $index ) : boolean Process an Adjacent Sibling.
combineAnyDescendant ( DOMNode $node, array $selectors, integer $index ) : boolean Handle Any Descendant combinations.
combineDirectDescendant ( DOMNode $node, array $selectors, integer $index ) : boolean Handle a Direct Descendant combination.
combineSibling ( DOMNode $node, array $selectors, integer $index ) : boolean Check all siblings.
debug ( $msg )
find ( string $selector ) Given a selector, find the matches in the given DOM.
getDocument ( )
matches ( )
matchesSelector ( $node, $selector ) Check whether the given node matches the given selector.
matchesSimpleSelector ( $node, $selectors, $index ) Performs a match check on a SimpleSelector.

보호된 메소드들

메소드 설명
ancestors ( $node ) Get a list of ancestors to the present node.
getMatches ( ) Get the internal match set.
initialMatch ( $selector, $matches ) Get the intial match set.
initialMatchOnClasses ( $selector, $matches ) Shortcut for setting the intial match.
initialMatchOnElement ( $selector, $matches ) Shortcut for setting the initial match.
initialMatchOnElementNS ( $selector, $matches ) Get elements and filter by namespace.
initialMatchOnID ( $selector, $matches ) Shortcut for finding initial match by ID.
matchAttributes ( $node, $attributes ) Check to see if DOMNode has all of the given attributes.
matchClasses ( $node, $classes ) Check that the given DOMNode has all of the given classes.
matchElement ( $node, $element, $ns = null ) Checks to see if the DOMNode matches the given element selector.
matchId ( $node, $id ) Check that the given DOMNode has the given ID.
matchPseudoClasses ( $node, $pseudoClasses )
matchPseudoElements ( $node, $pseudoElements ) Test whether the given node matches the pseudoElements.
newMatches ( )
setMatches ( $matches ) Set the internal match set.

비공개 메소드들

메소드 설명
initialXpathQuery ( $xpath, $node, $query ) Internal xpath query.

메소드 상세

__construct() 공개 메소드

This requires a DOM-like object or collection of DOM nodes.
public __construct ( SPLObjectStorage $splos, $initialized = false, $scopeNode = null )
$splos SPLObjectStorage

ancestors() 보호된 메소드

Get a list of ancestors to the present node.
protected ancestors ( $node )

attachNodeList() 공개 메소드

Attach all nodes in a node list to the given \SplObjectStorage.
public attachNodeList ( DOMNodeList $nodeList, SplObjectStorage $splos )
$nodeList DOMNodeList
$splos SplObjectStorage

combine() 공개 메소드

If the next selector is combined with another selector, that will be evaluated too, and so on. So if this function returns TRUE, it means that all child selectors are also matches.
public combine ( DOMNode $node, array $selectors, integer $index )
$node DOMNode The DOMNode to test.
$selectors array The array of simple selectors.
$index integer The index of the current selector.

combineAdjacent() 공개 메소드

The spec does not indicate whether Adjacent should ignore non-Element nodes, so we choose to ignore them.
public combineAdjacent ( DOMNode $node, array $selectors, integer $index ) : boolean
$node DOMNode A DOM Node.
$selectors array The selectors array.
$index integer The current index to the operative simple selector in the selectors array.
리턴 boolean TRUE if the combination matches, FALSE otherwise.

combineAnyDescendant() 공개 메소드

This checks to see if there are any matching routes from the selector beginning at the present node.
public combineAnyDescendant ( DOMNode $node, array $selectors, integer $index ) : boolean
$node DOMNode A DOM Node.
$selectors array The selectors array.
$index integer The current index to the operative simple selector in the selectors array.
리턴 boolean TRUE if the combination matches, FALSE otherwise.

combineDirectDescendant() 공개 메소드

Check whether the given node is a rightly-related descendant of its parent node.
public combineDirectDescendant ( DOMNode $node, array $selectors, integer $index ) : boolean
$node DOMNode A DOM Node.
$selectors array The selectors array.
$index integer The current index to the operative simple selector in the selectors array.
리턴 boolean TRUE if the combination matches, FALSE otherwise.

combineSibling() 공개 메소드

According to the spec, this only tests elements LEFT of the provided node.
public combineSibling ( DOMNode $node, array $selectors, integer $index ) : boolean
$node DOMNode A DOM Node.
$selectors array The selectors array.
$index integer The current index to the operative simple selector in the selectors array.
리턴 boolean TRUE if the combination matches, FALSE otherwise.

debug() 공개 메소드

public debug ( $msg )

find() 공개 메소드

This is the main function for querying the DOM using a CSS selector.
public find ( string $selector )
$selector string The selector.

getDocument() 공개 메소드

public getDocument ( )

getMatches() 보호된 메소드

Internal utility function.
protected getMatches ( )

initialMatch() 보호된 메소드

This should only be executed when not working with an existing match set.
protected initialMatch ( $selector, $matches )

initialMatchOnClasses() 보호된 메소드

This shortcut should only be used when the initial element is '*' and there are classes set. In any other case, the element finding algo is faster and should be used instead.
protected initialMatchOnClasses ( $selector, $matches )

initialMatchOnElement() 보호된 메소드

Shortcut for setting the initial match.
protected initialMatchOnElement ( $selector, $matches )

initialMatchOnElementNS() 보호된 메소드

Get elements and filter by namespace.
protected initialMatchOnElementNS ( $selector, $matches )

initialMatchOnID() 보호된 메소드

If the element is set to '*' and an ID is set, then this should be used to find by ID, which will drastically reduce the amount of comparison operations done in PHP.
protected initialMatchOnID ( $selector, $matches )

matchAttributes() 보호된 메소드

This can handle namespaced attributes, including namespace wildcards.
protected matchAttributes ( $node, $attributes )

matchClasses() 보호된 메소드

Check that the given DOMNode has all of the given classes.
protected matchClasses ( $node, $classes )

matchElement() 보호된 메소드

This handles the following cases: - element (foo) - namespaced element (ns|foo) - namespaced wildcard (ns|*) - wildcard (* or *|*)
protected matchElement ( $node, $element, $ns = null )

matchId() 보호된 메소드

Check that the given DOMNode has the given ID.
protected matchId ( $node, $id )

matchPseudoClasses() 보호된 메소드

protected matchPseudoClasses ( $node, $pseudoClasses )

matchPseudoElements() 보호된 메소드

If any pseudo-elements are passed, this will test to see if conditions obtain that would allow the pseudo-element to be created. This does not modify the match in any way.
protected matchPseudoElements ( $node, $pseudoElements )

matches() 공개 메소드

public matches ( )

matchesSelector() 공개 메소드

A selector is a group of one or more simple selectors combined by combinators. This determines if a given selector matches the given node.
public matchesSelector ( $node, $selector )

matchesSimpleSelector() 공개 메소드

Where matchesSelector() does a check on an entire selector, this checks only a simple selector (plus an optional combinator).
public matchesSimpleSelector ( $node, $selectors, $index )

newMatches() 보호된 메소드

protected newMatches ( )

setMatches() 보호된 메소드

Internal utility function.
protected setMatches ( $matches )

프로퍼티 상세

$dom 보호되어 있는 프로퍼티

protected $dom

$initialized 보호되어 있는 프로퍼티

protected $initialized

$matches 보호되어 있는 프로퍼티

protected $matches

$psHandler 보호되어 있는 프로퍼티

protected $psHandler

$scopeNode 보호되어 있는 프로퍼티

protected $scopeNode

$selector 보호되어 있는 프로퍼티

protected $selector