Bug Tracker

Opened 5 years ago

Closed 4 years ago

#8909 closed enhancement (fixed)

$(element).data() will scan all attributes more than needed.

Reported by: gnarf Owned by: gnarf
Priority: blocker Milestone: 1.7
Component: data Version: 1.5.2
Keywords: 1.7-discuss Cc:
Blocked by: Blocking:

Description

If you make more than one call to $(element).data() you end up having to loop over the attributes of the element looking for "data-" attributes every time you access it. I'd like to propose adding a simple flag in our private _data() that can stop us from having to check more than once...

Change History (13)

comment:2 Changed 5 years ago by timmywil

  • Component changed from unfiled to data
  • Status changed from new to open
  • Type changed from bug to enhancement

comment:3 Changed 5 years ago by gnarf

  • Owner set to gnarf
  • Status changed from open to assigned

comment:4 Changed 5 years ago by john

  • Keywords 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:5 Changed 5 years ago by jaubourg

+0, Need some code and perf tests

comment:6 Changed 5 years ago by rwaldron

+1, If I'm reading correctly, this seems to be a performance boost

comment:7 Changed 5 years ago by timmywil

+1,

comment:8 Changed 5 years ago by dmethvin

+1, Makes the semantics more predictable too.

comment:9 Changed 5 years ago by john

+1

comment:10 Changed 5 years ago by ajpiano

+1, Anything we can do to improve the perf of $(element).data("yesplease!")

comment:11 Changed 5 years ago by dmethvin

  • Milestone changed from 1.next to 1.7
  • Priority changed from undecided to blocker

comment:12 Changed 4 years ago by gnarf

Updated the pull request in comment #1 - http://jsperf.com/internal-data/3 has some perf data

comment:13 Changed 4 years ago by Corey Frang

  • Resolution set to fixed
  • Status changed from assigned to closed

Landing pull request 503. 1.7 data: set a flag in the private data cache to avoid having to scan attributes multiple times - Fixes #8909.

More Details:

Note: See TracTickets for help on using tickets.