Skip to content

Commit b90dd57

Browse files
committed
fixed error with event.target in Event Manager Moddule
1 parent 69c4d37 commit b90dd57

File tree

6 files changed

+83
-111
lines changed

6 files changed

+83
-111
lines changed

dist/tigerjs/tiger_min.js

Lines changed: 35 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/$.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,8 @@ TigerJS.$ = function (el_) {
591591
*/
592592
this.el.remove_class = function (classNames) {
593593

594-
var cls = T.Iterator(this.className.split(" ")), //get the classes on the element
595-
arg = arguments[0].split(" "); //get the classes to remove
596-
597-
this.className = cls.without(arg).
598-
join(" "); //remove classes not neeed and replace on the element
594+
classNames = classNames.split(" ").join(",");
595+
this.classList.remove(classNames);
599596
return this;
600597
};
601598

@@ -608,11 +605,9 @@ TigerJS.$ = function (el_) {
608605
*/
609606

610607
this.el.add_class = function (classNames) {
611-
var cls = T.Iterator(this.className.split(" ")); //get the classes currently on the element
612608

613-
this.remove_class(classNames); //try to remove the classes been sent in case they already exist so we dont duplicate
614-
this.className = cls.merge(classNames.split(" ")).
615-
join(" "); //add parameters with existing classes
609+
classNames = classNames.split(" ").join(",");
610+
this.classList.add(classNames);
616611
return this;
617612
};
618613
/**
@@ -651,12 +646,8 @@ TigerJS.$ = function (el_) {
651646
*
652647
*/
653648
this.el.toggle_class = function (className) {
654-
if (this.has_class(className)) {
655-
this.remove_class(className);
656-
} else {
657649

658-
this.add_class(className);
659-
}
650+
this.classList.toggle(className);
660651
return this;
661652
};
662653
/**

src/bootstrap.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function insert_svg_icons() { //insert SVG icons refrenced in HTMLElements class
8989

9090
};
9191
svgImages.add(x);
92-
92+
x.remove_class(T_ICON_CLASS);
9393

9494
});
9595

@@ -170,10 +170,7 @@ function insert_svg_icons() { //insert SVG icons refrenced in HTMLElements class
170170

171171
SVGNodesArray[i].id = svgImages[i].id;
172172
}
173-
if (svgImages[i].className) {
174-
175-
SVGNodesArray[i].setAttribute("class", svgImages[i].className);
176-
}
173+
177174

178175

179176

src/eventManager.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
22
/* global TigerJS, T */
33

44
/* This file is part of the TigerJS Javascript Library @@https://sourceforge.net/p/tigerjs> */
@@ -18,11 +18,11 @@ TigerJS.EventManager = function () {
1818
if (!('hasOwnProperty' in Event.prototype)) {
1919
addHasOwnProperty(event);
2020
}
21-
if (!('stopPropagation' in Event.prototype)) {
21+
if (!('stopPropagation' in Event.prototype)) { //IE hack
2222
Event.prototype.stopPropagation = function () {
2323
this.cancelBubble = true;
2424
};
25-
Event.prototype.stopImmediatePropagation = function () {
25+
Event.prototype.stopImmediatePropagation = function () { //IE again
2626
this.cancelBubble = true;
2727
this.immediatePropagationStopped = true;
2828
};
@@ -139,10 +139,9 @@ TigerJS.EventManager = function () {
139139
*@ignore
140140
*/
141141
normalize_event = function (eventObject) {
142-
var e = eventObject;
142+
var e = T.clone( eventObject);
143143
var keys = getKey(e); //normalize the DOM3 key and char values
144144
e['key'] = keys.key;
145-
146145
e["char"] = keys["char"];
147146
e["_char"] = keys["_char"];
148147
//normalize the event object,
@@ -161,7 +160,7 @@ TigerJS.EventManager = function () {
161160

162161
e.relatedTarget = getRT(e);
163162
e.timeStamp = (new Date).getTime();
164-
e.target = T.$(e.target ? e.target : e.srcElement);
163+
e.target = T.$(e.currentTarget || e.srcElement || e.target);
165164
e.clientX = e.clientX || e.Y || this.changedTouches[0].pageY;
166165
e.clientY = e.clientY || e.X || this.changedTouches[0].pageX;
167166
e.defaultPrevented = e.defaultPrevented || e.returnValue;
@@ -479,19 +478,6 @@ TigerJS.EventManager = function () {
479478
}
480479

481480

482-
},
483-
///private
484-
///removeEvent abstraction Layer, accepts target, event type, and callback
485-
/*
486-
*@ignore
487-
*/
488-
489-
removeListener = function (target, type, callBack) {
490-
491-
target.removeEventListener ? target.removeEventListener(type, callBack) :
492-
target.detachEvent("on" + type, callBack);
493-
494-
495481
};
496482

497483
///accept initialization parameters from DOM-CLASS, TigerJS.$ -> "on" method

src/nodes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ TigerJS.nodes = function(config, strictMatch) {
237237

238238

239239
for (i = 0; i < this.n.length; i++) {
240-
this.n[i] = T.$(this.n[i]);
240+
this.n[i] = T.$(this.n[i]); //tigerfy
241241
}
242242
this.n = T.Iterator(this.n); //convert to an iterator filled up with nodes
243243

0 commit comments

Comments
 (0)