#976 bug
dami

Element.addMethods('SPAN', ...) fails on WebKit

Reported by dami | January 4th, 2010 @ 11:17 AM

Fatal error on WebKit when calling Element.addMethods on a SPAN element (prototype.js v1.6.1, Windows XP).

Element.addMethods('SPAN', {foo: function(){}});

Tested on both Safari 4.0.4 and Google Chrome 3.0.195.38 : both complain that
TypeError: Result of expression 'destination' [undefined] is not an object, prototype.js:2999

It seems that the specific DOM class for 'SPAN' has no 'prototype' property.

No such problem under MSIE8 or Firefox.

As a temporary fix I changed line 3040 from

if (Object.isUndefined(klass)) continue;

to

if (Object.isUndefined(klass) || Object.isUndefined(klass.prototype)) continue;

which apparently gets rid of the problem, but I have no idea if this is the proper way to solve it.

Comments and changes to this ticket

  • Tobie Langel
  • Tisho Georgiev

    Tisho Georgiev March 1st, 2010 @ 03:28 PM

    • Tag set to section:dom
    • State changed from “new” to “bug”
  • Flambino

    Flambino February 28th, 2011 @ 04:54 AM

    • Importance changed from “” to “Medium”

    Had a similar issue in IE8 when adding methods to PRE elements.

    The issue seems to be in findDOMClass() (inside addMethods). Unless I'm mistaken, that function returns a DOMElement's class if it can find it, but for the last return statement, it returns the prototype.

    addMethods attempts to add methods to the prototype of whatever findDOMClass returns. When findDOMClass returns something that's already a prototype, you get the error.

    At least, that's what I think is going on. My (suboptimal) patch is to change line 3049 in addMethods from:

    copy(T[tag], klass.prototype);
    

    to:

    copy(T[tag], klass.prototype || klass); // in case klass (returned by findDOMClass) is already a prototype
    

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

Pages