Bug Tracker

Opened 12 years ago

Closed 12 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 12 years ago by Timmy Willison

Component: unfileddata
Status: newopen
Type: bugenhancement

comment:3 Changed 12 years ago by gnarf

Owner: set to gnarf
Status: openassigned

comment:4 Changed 12 years ago by john

Keywords: 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:5 Changed 12 years ago by jaubourg

+0, Need some code and perf tests

comment:6 Changed 12 years ago by Rick Waldron

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

comment:7 Changed 12 years ago by Timmy Willison

+1,

comment:8 Changed 12 years ago by dmethvin

+1, Makes the semantics more predictable too.

comment:9 Changed 12 years ago by john

+1

comment:10 Changed 12 years ago by ajpiano

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

comment:11 Changed 12 years ago by dmethvin

Milestone: 1.next1.7
Priority: undecidedblocker

comment:12 Changed 12 years ago by gnarf

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

comment:13 Changed 12 years ago by Corey Frang

Resolution: fixed
Status: assignedclosed

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.