Bug Tracker

Ticket #8909 (closed enhancement: fixed)

Opened 4 years ago

Last modified 3 years ago

$(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:
Blocking: Blocked by:

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

comment:1 Changed 4 years ago by gnarf

Last edited 3 years ago by gnarf (previous) (diff)

comment:2 Changed 4 years ago by timmywil

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

comment:3 Changed 4 years ago by gnarf

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

comment:4 Changed 4 years ago by john

  • Keywords 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:5 Changed 4 years ago by jaubourg

+0, Need some code and perf tests

comment:6 Changed 4 years ago by rwaldron

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

comment:7 Changed 4 years ago by timmywil

+1,

comment:8 Changed 4 years ago by dmethvin

+1, Makes the semantics more predictable too.

comment:9 Changed 3 years ago by john

+1

comment:10 Changed 3 years ago by ajpiano

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

comment:11 Changed 3 years ago by dmethvin

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

comment:12 Changed 3 years ago by gnarf

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

comment:13 Changed 3 years ago by Corey Frang

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

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.