Maybe I'm misunderstanding this code on first pass, but does this trigger an event that will walk up the dom everytime someone changes jQuery data? Won't this potentially cause huge performance issues?
@justin, Irbabe: We've always fired events on the manipulation of .data() (previously just getData/setData and now with the useful addition of changeData). It looks like setData/changeData are bubbling - which should not be the case. I'll change this in a follow-up commit.
Yeah, I knew it was sending events. I was just surprised it was bubbling. I don't think data events should be bubbling by default.
However, I can definitely see a use case for data listeners - plugins that listen high on the dom for data changes and send an Ajax request back to the server -and these would require bubbling data events. But, someone should have to opt-in for this performance penalty.
BTW: this is Justin, l realized I was logged in with my other account.
This comment has been minimized.
defkode repliedJul 20, 2010
thats fantastic and useful addition.
This comment has been minimized.
justinbmeyer repliedJul 26, 2010
Maybe I'm misunderstanding this code on first pass, but does this trigger an event that will walk up the dom everytime someone changes jQuery data? Won't this potentially cause huge performance issues?
This comment has been minimized.
louisremi repliedJul 27, 2010
This would have been perfect as a plugin, considering the potential performance issues. I will no think twice before using .data()
This comment has been minimized.
cowboy repliedJul 27, 2010
You can use the
$.data( elem, ... )
syntax instead of$(elem).data( ... )
if you don't want any of the events to fire.This comment has been minimized.
louisremi repliedJul 27, 2010
Yep, but I still think it made more sense as a plugin.
This comment has been minimized.
jeresig repliedJul 27, 2010
@justin, Irbabe: We've always fired events on the manipulation of .data() (previously just getData/setData and now with the useful addition of changeData). It looks like setData/changeData are bubbling - which should not be the case. I'll change this in a follow-up commit.
This comment has been minimized.
jeresig repliedJul 27, 2010
Fixed in c4b4df4.
This comment has been minimized.
ghost repliedJul 27, 2010
Yeah, I knew it was sending events. I was just surprised it was bubbling. I don't think data events should be bubbling by default.
However, I can definitely see a use case for data listeners - plugins that listen high on the dom for data changes and send an Ajax request back to the server -and these would require bubbling data events. But, someone should have to opt-in for this performance penalty.
BTW: this is Justin, l realized I was logged in with my other account.
This comment has been minimized.
louisremi repliedJul 27, 2010
"Fixed in c4b4df4."
Yay!