Bug Tracker

Ticket #2147 (new enhancement)

Opened 11 months ago

need for a selector to match full string, as :contians() selector match only substring

Reported by: G_Gus Assigned to: anonymous
Type: enhancement Priority: minor
Milestone: 1.2.2 Component: core
Version: 1.2.1 Keywords: contains selector text
Cc: Needs: Review

Description

:contains() is the very only selector that operates on text.

Here's the actual jQuery code:

// Text Check
contains: "(a.textContent||a.innerText||jQuery(a).text()||'').indexOf(m[3])>=0",

the method for matching text is .indexOf() , so it returns true if the text is contained, with no option for exact matching.

I think that another selector that operates on text is needed. I wrote a simple exact matching selector:

  equals: "(a.textContent||a.innerText||jQuery(a).text()||'')==m[3]",

it does make use of == operand instead of .indexOf() method

What do you think about it?

Attachments

testcase.html (2.0 kB) - added by G_Gus 11 months ago.
testcase and a semi-real case

Change History

Changed 11 months ago by G_Gus

testcase and a semi-real case

Note: See TracTickets for help on using tickets.