From 391dad3c9967287a0d31d97a8de06115e40c128b Mon Sep 17 00:00:00 2001 From: Justin Tulloss Date: Tue, 27 Jan 2015 16:28:47 -0800 Subject: [PATCH] Save a reference to the snapshot on the immutable value This allows us to later get a firebase reference to it and to get it's priority, among other nice things. --- src/reactfire.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/reactfire.js b/src/reactfire.js index 4a59281c..d520452a 100644 --- a/src/reactfire.js +++ b/src/reactfire.js @@ -133,7 +133,9 @@ var ReactFireMixin = { else if (typeof(snapshot) === "object") { out = out.withMutations(function(map) { snapshot.forEach(function(child) { - map.set(child.key(), Immutable.fromJS(child.val())); + var immutableChild = Immutable.fromJS(child.val()); + immutableChild.snapshot = child; + map.set(child.key(), immutableChild); }); }); } @@ -151,7 +153,9 @@ var ReactFireMixin = { else if (typeof(snapshot) === "object") { out = out.withMutations(function(list) { snapshot.forEach(function(child) { - list.push(Immutable.fromJS(child.val())); + var immutableChild = Immutable.fromJS(child.val()); + immutableChild.snapshot = child; + list.push(immutableChild); }); }); }