zzsoszz / base2

Automatically exported from code.google.com/p/base2
0 stars 0 forks source link

base2.DOM.bind() and element.cloneNode doesn't work well together #51

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
:: What steps will reproduce the problem?

1. base2.DOM.bind() some HTMLElement
2. clone this element (cloneNode)
3. bind() this new, cloned element
4. try for example: alert(element.addEventListener)

:: What is the expected output? What do you see instead?

Expected is some object (function, string, etc.), insted it returns 
undefined in IE. Probably element is not binded because base2 thinks it 
was binded before.

:: What version of the product are you using? On what operating system?

IE6, Windows XP SP2

:: Please provide any additional information below.

if I will do something like this:

base2.DOM.bind(element); // it is first time I bind this element
var clone = element.cloneNode(true);
clone.base2ID = undefined;
base2.DOM.bind(clone);

then the element IS binded, but it still do not work well (for the 
addEventExample: action on new element, such as onfocus will trigger event 
listener from the old object (not the cloned one).

In my case everything looks ok in other browsers, so I did not analized if 
in fact everything works well.

----

I have prepared simple test case. Problem in this test case seems to be 
quite different, but clearly shows that there is problem with bind and 
cloneNode in IE.

http://ffreak.net/-/base2_vs_cloneNode.html

Original issue reported on code.google.com by ffreak@gmail.com on 30 Jul 2007 at 3:16

GoogleCodeExporter commented 9 years ago

Original comment by dean.edw...@gmail.com on 30 Jul 2007 at 5:48

GoogleCodeExporter commented 9 years ago
One thing I've seen: IE's cloneNode also clones (or just copies) 
attachEvent-added 
event listeners....

Original comment by doek...@gmail.com on 31 Jul 2007 at 2:29

GoogleCodeExporter commented 9 years ago
This code fixes it:

// remove the base2ID for clones
extend(Element.prototype, "cloneNode", function(deep) {
  var clone = this.base(deep || false);
  clone.base2ID = undefined;
  return clone;
});

Will check this in soon.

Original comment by dean.edw...@gmail.com on 10 Aug 2007 at 4:49

GoogleCodeExporter commented 9 years ago
Fixed.

Original comment by dean.edw...@gmail.com on 10 Aug 2007 at 9:52