Sizzle analysis record: Custom pseudo-class selector

Source: Internet
Author: User
Visibility
  • : Hidden
  • : Visible

The hidden object has no width or height, provided thatDisplay: None processed

jQuery.expr.filters.hidden = function( elem ) {    // Support: Opera <= 12.12    // Opera reports offsetWidths and offsetHeights less than zero on some elements    return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;};jQuery.expr.filters.visible = function( elem ) {    return !jQuery.expr.filters.hidden( elem );};

 

Content
  • : Contains (text)
  • : Empty
  • : Has (selector)
  • : Parent

Get text content matching through indexof

"contains": markFunction(function( text ) {    return function( elem ) {        return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;    };}),

 

Null

Recursion of this node to exclude nodes with nodetype greater than 6

// Contents"empty": function( elem ) {    // http://www.w3.org/TR/selectors/#empty-pseudo    // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),    //   but not by others (comment: 8; processing instruction: 7; etc.)    // nodeType < 6 works because attributes (2) do not appear as children    for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {        if ( elem.nodeType < 6 ) {            return false;        }    }    return true;},

 

View include

Recursive sizzle implements include search by passing context objects

"has": markFunction(function( selector ) {    return function( elem ) {        return Sizzle( selector, elem ).length > 0;    };}),

 

Match an element containing child elements or text

"parent": function( elem ) {    return !Expr.pseudos["empty"]( elem );},

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.