Bug Tracker


Ticket #9392 (closed feature: wontfix)

Opened 3 years ago

Last modified 2 years ago

Add :data() Selector

Reported by: kaneiderdaniel@… Owned by:
Priority: low Milestone: 1.7
Component: selector Version: 1.6.1
Keywords: 1.7-discuss Cc:
Blocking: Blocked by:

Description (last modified by scott.gonzalez) (diff)

Provide a selector for .data(), similar to those of attributes:

Example with attributes

  • $("".someClass[myAttr])
  • $("".someClass[myAttr='someValue'])

Likewise something for .data

  • $("".someClass:hasData(myAttr))
  • $("".someClass:data(myAttr='someValue'))

You can avoid the need for this, if you use custom data attributes, as and only as DOM attributes: <div id=""test"" data-test=""value""></div> .. $(""#test[data-test='value'])

But if you start using the .data() function, this is no longer possible in such a way: <div id=""test""></div> .. $(""#test"").data(""test"", ""value"") $(""#test[data-test='value']) fails

Alternative: $(""*"").filter(function() { return $(this).data(""test"") === ""value""; });

There is a already a plugin which implements this problem, which I would like to see included in $1.7 in some way...  http://plugins.jquery.com/project/dataSelector

Change History

comment:1 Changed 3 years ago by john

  • Keywords 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:2 Changed 3 years ago by rwaldron

  • Description modified (diff)

-1, can be achieved with existing API;  http://jsfiddle.net/rwaldron/AW2vj/

comment:3 Changed 3 years ago by jaubourg

-1, well, use the plugin

comment:4 Changed 3 years ago by timmywil

-1, best as plugin

comment:5 Changed 3 years ago by paul.irish

  • Description modified (diff)

comment:6 Changed 3 years ago by timmywil

  • Priority changed from undecided to low
  • Status changed from new to open
  • Component changed from unfiled to selector

comment:7 Changed 3 years ago by dmethvin

-1, No new selectors.

comment:8 Changed 3 years ago by john

  • Description modified (diff)

-1, Plugin.

comment:9 Changed 3 years ago by ajpiano

  • Description modified (diff)

-1, Not only no new selectors, I feel like this is a particularly bad way to query the DOM generally. There's a :data selector baked into jQuery UI, if you want to use it.  https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.core.js#L206

comment:10 Changed 3 years ago by scott.gonzalez

  • Description modified (diff)

-1, there are so many things you might or might not want this selector to handle

comment:11 Changed 3 years ago by rwaldron

  • Status changed from open to closed
  • Resolution set to wontfix
  • Milestone changed from 1.next to 1.7

Closing per 1.7 roadmap meeting resolution

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


Add a comment

Modify Ticket

as closed

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

Note: See TracTickets for help on using tickets.