/*
---

name: Element.From

description:

license: MIT-style license.

author:
	- Jean-Philippe Dery (jeanphilippe.dery@gmail.com)

requires:

provides:
	- Element.From
	- Element.At

...
*/

(function() {

/**
 * @see http://moobile.net/api/0.1/Element/Element.From#ElementFrom
 *
 * @author Jean-Philippe Dery (jeanphilippe.dery@gmail.com)
 * @since  0.1.0
 */
Element.from = function(text) {

	switch (typeof text) {
		case 'object': return document.id(text);
		case 'string': return Elements.from(text).pop();
	}

	return null;
};

var elements = {};

/**
 * @see http://moobile.net/api/0.1/Element/Element.From#ElementAt
 *
 * @author Jean-Philippe Dery (jeanphilippe.dery@gmail.com)
 * @since  0.1.0
 */
Element.at = function(path, async, fn) {

	var element = elements[path];
	if (element) {
		if (fn) fn(element);
		return element;
	}

	async = async || false;

	new Moobile.Request({
		method: 'get',
		async: async,
		url: path
	}).addEvent('success', function(response) {
		element = Element.from(response);
		if (fn) fn(element);
	}).addEvent('failure', function(request) {
		if (fn) fn(null);
	}).send();

	if (element) elements[path] = element;

	return !async ? element : null;
};

})();
@@ -788,24 +788,55 @@
 (element) %7B%0A
+%09%09var clone = element.clone();%0A
 %09%09if (fn) fn
@@ -832,31 +832,29 @@
 %09if (fn) fn(
-element
+clone
 );%0A%09%09return 
@@ -853,23 +853,21 @@
 %09return 
-element
+clone
 ;%0A%09%7D%0A%0A%09a
@@ -1059,16 +1059,24 @@
 (element
+.clone()
 );%0A%09%7D).a
@@ -1188,16 +1188,16 @@
 ement;%0A%0A
-
 %09return 
@@ -1212,16 +1212,24 @@
  element
+.clone()
  : null;

The element needs to be closed