--- _dhtml.js/0.9/2007-11-17-18/dhtml.js 2007-12-02 21:58:04.000000000 +0100
+++ dhtml.js 2008-01-12 01:42:40.000000000 +0100
@@ -12,7 +12,7 @@
* @section Copyright & Disclaimer
*
* @author
- * (C) 2002-2007 Thomas Lahn ,
+ * (C) 2002-2008 Thomas Lahn ,
* 2001 SELFHTML e.V. et al.,
* 2004 Ulrich Kritzner (loadScript),
* 2005 MozillaZine Knowledge Base contributors (DOM XPath):
@@ -79,11 +79,16 @@
* for details.
*/
+if (typeof _global != "undefined")
+{
+ var _global = this;
+}
+
function DHTML()
{
- this.version = "0.9.2.2007111718";
+ this.version = "0.9.3.2008011201";
// var dhtmlDocURL = dhtmlPath + "dhtml.htm";
- this.copyright = "Copyright \xA9 2002-2007";
+ this.copyright = "Copyright \xA9 2002-2008";
this.author = "Thomas Lahn";
this.email = "dhtml.js@PointedEars.de";
this.path = "http://pointedears.de/scripts/";
@@ -200,6 +205,10 @@
if (!isNaN(i) && i > -1)
{
result = found[i];
+ }
+ else
+ {
+ result = found;
}
}
@@ -474,7 +483,7 @@
if (o)
{
- // W3C DOM Level 2 Core
+ // W3C DOM Level 2 Core
if (typeof o.firstChild != "undefined")
{
if (typeof o.firstChild.nodeType != "undefined"
@@ -525,7 +534,7 @@
{
if (o)
{
- // DOM Level 2 Core
+ // DOM Level 2 Core
if (typeof o.firstChild != "undefined")
{
o.firstChild.nodeValue = sNodeValue;
@@ -943,6 +952,10 @@
{
if (o)
{
+ sPropertyName = sPropertyName.replace(
+ /-([a-z])/gi,
+ function(m, p1) { return p1.toUpperCase(); });
+
if (typeof o.style != "undefined")
{
if (typeof o.style[sPropertyName] != "undefined")
@@ -1593,7 +1606,7 @@
*/
function _addEventListener(o, sEvent, fListener)
{
- var result = false;
+ var result = false, sHandler = "on" + sEvent;
if (o && sEvent && isMethodType(typeof fListener) && fListener)
{
@@ -1602,18 +1615,36 @@
o.addEventListener(sEvent, fListener, false);
result = true;
}
- else
+ else if (typeof o[sHandler] != "undefined")
{
- if (isMethodType(typeof o.attachEvent) && o.attachEvent)
- {
- result = o.attachEvent("on" + sEvent, fListener);
- }
-
- if (!result)
+ // We don't attempt to use MSHTML's buggy attachEvent() anymore;
+ // thanks to Peter-Paul Koch for insight:
+ // http://www.quirksmode.org/blog/archives/2005/08/addevent_consid.html
+
+ var oldListener = o["on" + sEvent];
+
+ o[sHandler] = function(e)
{
- o["on" + sEvent] = fListener;
- result = (o["on" + sEvent] == fListener);
- }
+ if (!e)
+ {
+ e = (typeof _global.window != "undefined"
+ && typeof window.event != "undefined"
+ && window.event);
+ }
+
+ if (oldListener)
+ {
+ oldListener(e);
+ }
+
+ fListener(e);
+ };
+
+ result = (o[sHandler] == fListener);
+ }
+ else
+ {
+ result = false;
}
}