diff --git a/examples/unfinished/shark/client/shark.js b/examples/unfinished/shark/client/shark.js
index 227badbbe3..e5beb4656f 100644
--- a/examples/unfinished/shark/client/shark.js
+++ b/examples/unfinished/shark/client/shark.js
@@ -104,13 +104,13 @@ Either = UIComponent.extend({
elseContent: Span
}),
{ type: Span });
- buf(new _UI.Each({
+ /* buf(new _UI.Each({
content: UIComponent.extend({
render: function (buf) {
buf("
Each ", String(this.data()), "
");
}
})
- }));
+ }));*/
}
});
diff --git a/packages/ui/components.js b/packages/ui/components.js
index dc0751a278..c31474f1a5 100644
--- a/packages/ui/components.js
+++ b/packages/ui/components.js
@@ -34,16 +34,6 @@ _UI.If = Component.extend({
}
});
-_UI.Each = Component.extend({
- typeName: 'Each',
- render: function (buf) {
- var self = this;
- buf(self.content(function () { return 0; })),
- buf(self.content(function () { return 1; }));
- buf(self.content(function () { return 2; }));
- }
-});
-
_UI.Counter = Component.extend({
typeName: "Counter",
fields: {
diff --git a/packages/ui/each.js b/packages/ui/each.js
new file mode 100644
index 0000000000..5379aba76a
--- /dev/null
+++ b/packages/ui/each.js
@@ -0,0 +1,49 @@
+var Component = UIComponent;
+
+_UI.Each = Component.extend({
+ typeName: 'Each',
+ render: function (buf) {
+ var self = this;
+
+ // XXX support arrays too.
+ // For now, we assume the data is a database cursor.
+ var cursor = self.data();
+ // XXX also support `null`
+
+
+
+ var self = this;
+ buf(self.content(function () { return 0; })),
+ buf(self.content(function () { return 1; }));
+ buf(self.content(function () { return 2; }));
+ }
+});
+
+
+// Function equal to LocalCollection._idStringify, or the identity
+// function if we don't have LiveData. Converts item keys (i.e. DDP
+// keys) to strings for storage in an OrderedDict.
+var idStringify;
+
+// XXX not clear if this is the right way to do a weak dependency
+// now, post-linker
+if (typeof LocalCollection !== 'undefined') {
+ idStringify = function (id) {
+ if (id === null)
+ return id;
+ else
+ return LocalCollection._idStringify(id);
+ };
+} else {
+ idStringify = function (id) { return id; };
+}
+
+// XXX duplicated code from minimongo.js.
+var applyChanges = function (doc, changeFields) {
+ _.each(changeFields, function (value, key) {
+ if (value === undefined)
+ delete doc[key];
+ else
+ doc[key] = value;
+ });
+};
diff --git a/packages/ui/library.js b/packages/ui/library.js
index ffec3d572f..796192dd10 100644
--- a/packages/ui/library.js
+++ b/packages/ui/library.js
@@ -182,7 +182,7 @@ Each = Component.extend({
var idStringify;
// XXX not clear if this is the right way to do a weak dependency
-// now, on the linker branch
+// now, post-linker
if (typeof LocalCollection !== 'undefined') {
idStringify = function (id) {
if (id === null)
diff --git a/packages/ui/package.js b/packages/ui/package.js
index 91eacd0ace..c2be5c2a2e 100644
--- a/packages/ui/package.js
+++ b/packages/ui/package.js
@@ -20,6 +20,7 @@ Package.on_use(function (api) {
'render.js',
'dom.js',
'forms.js',
+ 'each.js',
'components.js',
'component.js', 'renderbuffer.js',