Steve - interesting.

In my tests, 1.2 didn't have this problem.  There's not a whole lot of
differences between the 1.2 and 1.3 Element.clone() function - I tried
commenting out the only real difference in 1.3 and it still didn't
work, which means there's some other issue in 1.3.  I also tried
passing "false" into mergeAttributes without much luck.


On Oct 25, 5:28 pm, "Steve Onnis" <[email protected]> wrote:
> Well there is defiantly an issue and i can tell you what is it.  When the
> item is cloned the ID is staying with it even though the actual ID attribute
> is updated, according to the DOM it does not change. I can confirm this
> because after the item is injected the id that is returned from the injected
> element is still the original id from the cloned element but the id in the
> actual code has been updated
>
> The IE version i was testing this on it version 6.0.3790.3959 in Service
> Pack 2
>
> This works...
>
> <script type="text/javascript" charset="utf-8">
>
>       document.addEvent('domready', function(){
>
>             cloned = new Element($('cloneMe').get("tag"), {"id":
> "sauce"}).set("html",
> $('cloneMe').get("html")).inject($('cloneMe').parentNode, "top");
>
>             alert(cloned.getParent().get("html"));
>
>             });
>
>       function getSauce() {
>
>             var el = $(document.body).getElements("div")[0];
>
>             alert(el.get('id') + "\n" + el.get("text"));
>
>             }
>
> </script>
>
> <input type="button" onclick="getSauce()" value="get sauce" />
>
> This does not work...
>
> <script type="text/javascript" charset="utf-8">
>
>       document.addEvent('domready', function(){
>
>             cloned = $('cloneMe').clone();
>
>             cloned.set('id', 'sauce').set("text", "the cloned
> one").inject($('cloneMe').parentNode, "top");
>
>             alert(cloned.getParent().get("html"));
>
>             });
>
> function getSauce() {
>
>             var el = $(document.body).getElements("div")[0];
>
>             alert(el.get('id') + "\n" + el.get("text"));
>
>             }
>
> </script>
>
> <input type="button" onclick="getSauce()" value="get sauce" />
>
> Looking at the code the element.clone() function is handled a little
> different for IE. It uses the clearAttributes() method on the element object
> but according to the MSDN
> (http://msdn.microsoft.com/en-us/library/ms536350%28VS.85%29.aspx) docs it
> says:-
>
> "The clearAttributes method clears only persistent HTML attributes. The ID
> attribute, styles, and script-only properties are not affected."
>
> It also uses a method element.mergAttributes() which is meant to copy the
> attributes from one element to another. The MSDN docs
> (http://msdn.microsoft.com/en-us/library/ms536614%28VS.85%29.aspx) say you
> pass in a source object and an optional "preserve" flag (true or false) to
> say if you want to preserve the identity of the attributes but i don't see
> that being used in the mootools code.  
>
> I think certainly something that needs to be looked at
>
> Steve

Reply via email to