This project is archived and is in readonly mode.

#1126 ✓wontfix

new Element('map') error.

Reported by dotmoo | December 27th, 2010 @ 04:09 PM | in 1.3.1 (closed)


I wanted to create a map Element with the new Element command. As result I get an error:

var test = new Element('map');
TypeError: Cannot call method 'call' of undefined

When I try to use only javascript without mootools libaries it works:

var foo = document.createElement('map');
var bar = document.createElement('area');
bar.coords = '12,23,45';
    Result => "12,23,45"


<area coords=​"12,23,45">​

I used Mootools 1.3 with compatibility and full more build with version

Comments and changes to this ticket

  • mattcoz

    mattcoz December 29th, 2010 @ 04:09 AM

    Nice catch!

    The problem is in this code in Element.js:

    var Element = function(tag, props){

    var konstructor = Element.Constructors[tag];
    if (konstructor) return konstructor(props);</code>

    Element.Constructors['map'] is defined as the map function of the Object prototype. You'll get the same error if trying to create an element with a tag name of filter, every, etc. We should be using hasOwnProperty to avoid this.

    var Element = function(tag, props){
        if (Element.Constructors.hasOwnProperty(tag)) return Element.Constructors[tag](props);

  • Arian

    Arian December 31st, 2010 @ 03:55 PM

    • Milestone set to 1.3.1
    • State changed from “new” to “open”
    • Assigned user set to “Christoph Pojer”
    • Milestone order changed from “855” to “0”

    Indeed, because with Compat Element.Constructors is a Hash, which has a map method.

  • Christoph Pojer

    Christoph Pojer January 4th, 2011 @ 02:58 PM

    • State changed from “open” to “wontfix”

    If you use MooTools Core 1.3 without compatibility it will work. We won't fix this as the no-compat and future versions already have this fix.

  • dotmoo

Create your profile

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

Shared Ticket Bins