Permalink
Browse files

Merge pull request #73 from alexblack/master

xui-ie was failing on IE6/7/8 in the function reduce, trying to use Array.indexOf
  • Loading branch information...
2 parents f6804b0 + 787cc72 commit 4d673232f80b2c7dcb836fbe108fde645cea9267 @brianleroux brianleroux committed Mar 27, 2012
Showing with 17 additions and 4 deletions.
  1. +14 −1 src/base.js
  2. +3 −3 src/ie/event.js
View
15 src/base.js
@@ -45,6 +45,19 @@ if (! [].forEach) {
}
};
}
+/*
+ * Patch indexOf for internet explorer: http://soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/
+ */
+if(!Array.indexOf){
+ Array.prototype.indexOf = function(obj) {
+ for(var i = 0; i < this.length; i++) {
+ if(this[i] == obj){
+ return i;
+ }
+ }
+ return -1;
+ }
+}
/*
* Array Remove - By John Resig (MIT Licensed)
*/
@@ -56,7 +69,7 @@ function removex(array, from, to) {
// converts all CSS style names to DOM style names, i.e. margin-left to marginLeft
function domstyle(name) {
- return name.replace(/\-[a-z]/g,function(m) { return m[1].toUpperCase(); });
+ return name.replace(/\-[a-z]/g,function(m) { return m.charAt(1).toUpperCase(); });
}
// converts all DOM style names to CSS style names, i.e. marginLeft to margin-left
View
6 src/ie/event.js
@@ -89,7 +89,7 @@ xui.extend({
else {
var responders = _getRespondersForEvent(_getEventID(el), type);
responders.forEach(function(r) {
- r.call(el);
+ r.call(el, event);
});
}
});
@@ -123,8 +123,8 @@ function _createResponder(element, eventName, handler) {
var responder = function(event) {
if (handler.call(element, event) === false) {
- event.preventDefault();
- event.stopPropagation();
+ event.stopPropagation ? event.stopPropagation() : (event.cancelBubble=true);
+ event.preventDefault ? event.preventDefault() : (event.returnValue = false);
}
};
responder.guid = handler.guid = handler.guid || ++_getEventID.id;

0 comments on commit 4d67323

Please sign in to comment.