From 4607e29fa2f0b00d836b4ea900afbb44f1f8c1b1 Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Thu, 11 Oct 2007 06:11:26 +0000 Subject: [PATCH] prototype: Element#wrap now returns the wrapper instead of the element being wrapped. --- CHANGELOG | 2 ++ src/dom.js | 2 +- test/unit/dom.html | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 3b97d5c..a7ca26b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Element#wrap now returns the wrapper instead of the element being wrapped. [sam] + * Namespace all custom event names to avoid conflicts with native DOM events. [sam] - All custom event names MUST include a namespace. Prefix custom event names for observe, stopObserving, and fire with the namespace followed by a colon. E.g. document.fire("widget:activated") - The "contentloaded" event is now "dom:loaded". diff --git a/src/dom.js b/src/dom.js index cdce566..133e9b2 100644 --- a/src/dom.js +++ b/src/dom.js @@ -153,7 +153,7 @@ Element.Methods = { if (element.parentNode) element.parentNode.replaceChild(wrapper, element); wrapper.appendChild(element); - return element; + return wrapper; }, inspect: function(element) { diff --git a/test/unit/dom.html b/test/unit/dom.html index 6058d15..a0f8f44 100644 --- a/test/unit/dom.html +++ b/test/unit/dom.html @@ -569,6 +569,13 @@ assertEqual(orphan.parentNode, div); }}, + testElementWrapReturnsWrapper: function() {with(this) { + var element = new Element("div"); + var wrapper = element.wrap("div"); + assertNotEqual(element, wrapper); + assertEqual(element.up(), wrapper); + }}, + testElementVisible: function(){with(this) { assertNotEqual('none', $('test-visible').style.display); assertEqual('none', $('test-hidden').style.display);