Permalink
Browse files

Change Element#retrieve to return the element itself (for chaining).

  • Loading branch information...
1 parent f8a2522 commit 1ca385b18c79ab510c6955c07f9f2bc53cfdd2ae @savetheclocktower savetheclocktower committed Dec 15, 2008
Showing with 6 additions and 2 deletions.
  1. +2 −0 CHANGELOG
  2. +1 −0 src/dom/dom.js
  3. +3 −2 test/unit/dom_test.js
View
@@ -1,3 +1,5 @@
+* Change Element#retrieve to return the element itself (for chaining). (Andrew Dupont)
+
* Add non-bubbling custom events. A new final argument to Element#fire defaults to `true`; pass `false` to prevent bubbling when firing a custom event. (Andrew Dupont)
* Alter event system to use new element storage API rather than have its own global hashtable. (Andrew Dupont)
View
@@ -1232,6 +1232,7 @@ Element.addMethods({
store: function(element, key, value) {
if (!(element = $(element))) return;
element.getStorage().set(key, value);
+ return element;
},
retrieve: function(element, key, defaultValue) {
View
@@ -1371,8 +1371,9 @@ new Test.Unit.Runner({
var element = $('test-empty');
element.store('foo', 'bar');
this.assertEqual("bar", element.retrieve("foo"), "Setting and reading a property");
- element.store('foo', 'thud');
+ var result = element.store('foo', 'thud');
this.assertEqual("thud", element.retrieve("foo"), "Re-setting and reading property");
+ this.assertIdentical(element, result, "Element#store should return element");
element.store('bar', 'narf');
this.assertEnumEqual($w('foo bar'), element.getStorage().keys(), "Getting the storage hash");
@@ -1381,7 +1382,7 @@ new Test.Unit.Runner({
this.assertUndefined(element.retrieve('bar'), "Undefined key should return undefined if default value is not defined");
this.assertEqual("default", element.retrieve('bar', 'default'), "Return default value if undefined key");
- this.assertEqual("default", element.retrieve('bar'), "Makes sure default value as been set properly");
+ this.assertEqual("default", element.retrieve('bar'), "Makes sure default value has been set properly");
var clonedElement = $('test-empty').cloneNode(false);
this.assert(!('_prototypeUID' in clonedElement), "Cloning a node should not confuse the storage engine");

2 comments on commit 1ca385b

Contributor

arthurschreiber replied Dec 15, 2008

Uhm, that’s Element#store, not Element#retrieve.

Collaborator

savetheclocktower replied Dec 16, 2008

Yes. I have since fixed this in the CHANGELOG. I am too lazy to fix this commit message.

Please sign in to comment.