API Docs for: 1.0.0
Show:

Node~optimizations Class

Optimizations for searching DOM tree.

Methods

ancestor

(
  • fn
  • test_self
)
Node

Patch to speed up search for a single class name or single tag name. To use a regular expression, call getAncestorByClassName().

Parameters:

  • fn String | Function

    selector string or boolean method for testing elements

  • test_self Boolean

    pass true to include the element itself in the scan

Returns:

Node:

getAncestorByClassName

(
  • class_name
  • test_self
)
Node

Searches for an ancestor by class name. This is significantly faster than using Y.node.ancestor('.classname'), and it accepts a regular expression.

Parameters:

  • class_name String | Regexp

    class to search for

  • test_self Boolean

    pass true to include the element itself in the scan

Returns:

Node:

getAncestorByTagName

(
  • tag_name
  • test_self
)
Node

Searches for an ancestor by tag name. This is significantly faster than using Y.node.ancestor('tagname').

Parameters:

  • tag_name String

    tag name to search for

  • test_self Boolean

    pass true to include the element itself in the scan

Returns:

Node:

getElementsByClassName

(
  • class_name
  • tag_name
)
NodeList

Searches for descendants by class name. Unlike Y.all(), this function accepts a regular expression.

Parameters:

  • class_name String | Regexp

    class to search for

  • tag_name String

    optional tag name to filter by

Returns:

getFirstElementByClassName

(
  • class_name
  • tag_name
)
Node

Searches for one descendant by class name. Unlike Y.one(), this function accepts a regular expression.

Parameters:

  • class_name String | Regexp

    class to search for

  • tag_name String

    optional tag name to filter by

Returns:

Node:

Properties

class_re_prefix

String static

Useful when constructing regular expressions that match CSS classes.

class_re_suffix

String static

Useful when constructing regular expressions that match CSS classes.