Bug Tracker

Modify

Ticket #2146 (closed enhancement: duplicate)

Opened 5 years ago

Last modified 5 years ago

:content() match substring - how if the need is to match the whole text?

Reported by: G_Gus Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: contains text selector Cc:
Blocking: Blocked by:

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

Change History

comment:1 Changed 5 years ago by G_Gus

sorry, this is a duplicate of 2147 (2147 is more accurate: it have an attachment)

comment:2 Changed 5 years ago by davidserduke

  • Status changed from new to closed
  • Resolution set to duplicate

Author says dup of #2147 so closing on that basis.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.