Permalink
Browse files

Refactored _fireEvent for IE6 up to IE9.

TESTED (green): IE6-9, FFx3-5, Opera 11, Safari 5, Chrome dev

IE8 and IE9 require the fireEvent to manually bound.
<IE8 just saves a copy prior to augmenting.

I tried to keep the code together, but IE didn't let up.
  • Loading branch information...
1 parent 57749c4 commit 79c4efe80a1a5865e429e5b207a732350c837589 @ibolmo ibolmo committed Nov 27, 2011
Showing with 12 additions and 7 deletions.
  1. +11 −6 Source/Element/Element.js
  2. +1 −1 Specs
View
@@ -41,10 +41,16 @@ var Element = function(tag, props){
return document.newElement(tag, props);
};
-var docFragment = document.createDocumentFragment();
-var FIRE_EVENT = docFragment.createElement && docFragment.createElement('div').fireEvent;
-if (Browser.Element) Element.prototype = Browser.Element.prototype;
+if (Browser.Element){
+ Element.prototype = Browser.Element.prototype;
+ // IE8 and IE9 require the wrapping.
+ Element.prototype._fireEvent = (function(fireEvent){
+ return function(type, event){
+ return fireEvent.call(this, type, event);
+ };
+ })(Element.prototype.fireEvent);
+}
new Type('Element', Element).mirror(function(name){
if (Array.prototype[name]) return;
@@ -250,12 +256,11 @@ Document.implement({
element: function(el, nocash){
$uid(el);
+ if (jasmine.annoy) alert('doh');
if (!nocash && !el.$family && !(/^(?:object|embed)$/i).test(el.tagName)){
+ el._fireEvent = el.fireEvent;
Object.append(el, Element.Prototype);
}
- if (FIRE_EVENT && !el._fireEvent) el._fireEvent = function(){
- return FIRE_EVENT.apply(el, arguments);
- };
return el;
},

0 comments on commit 79c4efe

Please sign in to comment.